Reputation: 497
I am fitting an ARMA model with a linear trend to a sequence and I would like to access the parameters after optimization to make some test. It seems like I can access the parameters via the attribute params
, but it's just an array with all the parameters in it. Is there a more convenient way to access the parameters (e.g. a dictionary)?
import numpy
from statsmodels.tsa.statespace.sarimax import SARIMAX
N_TRAIN = 100
train_data = numpy.random.randn(N_TRAIN)
model = SARIMAX(
endog=train_data,
order=(2, 0, 2),
seasonal_order=(0, 0, 0, 0),
trend='ct',
enforce_stationarity=False,
enforce_invertibility=False
)
fitted_model = model.fit(disp=False, maxiter=100, method='powell')
print(fitted_model.params)
Out:
[-0.03781736 -0.00285008 0.88970682 -0.88314944 -1.05743719 0.89770456
0.84405409]
Upvotes: 1
Views: 1016
Reputation: 3195
If the input endog
array is a Numpy array, then all results from Statsmodels are also Numpy arrays.
If you make your data into a Pandas series, then the returned params
object will be a Pandas Series including parameter names.
For example you could do: train_data = pd.Series(numpy.random.randn(N_TRAIN))
(after doing import pandas as pd
).
Upvotes: 2