# Panel Data and Forecasting

I have balanced panel data for around 130 countries, over three years. I ran a fixed effects regression using 'country' as my panel variable, and adding dummies for 'year'. I want to forecast the value of the dependent variable for the next 20 years, for only one country in particular. Could somebody suggest the best way to do this?

I am using Stata for this purpose.

• why are you using dummies for year? treat it as a trend variable and forecasting will be much easier. – EconJohn Nov 18 '18 at 20:17
• I think your best bet here is to gather data that will help explain that dependent variable for your desired country, specify a model, and then predict for that country. – 123 Dec 18 '18 at 14:29

Probably this question is better placed at stackoverflow. Technically, in order to predict out of the sample, you need the full set of variables in the estimation. So after carrying out the estimation, you could do something like this. I assume your last observed year is 2010.

* expand US data for the last observed data point.
expand 20 if country == "US" & year == 2010
bys country year: replace year = . if _n > 1
bys country (year): replace year = year[_n-1] if year == .
estimates restore panel_estimation
predict outcome_var
* check whether that worked
tw line outcome_var year if country == "US"


This will predict a value based on your panel estimation also for the newly created observations. I am not judging whether it makes sense to extrapolate a time-trend over three years to twenty years ;)

• predict outcome_var, xbu accounts for the fixed effects. Also, as you said, the full set of variables (X) are needed. – chan1142 Sep 19 '18 at 1:44
• When predicting the future, you are basically either making the claim that you think one of your covariates will change and so you predict a change in the dependent variable, or the claim that there is some time trend that you expect to continue, and are using that time trend to predict the future. By using dummies for year, you're not estimating a time trend, and have no basis for making a prediction about the future. This answer looks legit for how to code this up (although I think you're missing a +1 in line 5), but I think you also have to use a parametric form for year, not dummies. – NickCHK Oct 21 '18 at 18:36
• This is an econometrics exercise. The question belongs here and not at stackoverflow. – 123 Dec 18 '18 at 14:20