For class, I had to do a Fama French 3 Factor analysis. This is it, adapted for the internet.
library(tidyquant)
library(broom)
Let’s grab 2 years of the weekly fama french data.
#quandl_api_key("insert-quandl-api-key")
fama_french <- tq_get("KFRENCH/FACTORS_W", get = "quandl", to = "2017-02-24")
fama_french
We will need the weekly returns for the fama french analysis. The adjusted close price will be used to calculate them. Scale the returns as percentages since that is what Fama factors are in.
iwd_weekly <- iwd %>%
tq_transmute(select = adjusted,
col_rename ="weekly_returns",
mutate_fun = periodReturn,
period = "weekly") %>%
mutate(weekly_returns = weekly_returns * 100)
iwd_weekly
fama_iwd <- left_join(iwd_weekly, fama_french) %>%
mutate(ret_minus_rf = weekly_returns - rf) # Subtract the risk free rate
fama_iwd
ff_model <- lm(ret_minus_rf ~ mkt.rf + smb + hml, data = fama_iwd)
estimates <- tidy(ff_model)
estimates
stats <- glance(ff_model)
stats
The Fama-French 3 factor model explains IWD arithmetic returns very well, with an adjusted R squared of 0.98273. The intercept of -0.02437 suggests that IWD under performed the regression benchmark. The mkt.rf estimate of 0.96151 represents the beta of the fund, and shows that the fund slightly under reacts to market movements. The hml (High minus Low) factor has a coefficient of 0.23312, high enough to classify this fund as a “value” fund, which makes sense given the name. Similarly, the negative smb (Small minus Big) factor of -0.048 classifies this fund as “large”, which again is consistent with its name.