Create asset paths in R using GBM and Monte Carlo I would like to create asset paths using Geometric BM and Monte carlo simulation for a Basket option.
I have the correlation matrix, the covariance matrix. I used Cholesky on correlation matrix and then I multiplied it with a vector of random numbers to create correlated random numbers. My issue is that when I try to put them into my equation, my paths are only decreasing. Could you please help me?
$i$ for number of simulations
$j$ for number of assets
$r_n$ is a matrix with random numbers
correl is the cholesky (from correlation matrix)
trial_par$sigma[1,1] is the covariance matrix
dt=1/365 are the steps
asset1[1,1]=price of the asset now
for (i in 1:5){
  for (a in 2:(n+1)){
    for (b in 1:3){
      rn[a,b]=rnorm(1,0,sqrt(dt))}}
  crn=rn%*%correl
  for (j in 2:366){
    asset1[i,j]=asset1[i,j-1]*exp((r-0.5*trial_par$sigma[1,1])*dt+\sqrt{trial_par$sigma[1,1])*crn[j,1]*sqrt(dt)}
asset2[i,j]=asset2[i,j-1]*exp((r-0.5*trial_par$sigma[2,2])*dt+$\sqrt{trial_par sigma[2,2]}$*crn[j,2]*sqrt(dt))
    asset3[i,j]=asset3[i,j-1]*exp((r-0.5*trial_par$sigma[3,3])*dt+sqrt(trial_par$sigma[3,3])*crn[j,3]*sqrt(dt))
  }}
 A: Hello and thank you for replying.
I would like to create asset paths using Geometric BM and Monte carlo simulation for a Basket option.
I have the correlation matrix, the covariance matrix. I used Cholesky on correlation matrix and then I multiplied it with a vector of random numbers to create correlated random numbers. My issue is that when I try to put them into my equation, my paths are only decreasing. Could you please help me?
$i$ for number of simulations
$j$ for steps(j=2 is the first price after today)
$r_n$ is a matrix with random numbers
correl is the cholesky (from correlation matrix)
trial_par$sigma[1,1] is the covariance matrix
dt=1/365 are the steps
asset1[1,1]=price of the asset now
crn the matrix with correlated random numbers
edit:I changed the j-it was a mistake
My intention is the following:
I would like to use cholesky(not sure if I have to use cholesky on covariance matrix or correlation matrix), and multiply it with uncorrelated numbers to produce correlated random numbers(it will happen i times, each for every simulation).
The code is the following:
for (i in 1:5){
for (a in 2:(n+1)){
for (b in 1:3){
  rn[a,b]=rnorm(1,0,sqrt(dt))}}

crn=rn%*%correl
for (j in 2:366){
asset1[i,j]=asset1[i,j-1]*exp((r-0.5*trial_par$sigma[1,1])*dt+sqrt(trial_par$sigma[1,1])*crn[j,1]*sqrt(dt))


asset2[i,j]=asset2[i,j-1]*exp((r-0.5*trial_par$sigma[2,2])*dt+sqrt(trial_par$sigma[2,2])*crn[j,2]*sqrt(dt))


asset3[i,j]=asset3[i,j-1]*exp((r-0.5*trial_par$sigma[3,3])*dt+sqrt(trial_par$sigma[3,3])*crn[j,3]*sqrt(dt))

}}
