Skip to content

Instantly share code, notes, and snippets.

@HumanRupert
Created January 24, 2021 07:17
Show Gist options
  • Save HumanRupert/13be290216ed3d376f3d432a2b67d4c5 to your computer and use it in GitHub Desktop.
Save HumanRupert/13be290216ed3d376f3d432a2b67d4c5 to your computer and use it in GitHub Desktop.
import statsmodels.api as sm
# join factors to returns dfs
data = factors.join(excess_returns).dropna()
y = data[["Returns"]]
x = data[["Mkt-RF","SMB","HML"]]
ols = sm.OLS(y,x)
result = ols.fit()
betas = result.params
print(betas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment