[R] Problem with nls function

roberto marrone robertomarrone at hotmail.it
Mon Nov 16 15:19:11 CET 2015


Dear all,

I have a problem using the R finction nls. I am trying to perform an optimisation of the volatility parameter in the Black and Scholes formula. In the function nls I wrote as a formula the  call option price with the only unknown parameter the volatility that I called theta.  The code is the following and I have recevied some errors, one is that below. In my code I use as data a dataset of simuleted option price of length 99, and the same I did for subset.  I would like to have a code that compare my model with the volatility as an unknown parameter with a set of gien option data. Thanks in advance.



optim<- nls(call ~ S*pnorm((log(15/14)+(0.015+theta^2/2)*0.17)/(theta*sqrt(0.17))) - 14*exp(-0.015*0-17)*pnorm((log(15/14)+(0.015+theta^2/2)*0.17)/(theta*sqrt(0.17)) - theta * sqrt(0.17)), data=data, start= 0.01, control= nls.control(maxiter = 50, tol = 1e-05, minFactor = 1/1024,                        printEval = FALSE, warnOnly = FALSE),  subset= "data1")


Error in nls(call ~ S * pnorm((log(15/14) + (0.015 + theta^2/2) * 0.17)/(theta *  :
  parameters without starting value in 'data': theta


	[[alternative HTML version deleted]]



More information about the R-help mailing list