problem with nls....
On Fri, 22 Mar 2019 12:29:14 +0000
akshay kulkarni <akshay_e4 at hotmail.com> wrote:
How do I get the gradient, Hessian, and the jacobian of the objective function created by call to the nls?
nls() return value is a list containing an entry named `m`, which is an object of type "nlsModel". It doesn't seem to be documented in modern versions of R[*], so what I am describing might be an implementation detail subject to change. Still, model$m$gradient() should return the jacobian; Hessian is usually estimated as crossprod() of jacobian; and the gradient of the objective function is computed as -2*colSums(model$m$resid() * model$m$gradient()).
Also, I've checked the residuals...they are approximately normally distributed....I am still wondering why the nls call is not getting converged....!
The more important question is, how does the objective function (sum of
squared residuals) depend on the parameter `m` you are trying to find?
Try computing it for various values of `m` and looking at the result:
plot(
Vectorize(
function(m) {
model$m$setPars(m);
model$m$deviance()
}
),
from = ..., to = ... # fill as needed
)
Best regards, Ivan [*] But used to be: http://unixlab.stat.ubc.ca/R/library/stats/html/nlsModel.html