# ==========================================
# Problems 10, 11, and 12
# ==========================================

# 1. Define Market Parameters
rf <- 0.05          # Current T-bill rate
risk_premium <- 0.08 # S&P 500 premium over T-bills
e_rm <- rf + risk_premium # Expected return of S&P 500 (13%)
sigma_m <- 0.20     # S&P 500 standard deviation

# 2. Define Weights
w_bills <- c(0, 0.2, 0.4, 0.6, 0.8, 1.0)
w_index <- c(1.0, 0.8, 0.6, 0.4, 0.2, 0)
# --- Problem 10: Expected Return and Variance ---
e_rp <- (w_bills * rf) + (w_index * e_rm)
var_rp <- (w_index * sigma_m)^2

prob10_results <- data.frame(
  W_bills = w_bills, 
  W_index = w_index,
  Expected_Return = e_rp, 
  Variance = var_rp
)

cat("\n--- Problem 10: Expected Return & Variance ---\n")
## 
## --- Problem 10: Expected Return & Variance ---
print(prob10_results)
##   W_bills W_index Expected_Return Variance
## 1     0.0     1.0           0.130   0.0400
## 2     0.2     0.8           0.114   0.0256
## 3     0.4     0.6           0.098   0.0144
## 4     0.6     0.4           0.082   0.0064
## 5     0.8     0.2           0.066   0.0016
## 6     1.0     0.0           0.050   0.0000
# --- Problem 11: Utility for A = 2 ---
A_11 <- 2
utility_11 <- e_rp - 0.5 * A_11 * var_rp
prob11_results <- cbind(prob10_results, Utility_A2 = utility_11)

cat("\n--- Problem 11: Utility Levels (A = 2) ---\n")
## 
## --- Problem 11: Utility Levels (A = 2) ---
print(prob11_results)
##   W_bills W_index Expected_Return Variance Utility_A2
## 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("\nConclusion: Max utility achieved with W_index = 1.0\n")
## 
## Conclusion: Max utility achieved with W_index = 1.0
# --- Problem 12: Utility for A = 3 ---
A_12 <- 3
utility_12 <- e_rp - 0.5 * A_12 * var_rp
prob12_results <- cbind(prob10_results, Utility_A3 = utility_12)

cat("\n--- Problem 12: Utility Levels (A = 3) ---\n")
## 
## --- Problem 12: Utility Levels (A = 3) ---
print(prob12_results)
##   W_bills W_index Expected_Return Variance Utility_A3
## 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("\nConclusion: Max utility achieved with W_index = 0.6, W_bills = 0.4\n")
## 
## Conclusion: Max utility achieved with W_index = 0.6, W_bills = 0.4
# ==========================================
# CFA Problems 1, 2, and 3
# ==========================================

# 1. Define CFA Investment Data
cfa_data <- data.frame(
  Investment = 1:4,
  Expected_Return = c(0.12, 0.15, 0.21, 0.24),
  Standard_Deviation = c(0.30, 0.50, 0.16, 0.21)
)
cfa_data$Variance <- cfa_data$Standard_Deviation^2
# --- CFA Problem 1: Risk Averse (A = 4) ---
A_cfa <- 4
cfa_data$Utility_A4 <- cfa_data$Expected_Return - 0.5 * A_cfa * cfa_data$Variance
cat("\n--- CFA Problem 1: Utility Levels (A = 4) ---\n")
## 
## --- CFA Problem 1: Utility Levels (A = 4) ---
print(cfa_data)
##   Investment Expected_Return Standard_Deviation Variance Utility_A4
## 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("\nAnswer: Select Investment 3 (Highest Utility: ", max(cfa_data$Utility_A4), ")\n")
## 
## Answer: Select Investment 3 (Highest Utility:  0.1588 )
# --- CFA Problem 2: Risk Neutral ---
cat("\n--- CFA Problem 2: Risk Neutral (A = 0) ---\n")
## 
## --- CFA Problem 2: Risk Neutral (A = 0) ---
cat("Answer: A risk-neutral investor maximizes expected return. Select Investment 4 (E(r) = 0.24).\n")
## Answer: A risk-neutral investor maximizes expected return. Select Investment 4 (E(r) = 0.24).
# --- CFA Problem 3: Variable (A) ---
cat("\n--- CFA Problem 3: Meaning of Variable (A) ---\n")
## 
## --- CFA Problem 3: Meaning of Variable (A) ---
cat("Answer: b. Investor's aversion to risk.\n")
## Answer: b. Investor's aversion to risk.