hessian: Hessian Matrix

Description Usage Arguments Details Value See Also Examples

View source: R/hessian.R

Description

Numerical aproximation of the Hessian of a function.

Usage

1
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

arima.sim

Examples

1
2
3
4
5
6
7
8
9
# 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)
)))))

LSTS documentation built on July 29, 2021, 5:07 p.m.

Related to hessian in LSTS...