0

I have to simulate 1000 random paths for the next 10 days of a stock's value. Here is my code, but it doesn't work:

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
}
Till Helge
  • 9,253
  • 2
  • 40
  • 56
  • 2
    Hi. Welcome to StackOverflow. As you can see, I tried to make your question a little bit more clear. However, you haven't really explained what about your code isn't working as intended. Please go back to your question, [edit](http://stackoverflow.com/posts/33084805/edit) it and make sure you add everything that we need to know to help you. – Till Helge Oct 12 '15 at 15:48
  • Also, your code wont work as written. You haven't defined `C`, `mu`, `s0`, or `s` in your example, so those lines will give errors. – alexwhitworth Oct 12 '15 at 15:53
  • you may also be interested in `install.packages("mvtnorm")` – alexwhitworth Oct 12 '15 at 15:54

0 Answers0