Search code examples
statapredict

Predict yhat by changing estimates values with fixed effects


I have a individual-year level panel data, and run a simple regression of Y on Xs with year and individual fixed effects:

Y_it = a0 + a1*x1_it + a2*x2_it + FE_t + FE_i + e_it

I type:

reg Y x1 x2 i.year i.individual

So I get estimates a0_hat, a1_hat, and a2_hat.

I need to see the counterfactual levels of Y when we have a different value of a2.

If there are no fixed effects, I can just store the estimates and compute:

Yhat = a0hat + a1hat*x1_it + a2hat*x2_it

where I can change a2hat to any values I want.

However, when we have the time and individual fixed effects, is the only way to store all of them as well? Is there an option of predict where we can specify the value of a2 and keep other estimates and fixed effects at their estimated values?


Solution

  • I think there's a bit of misunderstanding with your question. You can't actually change a2hat as that is an estimated coefficient. You can change the values in x2_it, though...

    If I'm not wrong, the command margins does what you want.

    Alternatively, you can store also store the estimates after reg and compute it yourself (as you mention). If you use reg, the Stata output should also contain the coefficients of the fixed effects.

    Also, it could be useful to check out other options for panel data, especially in xtreg.