Error message: object of type 'closure' is not subsettable
Newbie wrote:
Dear R-users
I need to calibrate kappa, rho, eta, theta, v0 in the following code, see
below. However when I run it, I get:
y <- function(kappahat, rhohat, etahat, thetahat, v0hat)
{sum(difference(k, t, S0, X, r, implvol, q, kappahat, rhohat, etahat,
thetahat, v0hat)^2)}
nlminb(start=list(kappa, rho, eta, theta, v0), objective = y, lower =lb, upper =ub)
Error in dots[[1L]][[1L]] : object of type 'closure' is not subsettable
And I don't know what this mean and what I am doing wrong. Can anyone help
me?
Here is my code and data set.
Best
Rikke
..............
y <- function(kappahat, rhohat, etahat, thetahat, v0hat)
{sum(difference(k, t, S0, X, r, implvol, q, kappahat, rhohat, etahat,
thetahat, v0hat)^2)}
nlminb(start=list(kappa, rho, eta, theta, v0), objective = y, lower =lb,
upper =ub)
You haven't given all your data. Spot csv is missing.
You are using nlminb incorrectly.
It expects the objective function to take a numeric vector as argument as
clearly stated in the documentation.
Which should have been clear after your first post.
This would possibly help (NOT tested because of lack of data)
y <- function(par) {kappahat<-par[1]; rhohat<-par[2]; etahat<-par[3];
thetahat<-par[4]; v0hat<-par[5]; sum(difference(k, t, S0, X, r, implvol, q,
kappahat, rhohat, etahat, thetahat, v0hat)^2)}
nlminb(start=c(kappa, rho, eta, theta, v0), objective = y, lower =lb, upper
=ub)
Berend
--
View this message in context: http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-not-subsettable-tp3752886p3754511.html
Sent from the R help mailing list archive at Nabble.com.