I'm writing a method for the class "function" in R
fct.function <- function(x, start, tolerance = 1e-7, niter = 500)
This method needs a numerical approximatimation of the derivative of the function x. For this I want to use numericDev. Now
abl1 <- numericDeriv(quote(x),theta="lambda")
doesn't work because R cannot coerce the type 'closure' to a vector of type 'double'. Do you have any idea to fix that?
Here is some code:
# R version 3.3.1 on Windows 10
fct.function <- function(x, start=0, tolerance = 1e-7, niter = 500){
abl1 <- numericDeriv(quote(x),theta="lambda") # supposing that the function x is a function of lambda
abl2 <- numericDeriv(quote(abl1),theta="lambda")
}
For example this leads to an error:
x<-function(lambda) lambda^2
fct(x)
Thank you!