rf <- 0.05
rp <- 0.08
sigma_p <- 0.20 

w_bills <- c(0, 0.2, 0.4, 0.6, 0.8, 1.0)
w_index <- 1 - w_bills
  1. Expected return of portfolios
E_Rp <- w_bills * rf + w_index * (rf + rp)
E_Rp
## [1] 0.130 0.114 0.098 0.082 0.066 0.050

Variance of portfolios

Var_Rp <- (w_index^2) * (sigma_p^2)
Var_Rp
## [1] 0.0400 0.0256 0.0144 0.0064 0.0016 0.0000
  1. Utility levels of portfolios with A=2
A1 <- 2  
Utility_l2 <- E_Rp - 0.5 * A1 * Var_Rp
Utility_l2
## [1] 0.0900 0.0884 0.0836 0.0756 0.0644 0.0500

With A=2, the utility score is the highest when the portfolio consists of all risky asset

  1. Utility levels of portfolios with A=3
A2 <- 3 
Utility_l3 <- E_Rp - 0.5 * A2 * Var_Rp
Utility_l3
## [1] 0.0700 0.0756 0.0764 0.0724 0.0636 0.0500

With A=3, the ulitity score is the highest when the portfolio is diversified, with the weights of the risk-free and risky assets being 0.4 and 0.6