#Courtesy of Shizhen Wang, PGTA for BCPM0021" setwd("/Users/..../Desktop") sp500 <- read.csv("SP500.csv") mean(sp500$SP500) sd(sp500$SP500) return_simulated<-rnorm(10000, mean=mean(sp500$SP500), sd=sd(sp500$SP500)) hist(return_simulated) quantile(return_simulated,0.01) quantile(return_simulated,0.03) quantile(return_simulated,0.05) sp500$var01 <- quantile(return_simulated,0.01) sp500$var03 <- quantile(return_simulated,0.03) sp500$var05 <- quantile(return_simulated,0.05) plot(sp500$SP500,type = "l") lines(sp500$var01,col="red") lines(sp500$var03,col="yellow") lines(sp500$var05,col="blue")