1

I have a very similar problem to this question and it works for the training data. Now I´m trying to get the confidence interval for the predicted data:

from statsmodels.sandbox.regression.predstd import wls_prediction_std
#define y, X, X_forecast as pandas dataframes
regressor = sm.api.OLS(y, X).fit()
wls_prediction_std(regressor.predict(X_forecast))

But, of course, gives an error complaining about regressor.predict being an array. How can I calculate the confidence interval for the predicted regression values?

Community
  • 1
  • 1
Ivan
  • 19,560
  • 31
  • 97
  • 141
  • In my understanding, the confidence interval belongs to the curve you've obtained via regression. Thus, it does not really make sense to calculate it again for the test data (you call it "predicted"). You just do it for the training data as in the link you provide, and then you know that for any of your predictions you get the value at the curve +/- the confidence interval. Hope it helps. – lrnzcig Aug 25 '15 at 14:24
  • I found a way: you just have to pass the argument exog to the wls_predictoin_std function call. – Ivan Aug 25 '15 at 18:33

1 Answers1

1

you may have put the wrong parameter.

Let's try this one :

wls_prediction_std(regressor, exog=X_forecast, weights=None, alpha=0.05)
Meloman
  • 3,558
  • 3
  • 41
  • 51
SamLin
  • 11
  • 2