2

I am trying to creat a Seasonal ARIMA model by using the class statsmodels.statespace.sarimax.SARIMA, and the model seems to be well created. The JPEG of SARIMA Model summary

Now, I want to pass the AR coefficents and MA coefficents to variables seperately, but it appear a error that: SARIMAXResults object has no attribute _params_ma. The JPEG of error

What should I do to correct the error?

Bruno
  • 3,872
  • 4
  • 20
  • 37
Wei CHEN
  • 21
  • 1
  • 4
  • I have a new problem now. After the model is fitted, I tried to use `SARIMAXResults.cov_params` to get the correlation matrix of parameter estimates, but on jupyter notebook, it only shows me `>`, it seems the process suceed to a calculate a matrix as a result, but why it can't be shown? – Wei CHEN Nov 02 '18 at 08:36

2 Answers2

0

Finnaly, I find it was my own fault.

Following my SARIMA(2,0,0)X(0,0,1,12) model, the non-seasonal element has orders(p,d,q)=(2,0,0), and the seasonal element has orders (P,D,Q,s)=(0,0,1,12). Thus, the model says that the data has a nonseasonal AR(2) pattern, and a seasonal MA(1)_12 pattern. As a result, the coefficient of nonseasonal MA pattern which is corresponding to SARIMAXResults.maparams will not be estimated. By contrast, the coefficient of seasonal MA partter which is corresponding to SARIMAXResults.seasonalmaparams will be estimated.

For purpose of getting estimated coefficient value of seasonal MA pattern, I should call seasonalmaparams() method, instead of maparams().

The error problem is solved now. :D

Wei CHEN
  • 21
  • 1
  • 4
0

Well, after seeing the soure code, the other propblem added in the comment is also solved.

Actually, the parenthesis should be added to call the attribute of SARIMAXResults, so cov_params() will show the covariance-variance matrix, as following: cov_params matrix

Next, for sake of calculating the correlation matrix of parameters, I coded as following:

# Step1: Pass the covariance-variance matrix to a specified DataFrame
df_cov = final_result.cov_params()
# Step2: Creat a blank DataFrame which will be used to store correlation values
coef_name = [r'$b_1$',r'$b_2$',r'$\theta_1$',r'$\phi_{12}$',r'$\phi_{24}$']
cor_df = pd.DataFrame(index=coef_name,columns=coef_name)
cor_df.loc[:,:]=''
# Step3: Loop the covariance-variance matrix and calculate the correlation
var=[0]*5
for i in range(5):
    var[i] = df_cov.iloc[i,i]
for i in range(5):
    for j in range(5):
        if j<=i:
            corvar = df_cov.iloc[i,j] 
            cor = corvar/np.sqrt(var[i]*var[j])
            cor_df.iloc[i,j] = round(cor,2)
        else:
            continue
# Step4: Show the correlation matrix(as type of DataFrame)
cor_df

Finally, the correlaton matrix is well calculated as shown as below: correlation matrix

Thanks for your attention, no more question now.

Wei CHEN
  • 21
  • 1
  • 4