I have 5000 simulated matrices, please see the code below, I would like to take the average of generated 5000 matrices Call(i,j) to get the matrix Call of size MxP. Please advise. Many thanks
Code: Select all
OPEN DATA "C: \ Desktop\ R1newset.xls"
DATA(FORMAT=xls,ORG = Col) / R1
OPEN DATA "C: \ Desktop\ Data_T1.xls"
DATA(FORMAT=xls,ORG=COL) 1 10964 S T1 div r2 T2 K
com M = 61, P=10964
dec rec T3 ST Call Rtstr
dim T3(M,P) Rtstr(M,P) ST(M,P) Call(M,P)
do rep = 1, 5000
.......
* replicate 5000 returns
........
boot entries 1 61 1 65360
set draw 1 61 = R1(entries)
ewise T3(i,j) = T2(j)-T1(i)
ewise Rtstr(i,j) = (r2(i)-div(i)+draw(i))*T3(i,j)/365
ewise ST(i,j) = %if(T3(i,j)>0, S(i)*exp(Rtstr(i,j)),%na)
ewise Call(i,j) = %if(T3(i,j)>0,exp(-r2(i)*T3(i,j)/365)*%max(0,ST(i,j)-K(j)),%na)
end do rep