def test_smoke(data, period, use_mle, deseasonalize, use_test, diff, model): if period is None and isinstance(data, np.ndarray): return res = ThetaModel( data, period=period, deseasonalize=deseasonalize, use_test=use_test, difference=diff, method=model, ).fit(use_mle=use_mle) assert "b0" in str(res.summary()) res.forecast(36) res.forecast_components(47) assert res.model.use_test is (use_test and res.model.deseasonalize) assert res.model.difference is diff
ax.set_title("Housing Starts") plt.tight_layout(pad=1.0) # We could alternatively fit the log of the data. Here it makes more # sense to force the deseasonalizing to use the additive method, if needed. # We also fit the model parameters using MLE. This method fits the IMA # # $$ X_t = X_{t-1} + \gamma\epsilon_{t-1} + \epsilon_t $$ # # where $\hat{\alpha}$ = $\min(\hat{\gamma}+1, 0.9998)$ using # `statsmodels.tsa.SARIMAX`. The parameters are similar although the drift # is closer to zero. tm = ThetaModel(np.log(housing), method="additive") res = tm.fit(use_mle=True) print(res.summary()) # The forecast only depends on the forecast trend component, # $$ # \hat{b}_0 # \left[h - 1 + \frac{1}{\hat{\alpha}} # - \frac{(1-\hat{\alpha})^T}{\hat{\alpha}} \right], # $$ # # the forecast from the SES (which does not change with the horizon), and # the seasonal. These three components are available using the # `forecast_components`. This allows forecasts to be constructed using # multiple choices of $\theta$ using the weight expression above. res.forecast_components(12)