You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add method for generating ARMA predictions for new data, unrelated to training data #2577
It seems that the only way to use a trained ARMA model on new data is to use this internal function: _arma_predict_out_of_sample. Furthermore, it's not obvious how to do so.
I would assume that for an ARMA(p,q) model, there are max(p.q) previous datapoints required to generate a new prediction. So If I had an AR(2,3) model I'd need to pass in 3 datapoints to get one new output sample. There is also some information about past "residuals" that is not completely clear how to generate. An API like the following (perhaps with extra required parameters such as residuals....) would be quite useful to me:
The problem is that a ARMA(p,q) in it's basic prediction form needs to use the q past residuals for prediction. Those are usually obtained from fitting the model the the previous data points.
With a standalone function the user would need to provide the previous residuals, either from a filter operation or by assumption. so we would have two possibilities
require users to provide q residuals
allow users to provide a long time series of the data (endog y), and run the filter over the entire sample to estimate the residuals from zero initial conditions without reestimating the parameters.
The statespace model might provide something like the corresponding filter. @ChadFulton
I have a longer comment that I'll post in a moment, but there's a quick solution that you may be interested in. Suppose that you have a training dataset X and a new unrelated dataset Y. As I understand it, you want to do the following:
Estimate parameters using dataset X
Get out-of-sample predictions conditional on the observations in Y.
One way to do that is the following; let's suppose you want to fit an ARIMA(4,1,1) model and you want 5 out-of-sample forecasts.
I was going to post something else, but on reflection the above is almost certainly what you want. And it will work no matter how many data points are in Y.
Josef, how many previous points are required to compute the q residuals? Is
there a simple formula giving this?
Chad, sorry for the naive question, but what is SARIMAX? Seasonal ARIMA I
guess... but what is the "X"? Also teh switch from AMIRA(4,1,1) to SARIMAX
in your solution surprises me...
Thanks!
On Fri, Aug 7, 2015 at 12:36 PM, ChadFulton [email protected]
wrote:
I was going to post something else, but on reflection the above is almost
certainly what you want. And it will work no matter how many data points
are in Y.
—
Reply to this email directly or view it on GitHub #2577 (comment)
.
SARIMAX stands for Seasonal Autoregressive Integrated Moving-average with eXogenous regressors. It is just a very generic class that allows more general models than just ARIMA. So in the example I gave, it does not use the seasonal component or the exogenous regressors component, and so is just estimating an ARIMA(4,1,1) model as you would expect.
I should note, I guess, that SARIMAX is part of the state space package which is in master, but has not yet been released (it will be in statsmodels 0.7.0).
Hi @ChadFulton ! It's really great to see the new released! Would you mind explain more about when adding exog variables in the scenario above? Thanks much!!! How many data points required for exog?
Activity
josef-pkt commentedon Aug 7, 2015
The problem is that a ARMA(p,q) in it's basic prediction form needs to use the q past residuals for prediction. Those are usually obtained from fitting the model the the previous data points.
With a standalone function the user would need to provide the previous residuals, either from a filter operation or by assumption. so we would have two possibilities
The statespace model might provide something like the corresponding filter. @ChadFulton
josef-pkt commentedon Aug 7, 2015
milestone 0.8 if someone wants to give it a try.
josef-pkt commentedon Aug 7, 2015
I don't remember what the requirements are for calculating prediction intervals.
ChadFulton commentedon Aug 7, 2015
I have a longer comment that I'll post in a moment, but there's a quick solution that you may be interested in. Suppose that you have a training dataset X and a new unrelated dataset Y. As I understand it, you want to do the following:
One way to do that is the following; let's suppose you want to fit an ARIMA(4,1,1) model and you want 5 out-of-sample forecasts.
ChadFulton commentedon Aug 7, 2015
I was going to post something else, but on reflection the above is almost certainly what you want. And it will work no matter how many data points are in Y.
eraoul commentedon Aug 7, 2015
Thanks Josef and Chad.
Josef, how many previous points are required to compute the q residuals? Is
there a simple formula giving this?
Chad, sorry for the naive question, but what is SARIMAX? Seasonal ARIMA I
guess... but what is the "X"? Also teh switch from AMIRA(4,1,1) to SARIMAX
in your solution surprises me...
Thanks!
On Fri, Aug 7, 2015 at 12:36 PM, ChadFulton [email protected]
wrote:
ChadFulton commentedon Aug 7, 2015
SARIMAX stands for Seasonal Autoregressive Integrated Moving-average with eXogenous regressors. It is just a very generic class that allows more general models than just ARIMA. So in the example I gave, it does not use the seasonal component or the exogenous regressors component, and so is just estimating an ARIMA(4,1,1) model as you would expect.
I should note, I guess, that SARIMAX is part of the state space package which is in master, but has not yet been released (it will be in statsmodels 0.7.0).
josef-pkt commentedon Aug 7, 2015
the documentation for SARIMAX is at http://www.statsmodels.org/dev/statespace.html#seasonal-autoregressive-integrated-moving-average-with-exogenous-regoressors-sarimax
ARMA also supports the explanatory, exogenous variables X, but the name is from before it did.
That depends on the persistence of the process. Unless persistence is very high, the filtered series can be short and we can just assume that the residuals are zero before a few periods ago.
I never tried out any experiments for this.
I think the impulse response function could be used to see how long lasting shocks are.
(For ARMA there is a ArmaProcess class that takes the arma parameters/lag polynomials and can calculate the impulse response function. http://www.statsmodels.org/dev/generated/statsmodels.tsa.arima_process.arma_impulse_response.html )
hanhanzhai commentedon Feb 15, 2017
Hi @ChadFulton ! It's really great to see the new released! Would you mind explain more about when adding exog variables in the scenario above? Thanks much!!! How many data points required for exog?
mod1 = sm.tsa.SARIMAX(X, order=(4,1,1))
res1 = mod1.fit()
mod2 = sm.tsa.SARIMAX(Y, order=(4,1,1))
res2 = mod2.filter(res1.params)
print(res2.forecast(5))