I have the following Dataframe:
AVG_VOLUME AVG_RETURN VOL PRICE
SPX Index 500000 0.01 0.08 2082
KR7000270009 6000 0.02 0.09 102
KR7005930003 7000 0.02 0.08 103
JP3266400005 8000 0.03 0.08 104
KYG875721634 9000 0.04 0.08 105
JP3900000005 10 0.05 0.08 106
I'm trying to apply the GBM function of the sde package using the data in each row of the DataFrame:
GBM(x=1, r=0, sigma=1, T=1, N=100)
Arguments
x initial value of the process at time t0.
r the interest rate of the GBM.
sigma the volatility of the GBM.
T final time.
N number of intervals in which to split [t0,T]
I tried to use apply but I think I'm wrong somewhere:
Test <- apply(Stock_Info,1,function(x) {
GBM(x[,"PRICE"],x[,"AVG_RETURN"],x[,"VOL"],1,252)
})
What is the correct way to apply apply in this case? Or any other way to apply this function in the columns highlighted above on all rows?