hessian {LSTS} | R Documentation |
Hessian Matrix
Description
Numerical aproximation of the Hessian of a function.
Usage
hessian(f, x0, ...)
Arguments
f |
(type: numeric) name of function that defines log likelihood (or negative of it). |
x0 |
(type: numeric) scalar or vector of parameters that give the point at which you want the hessian estimated (usually will be the mle). |
... |
Additional arguments to be passed to the function. |
Details
Computes the numerical approximation of the Hessian of f
, evaluated at
x0
.
Usually needs to pass additional parameters (e.g. data). N.B. this uses no
numerical sophistication.
Value
An n \times n
matrix of 2nd derivatives, where n
is the length of
x0
.
See Also
Examples
# Variance of the maximum likelihood estimator for mu parameter in
# gaussian data
loglik <- function(series, x, sd = 1) {
-sum(log(dnorm(series, mean = x, sd = sd)))
}
sqrt(c(var(malleco) / length(malleco), diag(solve(hessian(
f = loglik, x = mean(malleco), series = malleco,
sd = sd(malleco)
)))))
[Package LSTS version 2.1 Index]