dell_data <- read_csv("fnce611_hw4.csv")
lm1 <- lm(dell_excess_return ~ sp_excess_return, data = dell_data)
equation = function(x) {
lm_coef <- list(a = formatC(coef(x)[1], digits = 4, format = 'f'),
b = formatC(coef(x)[2], digits = 4, format = 'f'),
r2 = formatC(summary(x)$r.squared, digits = 2, format = 'f'));
lm_eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(R)^2~"="~r2,lm_coef)
as.character(as.expression(lm_eq));
}
dell_data %>%
ggplot(aes(x = sp_excess_return, y = dell_excess_return)) +
geom_point() +
geom_smooth(method = 'lm', se = FALSE) +
annotate("rect", xmin = -.17, xmax = -.028, ymin = .08, ymax = 0.12, fill="white", colour = pal538[['red']]) +
annotate("text", x = -0.1, y = 0.1, label = equation(lm1), parse = TRUE,
family = "DecimaMonoPro", size = 3) +
theme_jrf(users_v = 'rstudio') +
labs(title = "Linear Regression of 5-year History", x = "S&P Excess Return",
y = "Dell Excess Return")
beta <-
lm1 %>%
tidy() %>%
filter(term == "sp_excess_return") %>%
select(estimate) %>%
unlist() %>%
unname()
We find that \(\beta\) = 0.9803.
dell_expected_return <- mean(dell_data$risk_free_return) * 52 +
beta * (mean(dell_data$sp_return) * 52 - mean(dell_data$risk_free_return) * 52)
Dell’s expected return is 0.0726.
variance <-
dell_data %>%
summarise(
dell_var = sd(dell_return)^2 * 52
, sp_var = sd(sp_return)^2 * 52
)
dell_var | sp_var |
---|---|
0.1342 | 0.0513 |
Of Dell’s sample variance, 0.1342, we can say that 0.0493 is from market risk and 0.0849 is firm specific risk.