1
votes

What formula does this function use after computing a simple linear regression (OLS) on data? There's many different prediction interval formulas, some using RMSE (root mean square error), some using standard deviation, etc.

http://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.OLSResults.get_prediction.html#statsmodels.regression.linear_model.OLSResults.get_prediction

In particular, I want to know if it's using this formula or something else: pi

Note the standard deviation of x parameter.

1
It uses a more general version, full code is in this module github.com/statsmodels/statsmodels/blob/master/statsmodels/… (e.g. variance for expected value/mean would take a robust sandwich covariance into account if specified by cov_type) - Josef
Yea, I confirmed it is using a more general version that works with multiple regression too. I'm just wondering if what it does with just 1 independent variable is the same as what is in my formula above. I see that the standard error it calculates is sqrt(var_pred_mean + var_resid). var_resid is the same thing as my s_y term above squared. However, I don't know how to break down var_pred_mean. - jerbear

1 Answers

0
votes

It does use the same formula as shown above. The standard error of the prediction is calculated using the formula sqrt(variance of predicted mean + variance of residuals). This can be simplified as shown in this link.