P = data.frame(stock=c('A', 'B', 'C'), beta=c(1.10, 0.8, 1.0), sd_of_error=c(0.07, 0.023, 0.01), weight=c(.2, .5, .3)) print(P) r_M = 0.12 s_M = 0.18 r_f = 0.05 r_p = r_f + sum(P$weight * P$beta) * ( r_M - r_f ) print(r_p) ## Part (b): ## pb = sum(P$weight * P$beta) ve2 = sum( P$weight^2 * P$sd_of_error^2 ) print(sqrt(ve2)) vp = pb^2 * s_M^2 + ve2 print(c(vp, sqrt(vp)))