I am trying to regenerate the ARMA parameters from statsmodel in python. The code I am using is:

from statsmodels.tsa.arima_process import arma_generate_sample
import statsmodels.api as sm
arparams = np.array([.75, -.25])
maparams = np.array([.65, .35])
arparams = np.r_[1, -arparams]
maparam = np.r_[1, maparams]
nobs = 250
y = arma_generate_sample(arparams, maparams, nobs) #generate ARMA series
res = sm.tsa.arma_order_select_ic(y, ic=['aic', 'bic'], trend='nc')
z = sm.tsa.ARMA(y, (2,2)).fit()
print z.arparams
array([ 0.13178508,  0.08568388])

The regenerated AR params are not same as the one I started with. What am I doing wrong?


1 Answer 1


The logic of your code is all right. However, the variance of the parameters is high because nobs=250 is relatively low. Increase nobs and your parameters will converge toward the parameters you specified eventually.

import statsmodels.api as sm
import numpy as np

# Parameters.
ar = np.array([.75, -.25])
ma = np.array([.65, .35])

# Simulate an ARMA process.
y = sm.tsa.arma_generate_sample(
    ar=np.r_[1, -ar],
    ma=np.r_[1, ma],

# Fit ARMA process on the simulates to check coefficients, ACF and PACF.
model = sm.tsa.ARMA(y, (2, 2)).fit(trend='c')

# Plot ACF and PACF of estimated model.
sm.tsa.graphics.plot_acf(y, lags=20, zero=True);
sm.tsa.graphics.plot_pacf(y, lags=20, zero=True);

Reference: McKinney, W., Perktold, J., & Seabold, S. (2011)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.