# ── Given Information ──────────────────────────────────────────────
r_bills  <- 0.05
r_index  <- 0.05 + 0.08   # 13%
sd_index <- 0.20

# ── Problem 10: Expected Return & Variance ─────────────────────────
w_bills <- c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0)
w_index <- 1 - w_bills

E_rp  <- w_bills * r_bills + w_index * r_index
var_p <- (w_index * sd_index)^2
sd_p  <- sqrt(var_p)

prob10 <- data.frame(
  W_bills  = w_bills,
  W_index  = w_index,
  E_return = round(E_rp,  4),
  Variance = round(var_p, 4),
  Std_Dev  = round(sd_p,  4)
)

cat("=== Problem 10: Expected Return & Variance ===\n")
## === Problem 10: Expected Return & Variance ===
print(prob10)
##   W_bills W_index E_return Variance Std_Dev
## 1     0.0     1.0    0.130   0.0400    0.20
## 2     0.2     0.8    0.114   0.0256    0.16
## 3     0.4     0.6    0.098   0.0144    0.12
## 4     0.6     0.4    0.082   0.0064    0.08
## 5     0.8     0.2    0.066   0.0016    0.04
## 6     1.0     0.0    0.050   0.0000    0.00
# ── Problem 11: Utility with A = 2 ────────────────────────────────
A2   <- 2
U_A2 <- E_rp - 0.5 * A2 * var_p

prob11 <- data.frame(
  W_bills  = w_bills,
  W_index  = w_index,
  E_return = round(E_rp,  4),
  Variance = round(var_p, 4),
  Utility  = round(U_A2,  4)
)

cat("\n=== Problem 11: Utility with A = 2 ===\n")
## 
## === Problem 11: Utility with A = 2 ===
print(prob11)
##   W_bills W_index E_return Variance Utility
## 1     0.0     1.0    0.130   0.0400  0.0900
## 2     0.2     0.8    0.114   0.0256  0.0884
## 3     0.4     0.6    0.098   0.0144  0.0836
## 4     0.6     0.4    0.082   0.0064  0.0756
## 5     0.8     0.2    0.066   0.0016  0.0644
## 6     1.0     0.0    0.050   0.0000  0.0500
cat("Best portfolio (A=2): W_bills =", w_bills[which.max(U_A2)],
    "| W_index =", w_index[which.max(U_A2)],
    "| Utility =", round(max(U_A2), 4), "\n")
## Best portfolio (A=2): W_bills = 0 | W_index = 1 | Utility = 0.09
# ── Problem 12: Utility with A = 3 ────────────────────────────────
A3   <- 3
U_A3 <- E_rp - 0.5 * A3 * var_p

prob12 <- data.frame(
  W_bills  = w_bills,
  W_index  = w_index,
  E_return = round(E_rp,  4),
  Variance = round(var_p, 4),
  Utility  = round(U_A3,  4)
)

cat("\n=== Problem 12: Utility with A = 3 ===\n")
## 
## === Problem 12: Utility with A = 3 ===
print(prob12)
##   W_bills W_index E_return Variance Utility
## 1     0.0     1.0    0.130   0.0400  0.0700
## 2     0.2     0.8    0.114   0.0256  0.0756
## 3     0.4     0.6    0.098   0.0144  0.0764
## 4     0.6     0.4    0.082   0.0064  0.0724
## 5     0.8     0.2    0.066   0.0016  0.0636
## 6     1.0     0.0    0.050   0.0000  0.0500
cat("Best portfolio (A=3): W_bills =", w_bills[which.max(U_A3)],
    "| W_index =", w_index[which.max(U_A3)],
    "| Utility =", round(max(U_A3), 4), "\n")
## Best portfolio (A=3): W_bills = 0.4 | W_index = 0.6 | Utility = 0.0764
# ── CFA Problems 1-3 ──────────────────────────────────────────────
Er  <- c(0.12, 0.15, 0.21, 0.24)
sd  <- c(0.30, 0.50, 0.16, 0.21)
A4  <- 4

U_cfa <- Er - 0.5 * A4 * sd^2

cfa <- data.frame(
  Investment = 1:4,
  E_return   = Er,
  Std_Dev    = sd,
  Variance   = round(sd^2, 4),
  Utility    = round(U_cfa, 4)
)

cat("\n=== CFA Problem 1: Utility with A = 4 ===\n")
## 
## === CFA Problem 1: Utility with A = 4 ===
print(cfa)
##   Investment E_return Std_Dev Variance Utility
## 1          1     0.12    0.30   0.0900 -0.0600
## 2          2     0.15    0.50   0.2500 -0.3500
## 3          3     0.21    0.16   0.0256  0.1588
## 4          4     0.24    0.21   0.0441  0.1518
cat("Best investment (A=4): Investment", which.max(U_cfa),
    "| Utility =", round(max(U_cfa), 4), "\n")
## Best investment (A=4): Investment 3 | Utility = 0.1588
cat("\n=== CFA Problem 2: Risk Neutral (A = 0) ===\n")
## 
## === CFA Problem 2: Risk Neutral (A = 0) ===
cat("Risk neutral investor ignores variance — picks highest E(r)\n")
## Risk neutral investor ignores variance — picks highest E(r)
cat("Best investment: Investment", which.max(Er),
    "| E(r) =", max(Er), "\n")
## Best investment: Investment 4 | E(r) = 0.24
cat("\n=== CFA Problem 3 ===\n")
## 
## === CFA Problem 3 ===
cat("Answer: (b) Investor's aversion to risk\n")
## Answer: (b) Investor's aversion to risk
cat("A measures how much an investor penalises utility for taking on variance.\n")
## A measures how much an investor penalises utility for taking on variance.