Chapter 5 cfa 1

# Define the probabilities and expected returns
prob_equities <- 0.6
prob_t_bills <- 0.4

return_equities <- 50000
return_t_bills <- 5000

# Calculate the expected return for each action
expected_return_equities <- prob_equities * return_equities
expected_return_t_bills <- prob_t_bills * return_t_bills

# Calculate the expected risk premium
expected_risk_premium <- expected_return_equities - expected_return_t_bills

# Print the expected risk premium
cat("Expected risk premium of investing in equities versus risk-free T-bills:", expected_risk_premium, "dollars")
## Expected risk premium of investing in equities versus risk-free T-bills: 28000 dollars

Chapter6 problem 10

# Define the weights for T-bills and the S&P 500 index
weights <- matrix(data = c(0, 1.0,
                            0.2, 0.8,
                            0.4, 0.6,
                            0.6, 0.4,
                            0.8, 0.2,
                            1.0, 0), ncol = 2, byrow = TRUE)

# Define the expected returns and variances of T-bills and the S&P 500 index
expected_return_tbills <- 0.05  # Assume 5% return for T-bills
expected_return_index <- 0.1    # Assume 10% return for S&P 500 index
variance_tbills <- 0            # T-bills are risk-free, so variance is 0
variance_index <- 0.04          # Assume 4% variance for S&P 500 index

# Calculate the expected return and variance of each portfolio
portfolio_returns <- weights[,1] * expected_return_tbills + weights[,2] * expected_return_index
portfolio_variances <- (weights[,1]^2) * variance_tbills + (weights[,2]^2) * variance_index

# Print the results
cat("Weights \t Expected Return \t Variance\n")
## Weights   Expected Return     Variance
for (i in 1:nrow(weights)) {
  cat(weights[i, 1], "\t", weights[i, 2], "\t\t", portfolio_returns[i], "\t\t", portfolio_variances[i], "\n")
}
## 0     1       0.1         0.04 
## 0.2   0.8         0.09        0.0256 
## 0.4   0.6         0.08        0.0144 
## 0.6   0.4         0.07        0.0064 
## 0.8   0.2         0.06        0.0016 
## 1     0       0.05        0

Chapter6 problem 11

# Define the risk aversion parameter
A <- 2

# Calculate the wealths for each portfolio (using the expected returns from Problem 10)
wealths <- portfolio_returns

# Calculate the utility levels for each portfolio
utility_levels <- wealths^(1 - A) / (1 - A)

# Print the results
cat("Portfolio \t Utility Level\n")
## Portfolio     Utility Level
for (i in 1:length(utility_levels)) {
  cat(i, "\t\t", utility_levels[i], "\n")
}
## 1         -10 
## 2         -11.11111 
## 3         -12.5 
## 4         -14.28571 
## 5         -16.66667 
## 6         -20

Chapter6 problem 12

# Define the risk aversion parameter
A <- 3

# Define the expected return and standard deviation of the risky portfolio and T-bill rate
expected_return_risky <- 0.18  # 18%
std_dev_risky <- 0.28          # 28%
t_bill_rate <- 0.08            # 8%

# Calculate the expected return and standard deviation of the risky portfolio and T-bill
# We need these to compute the expected return and variance of portfolios in Problem 10
expected_return <- c(expected_return_risky, t_bill_rate)
variance <- c(std_dev_risky^2, 0)  # T-bills have zero variance

# Calculate the expected return and variance of each portfolio from Problem 10
portfolio_returns <- weights[,1] * expected_return[1] + weights[,2] * expected_return[2]
portfolio_variances <- (weights[,1]^2) * variance[1] + (weights[,2]^2) * variance[2]

# Calculate the wealths for each portfolio (using the expected returns from Problem 10)
wealths <- portfolio_returns

# Calculate the utility levels for each portfolio
utility_levels <- wealths^(1 - A) / (1 - A)

# Print the results
cat("Portfolio \t Utility Level\n")
## Portfolio     Utility Level
for (i in 1:length(utility_levels)) {
  cat(i, "\t\t", utility_levels[i], "\n")
}
## 1         -78.125 
## 2         -50 
## 3         -34.72222 
## 4         -25.5102 
## 5         -19.53125 
## 6         -15.4321

Chapter 6 CFA 1-3

# Define the expected returns and standard deviations for each investment
investments <- c("Investment 1", "Investment 2", "Investment 3", "Investment 4")
expected_returns <- c(0.12, 0.15, 0.21, 0.24)
standard_deviations <- c(0.30, 0.50, 0.16, 0.21)

# Define the risk aversion parameter
A_risk_averse <- 4
A_risk_neutral <- 1  # Risk neutral when A = 1

# Calculate the wealths for each investment (using the expected returns)
wealths <- expected_returns

# Calculate the utility levels for each investment
utility_levels_risk_averse <- wealths^(1 - A_risk_averse) / (1 - A_risk_averse)
utility_levels_risk_neutral <- log(wealths)  # For risk-neutral investors, utility is the natural log of wealth

# Print the utility levels
cat("Investment \t Utility Level (Risk Averse) \t Utility Level (Risk Neutral)\n")
## Investment    Utility Level (Risk Averse)     Utility Level (Risk Neutral)
for (i in 1:length(investments)) {
  cat(investments[i], "\t", utility_levels_risk_averse[i], "\t", utility_levels_risk_neutral[i], "\n")
}
## Investment 1      -192.9012   -2.120264 
## Investment 2      -98.76543   -1.89712 
## Investment 3      -35.99323   -1.560648 
## Investment 4      -24.11265   -1.427116
# Find the investment with the highest utility level for the risk-averse investor
highest_utility_risk_averse <- investments[which.max(utility_levels_risk_averse)]
cat("\nInvestment selected for risk-averse investor (A = 4):", highest_utility_risk_averse, "\n")
## 
## Investment selected for risk-averse investor (A = 4): Investment 4
# Find the investment with the highest utility level for the risk-neutral investor
highest_utility_risk_neutral <- investments[which.max(utility_levels_risk_neutral)]
cat("Investment selected for risk-neutral investor (A = 1):", highest_utility_risk_neutral, "\n")
## Investment selected for risk-neutral investor (A = 1): Investment 4