r_p <- 0.11
r_f <- 0.05
target_return <- 0.08
y <- (target_return - r_f) / (r_p - r_f)
y_risk_free <- 1 - y
y
## [1] 0.5
y_risk_free
## [1] 0.5
#b. Standard deviation of the complete portfolio
sigma_p <- 0.15
sigma_c <- y * sigma_p
sigma_c
## [1] 0.075
#c. Second client: target standard deviation = 12%
target_sigma <- 0.12
y2 <- target_sigma / sigma_p
expected_return2 <- y2 * r_p + (1 - y2) * r_f
y2
## [1] 0.8
expected_return2
## [1] 0.098
r_m <- 0.12
sigma_m <- 0.20
sigma_c <- 0.10
expected_return_c <- r_f + (sigma_c / sigma_m) * (r_m - r_f)
expected_return_c
## [1] 0.085
#Chapter 6 - CFA Problem 8 a. Required rate of return using CAPM
cash_flows <- c(-1000, 500, 500, 500)
beta <- 1.5
required_r <- r_f + beta * (r_m - r_f)
required_r
## [1] 0.155
#b.Net Present Value (NPV) of the project
rf <- 0.05
rm <- 0.12
beta <- 1.5
r <- rf + beta * (rm - rf)
cashflows <- c(-1000, 500, 500, 500)
npv <- sum(cashflows / (1 + r)^(0:3))
npv
## [1] 132.213
r_stock <- 0.09
sigma_stock <- 0.15
r_gold <- 0.05
sigma_gold <- 0.10
rho <- 0.1
w <- 0.5
r_p <- w * r_stock + w * r_gold
sigma_p <- sqrt(
(w^2 * sigma_stock^2) +
(w^2 * sigma_gold^2) +
2 * w^2 * rho * sigma_stock * sigma_gold
)
r_p
## [1] 0.07
sigma_p
## [1] 0.09420722
sigma1 <- 0.10
sigma2 <- 0.15
rho <- -1
w1 <- sigma2 / (sigma1 + sigma2)
w2 <- 1 - w1
w1
## [1] 0.6
w2
## [1] 0.4
#Chapter 7 - CFA Problem 1
E_r <- 0.15
sigma <- 0.22
A1 <- 4
A2 <- 2
U1 <- E_r - 0.5 * A1 * sigma^2
U2 <- E_r - 0.5 * A2 * sigma^2
U1
## [1] 0.0532
U2
## [1] 0.1016
#Chapter 7 - CFA Problem 2
r_A <- 0.15
sigma_A <- 0.22
U_A <- r_A - 0.5 * 3 * sigma_A^2
r_B <- 0.13
sigma_B <- 0.20
U_B <- r_B - 0.5 * 3 * sigma_B^2
U_A
## [1] 0.0774
U_B
## [1] 0.07
#Chapter 7 - CFA Problem 3
U_X <- 0.122
U_Y <- 0.110
preferred <- ifelse(U_X > U_Y, "Investor X prefers their portfolio", "Investor Y prefers their portfolio")
preferred
## [1] "Investor X prefers their portfolio"
rf <- 0.08
rp <- 0.16
sigma_p <- 0.23
stocks <- data.frame(
stock = c("A", "B", "C", "D"),
exp_return = c(0.20, 0.18, 0.17, 0.12),
beta = c(1.3, 1.8, 0.7, 1.0),
residual_sd = c(0.58, 0.71, 0.60, 0.55)
)
stocks$alpha <- with(stocks, exp_return - (rf + beta * (rp - rf)))
stocks$resid_var <- stocks$residual_sd^2
stocks
## stock exp_return beta residual_sd alpha resid_var
## 1 A 0.20 1.3 0.58 0.016 0.3364
## 2 B 0.18 1.8 0.71 -0.044 0.5041
## 3 C 0.17 0.7 0.60 0.034 0.3600
## 4 D 0.12 1.0 0.55 -0.040 0.3025
#a.Compute Alpha and Residual Variance
stocks[, c("stock", "alpha", "resid_var")]
## stock alpha resid_var
## 1 A 0.016 0.3364
## 2 B -0.044 0.5041
## 3 C 0.034 0.3600
## 4 D -0.040 0.3025
#b.Construct Optimal Risky Portfolio (Trevynor-Black)
stocks$score <- stocks$alpha / stocks$resid_var
stocks$z_i <- with(stocks, alpha * score)
Z <- sum(stocks$z_i)
stocks$w_i <- stocks$z_i / Z
stocks[, c("stock", "alpha", "resid_var", "score", "w_i")]
## stock alpha resid_var score w_i
## 1 A 0.016 0.3364 0.04756243 0.0580832
## 2 B -0.044 0.5041 -0.08728427 0.2931266
## 3 C 0.034 0.3600 0.09444444 0.2450879
## 4 D -0.040 0.3025 -0.13223140 0.4037023
#c.Sharpe Ratio of Optimal Portfolio
stocks$systematic_var <- (stocks$beta^2) * (sigma_p^2)
var_active <- sum((stocks$w_i^2) * stocks$resid_var)
alpha_active <- sum(stocks$w_i * stocks$alpha)
sd_active <- sqrt(var_active)
sharpe_active <- alpha_active / sd_active
sharpe_passive <- (rp - rf) / sigma_p
sharpe_active
## [1] -0.05824341
sharpe_passive
## [1] 0.3478261
#d.Improvement in Sharpe Ratio
sharpe_combined <- sqrt(sharpe_passive^2 + sharpe_active^2)
sharpe_combined
## [1] 0.3526688
#e.Optimal Complete Portfolio (Risk Aversion = 2.8)
A <- 2.8
excess_combined <- sharpe_combined * sqrt(var_active + sigma_p^2)
y_opt <- excess_combined / (A * (var_active + sigma_p^2))
y_opt
## [1] 0.3070445
library(knitr)
regression_output <- data.frame(
Statistic = c("Alpha", "Beta", "R²", "Residual Std. Dev."),
ABC = c("-3.20%", "0.60", "0.35", "13.02%"),
XYZ = c("7.30%", "0.97", "0.17", "21.45%")
)
kable(regression_output, caption = "Regression Results for ABC and XYZ")
Statistic | ABC | XYZ |
---|---|---|
Alpha | -3.20% | 7.30% |
Beta | 0.60 | 0.97 |
R² | 0.35 | 0.17 |
Residual Std. Dev. | 13.02% | 21.45% |
brokerage_data <- data.frame(
`Brokerage House` = c("A", "B"),
`Beta of ABC` = c(0.62, 0.71),
`Beta of XYZ` = c(1.45, 1.25)
)
kable(brokerage_data, caption = "Recent Beta Estimates (2-Year Weekly Data)")
Brokerage.House | Beta.of.ABC | Beta.of.XYZ |
---|---|---|
A | 0.62 | 1.45 |
B | 0.71 | 1.25 |