Search code examples
pythonregressionpredictionstatsmodels

Statsmodels OLS get_prediction on out-of-sample data


I am trying to use get_prediction from statsmodels on out-of-sample data but it keeps returning in-sample data results.

  #Exponential regression
  Q1_Er = smf.ols(formula='log_Value ~ Date_Ordinal', data=sp500).fit()

  prediction = Q1_Er.get_prediction(xnew) #xnew is out-of-sample data of type pandas.core.series.Series

  frame = prediction.summary_frame(alpha=.05)

The summary frame returns values from the in-sample data instead of the xnew out-of-sample data.

Any ideas how I get the summary frame to return confidence intervals from my out-of-sample data, instead?


Solution

  • Changing xnew from series to dataframe fixes this issue