MasaAsami / pysynthdid

Synthetic difference in differences for Python
Apache License 2.0
66 stars 22 forks source link

Converting tau when data is log transform #2

Open ciberger opened 2 years ago

ciberger commented 2 years ago

Hey! thanks for your package

I've been playing around with it as an extension of Google's CausalImpact tool.

Got a dataset with market data having different scales, so log transformation is needed. However, I couldn't transform back ATT from its value estimated from log input data to one unscaled. Which formula should I use? Also, is it possible to get confidence interval for tau?

MasaAsami commented 2 years ago

Hi! Thank you for your comment.

However, I couldn't transform back ATT from its value estimated from log input data to one unscaled.

As a simple example, consider a linear model. Think about the meaning of the following x1 coefficient when the outcome variable Y is log-transformed.

image

As you can see from this

β1 means "Y increases by β1( = log Y'- log Y) when x1 increases by 1".

Since log(1 + y) can be approximated as y, the following transformation is possible: log Y'- log Y = log(Y'/Y)       = log(1 + (Y' - Y)/Y )        ~ (Y' - Y) / Y

In other words, we can think of it as "Y increases by β% as x1 increases by 1. This is the same in this model, which can be interpreted as an ATT of {tau}%!

I apologize if I misread the intent of your question.