Part F

Graph \(E(\pi)\) as a function of the interest rate for interest rates between 0 and 5 (0% to 500%).

library(ggplot2)
p <- function(x){
  return(ifelse(x>=0 & x <=1, -45+80*x,
      ifelse(x>=1 & x <= 2, -65+60*x,
      ifelse(x >= 2 & x<=5, 0, 0))))}
ggplot(data.frame(x=c(0, 5)), aes(x=x)) + 
  geom_path(aes(colour="darkblue"), stat="function", fun=p) +
  labs(x="i", y="Expected Returns") +
  ggtitle("Figure 5") +
  scale_colour_identity("Function", guide="legend", 
                        labels = c("E(pi)")) +
  theme(legend.text=element_text(size = 8.5)) +
  theme(plot.title=element_text(size=10, face="bold")) +
  theme(axis.title.x=element_text(face="italic", size=9.5)) +
  theme(axis.title.y=element_text(size=9.5))