Displaying 1 result from an estimated 1 matches for "shole".
Did you mean:
whole
2008 Nov 18
2
error in function: nls (urgent)
...)/(v*sqrt(t))
s*pnorm(d1)-x*pnorm(d2)
}
res<-nls(p~bs(s,x,t,a0,a1,a2),data=data,start=list(a0=-100,a1=100,a2=-100))
It returns the error:
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
By the way, bs function actually based on the Black-sholes option pricing
model. There is a specific function in Rmetrics, can I call the function in
Rmetrics package? Something like this:
bs<-function(s,x,t,a0,a1,a2,...){
v=exp(a0+a1*(x/s)+a2*(x/s)^2)
GBSOption(TypeFlag=c("c"),S=s,X=x,Time=t,r=0,b=0,sigma=v)@price
}
When I use this one,...