library(ggplot2)

Chapter 6 – Problem 10

Given: - Expected return of S&P 500 = 9% - T-bill rate = 4% - S&P 500 standard deviation = 20%

Portfolio Weights

w_index <- c(1.0, 0.8, 0.6, 0.4, 0.2, 0.0)
w_rf <- 1 - w_index

rf <- 0.04
rm <- 0.09
sigma_m <- 0.20

# Expected return
E_r <- w_rf * rf + w_index * rm

# Standard deviation
sigma <- w_index * sigma_m

df <- data.frame(w_rf, w_index, E_r, sigma)
df
##   w_rf w_index  E_r sigma
## 1  0.0     1.0 0.09  0.20
## 2  0.2     0.8 0.08  0.16
## 3  0.4     0.6 0.07  0.12
## 4  0.6     0.4 0.06  0.08
## 5  0.8     0.2 0.05  0.04
## 6  1.0     0.0 0.04  0.00

Visualization: Risk vs Return

ggplot(df, aes(x = sigma, y = E_r)) +
  geom_point(size = 3) +
  geom_line() +
  labs(title = "Risk-Return Tradeoff",
       x = "Risk (Standard Deviation)",
       y = "Expected Return")


Chapter 6 – Problem 11 (A = 2)

Utility formula:

U = E(r) - (1/2) * A * σ^2

A <- 2
df$U <- df$E_r - 0.5 * A * df$sigma^2
df
##   w_rf w_index  E_r sigma      U
## 1  0.0     1.0 0.09  0.20 0.0500
## 2  0.2     0.8 0.08  0.16 0.0544
## 3  0.4     0.6 0.07  0.12 0.0556
## 4  0.6     0.4 0.06  0.08 0.0536
## 5  0.8     0.2 0.05  0.04 0.0484
## 6  1.0     0.0 0.04  0.00 0.0400

Visualization: Utility vs Portfolio Weight

ggplot(df, aes(x = w_index, y = U)) +
  geom_point(size = 3) +
  geom_line() +
  labs(title = "Utility vs Stock Weight (A=2)",
       x = "Weight in Risky Asset",
       y = "Utility")


Chapter 6 – Problem 12 (A = 3)

A <- 3
df$U2 <- df$E_r - 0.5 * A * df$sigma^2
df
##   w_rf w_index  E_r sigma      U     U2
## 1  0.0     1.0 0.09  0.20 0.0500 0.0300
## 2  0.2     0.8 0.08  0.16 0.0544 0.0416
## 3  0.4     0.6 0.07  0.12 0.0556 0.0484
## 4  0.6     0.4 0.06  0.08 0.0536 0.0504
## 5  0.8     0.2 0.05  0.04 0.0484 0.0476
## 6  1.0     0.0 0.04  0.00 0.0400 0.0400

Visualization: Higher Risk Aversion

ggplot(df, aes(x = w_index, y = U2)) +
  geom_point(size = 3) +
  geom_line() +
  labs(title = "Utility vs Stock Weight (A=3)",
       x = "Weight in Risky Asset",
       y = "Utility")


CFA Problem 1–3

Data

E_r <- c(0.12, 0.15, 0.21, 0.24)
sigma <- c(0.30, 0.50, 0.16, 0.21)
A <- 4

U <- E_r - 0.5 * A * sigma^2

df2 <- data.frame(Portfolio = factor(1:4), E_r, sigma, U)
df2
##   Portfolio  E_r sigma       U
## 1         1 0.12  0.30 -0.0600
## 2         2 0.15  0.50 -0.3500
## 3         3 0.21  0.16  0.1588
## 4         4 0.24  0.21  0.1518

Visualization: Portfolio Comparison

ggplot(df2, aes(x = Portfolio, y = U)) +
  geom_bar(stat = "identity") +
  labs(title = "Utility Comparison Across Portfolios",
       x = "Portfolio",
       y = "Utility")


Final Summary