tlamadon / pytwoway

Two way models in python
MIT License
24 stars 7 forks source link

BLM - worker effects var(alpha) #52

Closed MartinHaus1993 closed 1 year ago

MartinHaus1993 commented 1 year ago

Hi there,

I have a quick question regarding the BLM estimator. The example notebook ( https://tlamadon.github.io/pytwoway/notebooks/blm_example.html ) notes that

By default, the variance is var(psi) and the covariance is cov(psi, alpha). The default estimates don’t include var(alpha), but if you don’t include controls, var(alpha) can be computed as the residual from var(y) = var(psi) + var(alpha) + 2 * cov(psi, alpha) + var(eps).

I might be missing something here, but I guess this only holds if there are no interaction effects (see the BLM paper p.704)? I have no additional controls and just checked if I add tw.Q.VarAlpha() to Q_var when calling the fit function, the var(alpha) differs from the residual - which makes sense unless some additional restrictions are met?

But I might be missing something here!

Thanks, Martin

adamoppenheimer commented 1 year ago

Hi Martin,

Thanks for the question, and thanks for using the package!

I think the issue is that for the BLM variance decomposition, weighting actually doesn't make sense. Unfortunately at the moment there isn't an option to specify whether to run a weighted/unweighted variance decomposition for BLM, but you can get around this by:

What happens if you do these?

Best, Adam

MartinHaus1993 commented 1 year ago

Hi Adam,

Thanks for the quick response! You are right. If I manually set all weights to 1 before running the variance decomposition the residual and tw.Q.VarAlpha() have the same value.

Thanks a lot for looking into this!

Best wishes, Martin