2big2fail
2big2fail

Reputation: 21

Get Values out of summary of statsmodels AutoReg

I got data and need to estimate the autoregressive value with lag 1 "AR(1)" of a column.

I got the summary which looks like this:

import pandas as pd
import pandas_datareader as pdr
from statsmodels.tsa.ar_model import AutoReg
mod = AutoReg(df["Column"], 1)
res = mod.fit()
print(res.summary())

I am happy with the results i get.

My question is: Is is possible to get the value of the first AR coefficient as simple output value?

I got the documentation 1 but don't understand if one method is useful for this and dont have any other ideas.

Bonus question: Is it possible to create a loop (or get several values at once) and put it in a DF?

Appreciate your help :)

Upvotes: 1

Views: 1675

Answers (1)

user17409849
user17409849

Reputation: 11

The parameters are accessible via res.params. If you need the first parameter, you can retrieve it using res.params[0]. You can also loop through and use them as per your requriements.

res.params is already a Series; so you do not have to do too much work for changing it to a df.

You can check out below link for examples: https://machinelearningmastery.com/autoregression-models-time-series-forecasting-python/

Upvotes: 1

Related Questions