Can statsforecast fit on a / "for a" specific pred...
# statsforecast
m
Can statsforecast fit on a / "for a" specific prediction window ? https://nixtla.github.io/statsforecast/src/core/core.html#statsforecast.fit
Copy code
sf.fit(df = Y_df)
For instance, currently the MSTL with AutoArima is not picking up any exogenous regressors. If the prediction window is only the next step clearly the AR MA lags dominate but my objective is e.g. 48 hours ahead and there the covariates might prove beneficial. How can I do this using statsforecast package ? Also is there some summary of fitted model similar to statsmodels? : ) Thanks so much
k
You can do:
Copy code
sf.fitted_[0][0].model_
I don’t know about the 48 hours ahead. Let me ask someone
m
Hi @Matej I was looking at your question, but I'm not sure I follow. Do you want to fit the next 48 hours ahead in the historical data? If that is the case, then the cross-validation method can help.
Copy code
crossvalidation_df = sf.cross_validation(
  df = df,
  h = 48,
  step_size = 48,
  n_windows = 3
 )
With this, you are fitting a MSTL model using all the information up to the cutoff date. If you want to fit the whole historical data, just change the number of windows to include all possible values. If this is not what you need/want, please elaborate so we can help you with that.
m
Apologies, I got into time series only recently so safely correct me if I am talking nonsense. • I mean to ask, if it is possible to fit the model with a specific forecast horizon in mind. • This might be beneficial as then the loss function/likelihood can reflect the specific time horizon. See for example, (the also legendary) R package smooth: https://openforecast.org/adam/multistepLosses.html If I understand correctly, the ETS model is then able to consider the forecast horizon h in its estimation of parameters. Specifically the General Predictive Likelihood, (GPL) loss or others... Thanks for being so helpful : )
Also, • Is it somehow possible to parallelize the sf.cross_validation ? When I run it, the process is only able to utilize one CPU, but that might be an issue on my side running it in jupyter or something like that.
Copy code
sf.fitted_[0][0].model_
for MSTL this only returns the components:
Copy code
data	trend	seasonal remainder
...
I assume I have to calculate the summary such as likelihood and R^2 by myself out of these numbers or out of
Copy code
insample_forecasts = sf.forecast_fitted_values()
Sorry for asking dumb questions, some things are not obvious from the documentation.
b
@Matej Don't see an answer to your question about parallelizing CV. I was able to do it in Jupyter and also Databricks by using n_jobs in the "StatsForecast" call that pipes into cross_validation. I'm not an expert with statsforecast--just getting into it from the R world, but parallelization and also distributed processing were important for me too.
❤️ 1