I am using R for volatility calibration (Variance Gamma distribution). My question is very basic and not at all related to mathematics!

    y=spline(KK,CallPrices,,"fmm",,,strikes)

When calling spline function it returns a list y

The list contains some numbers which I have to subtract from another array called "MarketPrices"

since y is a list a normal subtraction is not possible.

For example I get this output from spline function...

$x
 [1] 1050 1100 1150 1175 1200 1250 1300 1350 1400 1450 1500

$y
[1] 175.15474 146.78475 121.76502 110.50149 100.05049 81.49610 65.87413 52.89799 42.24847 33.59852 26.63327

I can chunk out...the second list...using modelprices[2]

> modelprices[2]
$y
[1] 175.15474 146.78475 121.76502 110.50149 100.05049 81.49610 65.87413 52.89799 42.24847 33.59852 26.63327

Still its a list and I think I need an array
other array is
> marketprices
 [1] 171.4 140.4 112.8  99.8  88.2  66.9  49.5  35.7  25.2  17.0  12.2
> marketprices-modelprices[2]
Error in marketprices - modelprices[2] :
  non-numeric argument to binary operator

Is there any way to perform this substraction?

I tried the normal approaches like
> as.numeric(modelprices[2])
Error: (list) object cannot be coerced to type 'double'

Thanks in advance!--

Regards,
Animesh Saxena

(www.quantanalysis.in)

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to