Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nlmixrHess

Calculate Hessian


Description

Unlike 'stats::optimHess' which assumes the gradient is accurate, nlmixrHess does not make as strong an assumption that the gradient is accurate but takes more function evaluations to calculate the Hessian. In addition, this procedures optimizes the forward difference interval by nlmixrGill83

Usage

nlmixrHess(par, fn, ..., envir = parent.frame())

Arguments

par

Initial values for the parameters to be optimized over.

fn

A function to be minimized (or maximized), with first argument the vector of parameters over which minimization is to take place. It should return a scalar result.

...

Extra arguments sent to nlmixrGill83

envir

an environment within which to evaluate the call. This will be most useful if what is a character string and the arguments are symbols or quoted expressions.

Details

If you have an analytical gradient function, you should use 'stats::optimHess'

Value

Hessian matrix based on Gill83

Author(s)

Matthew Fidler

References

See Also

Examples

func0 <- function(x){ sum(sin(x))  }
 x <- (0:10)*2*pi/10
 nlmixrHess(x, func0)

fr <- function(x) {   ## Rosenbrock Banana function
    x1 <- x[1]
    x2 <- x[2]
    100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
grr <- function(x) { ## Gradient of 'fr'
    x1 <- x[1]
    x2 <- x[2]
    c(-400 * x1 * (x2 - x1 * x1) - 2 * (1 - x1),
       200 *      (x2 - x1 * x1))
}

h1 <- optimHess(c(1.2,1.2), fr, grr)

h2 <- optimHess(c(1.2,1.2), fr)

## in this case h3 is closer to h1 where the gradient is known

h3 <- nlmixrHess(c(1.2,1.2), fr)

nlmixr

Nonlinear Mixed Effects Models in Population PK/PD

v2.0.4
GPL (>= 2)
Authors
Matthew Fidler [aut] (<https://orcid.org/0000-0001-8538-6691>), Yuan Xiong [aut], Rik Schoemaker [aut] (<https://orcid.org/0000-0002-7538-3005>), Justin Wilkins [aut] (<https://orcid.org/0000-0002-7099-9396>), Wenping Wang [aut, cre], Robert Leary [ctb], Mason McComb [aut] (<https://orcid.org/0000-0001-9871-8616>), Mirjam Trame [ctb], Teun Post [ctb], Richard Hooijmaijers [aut], Hadley Wickham [ctb], Dirk Eddelbuettel [cph], Johannes Pfeifer [ctb], Robert B. Schnabel [ctb], Elizabeth Eskow [ctb], Emmanuelle Comets [ctb], Audrey Lavenu [ctb], Marc Lavielle [ctb], David Ardia [cph], Daniel C. Dillon [ctb], Katharine Mullen [cph], Ben Goodrich [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.