I'm using the CRRBinomialTreeOption function (in package "fOptions") with a
loop for pricing a large number of options. But I can't transfer the values
obtained from this function to a "numeric" matrix as the outcome of this
function is not a simple numeric.
The following is the piece of code:
# USING THE FUNCTION
library(fOptions)
option.price<-matrix(nrow=250,ncol=9)
for(j in 1:9){for(i in 1:250)
{option.price[i,j]=CRRBinomialTreeOption(TypeFlag="ca",S=data[(i+250),j],X=data[j,19],Time=T[i,j],r=data[i
,(9+j)],b=0,sigma=sig[i,j],n=5)}}
R output:
Error in option.price[i, j] = CRRBinomialTreeOption(TypeFlag = "ca", S =
data[(i + :
object of type 'S4' is not subsettable
I'm very new to R and can't find a solution with my knowledge at this
moment. Plz help.