Linear regression model
In this exercise you're going to use the Fama French model to explain the returns in your portfolio. You'll first walk through the linear regression model taking all the different steps, and obtain the summary at the end to interpret the results.
In this exercise you'll use statsmodels. You might have come across the linear regression model in scikit-learn. If you are curious how the two options compare, you can read more in this blogpost.
Available is a dataset called factor_returns which contains portfolio returns as well as the Fama French factors. Good luck!
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Introduction to Portfolio Analysis in Python
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Define the model
model = sm.____(factor_returns['pf_returns'], factor_returns[['Mkt-RF','SMB', 'HML']]).____()