Download five years of monthly stock prices for Wesfarmers, Woolworths, Rio Tinto, BHP Billiton, Telstra.1 Download the monthly levels of the ASX 200 for same period. Calculate the beta for each of the stocks. Assuming that the expected market return is equal to the historical long-term average return of 12%, and the average risk free return is 3%, what is the risk aversion parameter for the average investor in Australia according to the CAPM model?
Ra <- c("BHP.AX", "WES.AX", "WOW.AX", "RIO.AX", "TLS.AX") %>%
tq_get(get = "stock.prices",
from = "2012-08-21",
to = "2017-08-21") %>%
group_by(symbol) %>%
tq_transmute(select = adjusted,
mutate_fun = periodReturn,
period = "monthly",
col_rename = "Ra")
Ra %>%
ggplot(aes(date, Ra, group = symbol, color = symbol)) +
geom_line() +
facet_wrap(~ symbol, ncol = 2, scale = "free_y") +
guides(color = FALSE)
Rb <- "^AXJO" %>%
tq_get(get = "stock.prices",
from = "2012-08-21",
to = "2017-08-21") %>%
tq_transmute(select = adjusted,
mutate_fun = periodReturn,
period = "monthly",
col_rename = "Rb")
Rb %>%
ggplot(aes(date, Rb, fill = Rb)) +
geom_bar(stat = "identity") +
labs(title = "ASX200 Returns",
x = "", y = "Monthly Returns") +
geom_smooth(method = "lm") +
theme_tq() +
scale_color_tq() +
scale_y_continuous(labels = scales::percent) +
guides(fill = FALSE)
RaRb <- left_join(Ra, Rb, by = c("date" = "date"))
RaRb_capm <- RaRb %>%
tq_performance(Ra = Ra,
Rb = Rb,
performance_fun = table.CAPM)
RaRb_capm
RaRb_capm %>%
select(Alpha, Beta)
RaRb %>%
ggplot(aes(Rb, Ra, group = symbol, color = symbol)) +
geom_point() +
facet_wrap(~ symbol, ncol = 2) +
labs(title = "Stock Betas",
x = "ASX 200 Return", y = "Stock Returns") +
geom_smooth(method = "lm") +
scale_y_continuous(labels = scales::percent) +
guides(color = FALSE)
All data sourced from Yahoo Finance↩