Hi there,
I am using a two-way fixed effects model that I would like to use to forecast and simulate alternative scenarios based on the Stata command "forecast". The challenge here is how to use the command forecast with two dimensional FE. The stata manual explains quite well how to use the command forecast in a panel with one FE, but not if you want to consider region and time fe.
My data is strongly balanced with T=572 and N=324. Now I can either use xtreg, fe or reghdfe, but both alternatives lead to different error messages.
1. use of reghdfe
xtset county week, weekly
reghdfe y L1.y x_1 x_2 , vce(cluster Landkreis) absorb(i.week i.county) resid(r)
estimates store est_1
predict FE if age_group==`susc',d
bysort Landkreis: egen FE_2=mean(FE)
forecast create est_1, replace
* adjust for FE
forecast estimates est_1, name(est_1, replace)
forecast adjust est_1=est_1+ FE_2
* declare non-stochastic relationships
forecast identities
forecast exogenous
forecast solve, begin(tw(2011w28)) log(off) prefix(alt2_) simulate(betas errors, statistic(stddev, prefix(sd_alt2_)) reps(500))
=> I obtain the follwoing error message: "command may not be used with panel data"
2. use of xtreg
xtset county week, weekly
xtreg y L1.y x_1 x_2 i.week , vce(cluster Landkreis) fe
estimates store est_1
predict FE if age_group==`susc', u
bysort Landkreis: egen FE_2=mean(FE)
forecast create est_1, replace
* adjust for FE
forecast estimates est_1, name(est_1, replace)
forecast adjust est_1=est_1+ FE_2
* declare non-stochastic relationships
forecast identities
forecast exogenous
forecast solve, begin(tw(2011w28)) log(off) prefix(alt2_) simulate(betas errors, statistic(stddev, prefix(sd_alt2_)) reps(500))
=> I obtain the following error message "cannot simulate parameter vector
Stored estimation result I_a5 contains a parameter covariance matrix that is not full rank, so forecast cannot draw multivariate normal parameters."
Any advise is highly welcome!
0 Response to xtreg/reghdfe + dynamic forecasting
Post a Comment