我必须为股票价值的下一个10天模拟1000个随机路径。这是我的代码,但它不起作用:
for(i in 1:90) { # simulate price for future 90 days
z<-rnorm(3) # generate normal random vector
v<-mu+t(C)%*%z # transform to multivariate normal
s1<-s0*(1+v) # new stock price
s<-rbind(s,t(s1)) # append s1 to s
s0<-s1 # update s0
}