Dynamic factor model : forecasting the factors

Viewed 594

The statsmodels package offers a DynamicFactor object that, when fit, yields a statsmodels.tsa.statespace.dynamic_factor.DynamicFactorResultsWrapper object. That offers predict and simulate methods, but both forecast the original time-series, not the underlying latent factor.

I've tried reconstructing the latent factor as an AR process, but have been unsuccessful. The coefficients in both the .ssm["transition"] and in the results .summary() match, but when simulated as an AR process, don't give me back the factor on the results .factors["filtered"]...

How can I generate future values of the latent factors ?

1 Answers

One way to do this is:

m = sm.tsa.DynamicFactor(endog, k_factors=1, factor_order=1)
r = m.fit()
f = r.get_forecast(10)
print(f.prediction_results.filtered_state)

Note that this is always a numpy array, so if your data has e.g. a Pandas date index, you would need to create the Pandas Series with that index yourself.

Another way to do this is to append np.nan values to the end of your dataset, and then use the typical .factors["filtered"] accessor. If you append n observations with np.nan, then the last n values of .factors["filtered"] will contain the forecasts of the factors.

Related