SARIMAX simulate

207 views
Skip to first unread message

David Waterworth

unread,
Oct 18, 2019, 4:17:48 AM10/18/19
to pystatsmodels
The R forecast package has a simulate() which allows monte-carlo simulation of a SARIMA model, i.e

sim <- ts(matrix(0, nrow=30, ncol=10000), start=end(residuals)[1]+1)
for(i in seq(10000))
  sim[,i] <- simulate(fit, nsim=30)

simulates 10000 paths, nsteps=30

Does the statsmodels SARIMAX have the same functionality?

Dave

josef...@gmail.com

unread,
Oct 18, 2019, 1:37:15 PM10/18/19
to pystatsmodels
I don't know what simulation methods are in the statespace models, 
but there is an old function for simulating ARMA processes.

Josef 

 

Dave

--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystatsmodel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pystatsmodels/40210055-1a40-463c-907d-59e68d00aea1%40googlegroups.com.

Chad Fulton

unread,
Oct 18, 2019, 10:20:12 PM10/18/19
to Statsmodels Mailing List
On Fri, Oct 18, 2019 at 1:37 PM <josef...@gmail.com> wrote:


On Fri, Oct 18, 2019 at 4:17 AM David Waterworth <david.wa...@cimenviro.com> wrote:
The R forecast package has a simulate() which allows monte-carlo simulation of a SARIMA model, i.e

sim <- ts(matrix(0, nrow=30, ncol=10000), start=end(residuals)[1]+1)
for(i in seq(10000))
  sim[,i] <- simulate(fit, nsim=30)

simulates 10000 paths, nsteps=30

Does the statsmodels SARIMAX have the same functionality?

I don't know what simulation methods are in the statespace models, 
but there is an old function for simulating ARMA processes.

Josef 

 

Unfortunately this is an area which has not received enough development attention for the state space models. There does exist a `simulate` method, but it currently is not very user friendly. Its default is to simulate a *new* dataset following the current state space model, which is not the same thing as simulating *additional* datapoints after the existing dataset, and unfortunately the current interface does not make it entirely straightforward to do the latter.

However, you can do it, e.g. as follows:

# Create and fit the model
mod = sm.tsa.SARIMAX(endog, <your spec here>)
res = mod.fit()

# Create a faux model to use for simulation
mod_sim = sm.tsa.SARIMAX([0] * 30, <your spec here>)
mod_sim.initialize_known(res.predicted_state[..., -1], res.predicted_state_cov[..., -1])

sim = np.zeros((30, 10000))
for i in range(10000):
    sim[:, i] = mod_sim.simulate(res.params, 30)

Best,
Chad

David Waterworth

unread,
Oct 19, 2019, 9:15:46 PM10/19/19
to pystatsmodels
Thanks Chad

I ended up using R's sim.ssarima from the smooth package as I just wanted some quick test data - but thatks for the tip

Regards
David
Reply all
Reply to author
Forward
0 new messages