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!
Related Posts with xtreg/reghdfe + dynamic forecasting
Adding rows under a variableStata command for adding rows lets say 10 rows under a variable which has fixed observations like 40…
please help. making bar graph more simple with "over" optionsHi, guys. I'm a newcomers with stata, and there is some trouble in making bar graph. My data has 4…
Writing a formula in which stata chooses a value or 1Hi! I'm trying to use this formula to calculate eGFR: eGFR = 142*min(standardized Scr/K, 1)^α *max(…
Pseudo Panel Data and Mediation AnalysisDear Stata Experts I'm a PhD student, and I'd like to know how to use the codes to perform the Medi…
Please help cant work out how to t-test. Im new to stataHi guys I'm struggling to compare 2 different regions with a t-test. As seen from the screenshots I…
Subscribe to:
Post Comments (Atom)
0 Response to xtreg/reghdfe + dynamic forecasting
Post a Comment