1

I am having some troubles with forecasting panel data using the fixed model of the plm pachage. I know that it does not have a built-in forecasting function, so I want to compute the out-of-sample forecasts by hand. Is my logic correct:

fixed <- plm(y ~ x1 + x2, data=panel_df, index=c("country", "year"), model="within")

forecast <- fixed$coefficients[1] * x1 + 
            fixed$coefficients[2] * x2 + 
            as.numeric(fixef(fixed))

Of course, as this is out-of-sample forecasting, I am using lagged variables (already defined in the data.frame panel_df), and for the forecasting I use the last observations, which should give forecasts for the one-ahead (unknown) period.

I would be grateful for confirming whether such approach is correct!

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
Masher
  • 133
  • 1
  • 7

0 Answers0