Hi Delaney
In the MLR lecture I can't work out why running slr.params[1] is returning 2.78 but when printing summary.results() it shows X2 coef is 1.
Is the coef printed on the summary screen not reflecting the beta?
I noticed the same problem further on when running the MLR using a benchmark whereby using the results.summary () and mlr.summary () are showing different values for the X1 and X2 coef.
Additionally, the example at the end of the lecture using X1...X4 has the beta line up with the coef that is printed on results.summary (). Not sure why I'm getting conflicting results or if I'm simply interpreting it incorrectly.
Code for SLR:
start = '2014-01-01'
end = '2015-01-01'
asset1 = get_pricing('AAPL', fields='price', start_date=start, end_date=end)
asset2 = get_pricing('FISV', fields='price', start_date=start, end_date=end)
benchmark = get_pricing('SPY', fields='price', start_date=start, end_date=end)
slr = regression.linear_model.OLS(asset1, sm.add_constant(asset2)).fit()
print 'SLR beta of asset2:', slr.params[1]
print results.summary()
Code for MLR:
mlr = regression.linear_model.OLS(asset1, sm.add_constant(np.column_stack((asset2, benchmark)))).fit()
prediction = mlr.params[0] + mlr.params[1]*asset2 + mlr.params[2]*benchmark
prediction.name = 'Prediction'
print 'MLR beta of asset2:', mlr.params[1], '\nMLR beta of S&P 500:', mlr.params[2]
print results.summary()
mlr.summary()