0

I have 2 1D np.array X and Y that are the values of a time series.I am trying to do time series forecasting. However when i apply the following code :

mod = RollingOLS(endog=Y, exog=X, window=75, min_nobs=None,expanding=True)
fit=mod.fit()
print("Akaike")
print(fit.aic)

i get an array of length equal to the one of X and Y which lead me to think that the mdeolization doesn't work as i would like to because i should get only one value.

Thus, i think that the format of X and Y is inadequate. How can i solve this ?

rg75
  • 3
  • 2

1 Answers1

0

According to the document, exog is supposed to be 2D array, [nobs, k].

exog: array_like A nobs x k array where nobs is the number of observations and k is the number of regressors. An intercept is not included by default and should be added by the user. See statsmodels.tools.add_constant.

You might want to add a column filled with ones.

import statsmodels.api as sm
X = sm.add_constant(X)
# if your statsmodel version is new
# X = statsmodels.tools.tools.add_constant(X)

https://www.statsmodels.org/stable/generated/statsmodels.regression.rolling.RollingOLS.html
https://www.statsmodels.org/stable/examples/notebooks/generated/rolling_ls.html

Maybe related question
Why do I get only one parameter from a statsmodels OLS fit

Watanabe.N
  • 1,549
  • 1
  • 14
  • 37