Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def run_ordinary_least_squares(ols_dates, ols_data, statsmodels_settings):
This method receives the dates and prices of a Quandl data-set as well as settings for the StatsModels package,
it then calculates the regression lines and / or the confidence lines are returns the objects
intercept = np.column_stack((ols_dates, ols_dates ** statsmodels_settings.exponent))
constant = sm.add_constant(intercept)
statsmodel_regression = sm.OLS(ols_prices, constant).fit()
if statsmodels_settings.confidence:
prstd, lower, upper = wls_prediction_std(statsmodel_regression)
return statsmodel_regression, lower, upper
return statsmodel_regression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment