Learn R Programming

DistributionUtils (version 0.6-1)

tsHessian: Calculate Two-Sided Hessian Approximation

Description

Calculates an approximation to the Hessian of a function. Used for obtaining an approximation to the information matrix for maximum likelihood estimation.

Usage

tsHessian(param, fun, ...)

Value

The approximate Hessian matrix of the function fun where differentiation is with respect to the vector of parameters

param at the point given by the vector param.

Arguments

param

Numeric. The Hessian is to be evaluated at this point.

fun

A function of the parameters specified by param, and possibly other parameters.

...

Values of other parameters of the function fun if required.

Author

David Scott d.scott@auckland.ac.nz, Christine Yang Dong c.dong@auckland.ac.nz

Details

As a typical statistical application, the function fun is the log-likelihood function, param specifies the maximum likelihood estimates of the parameters of the distribution, and the data constitutes the other parameter values required for determination of the log-likelihood function.

See Also

hyperbHessian and summary.hyperbFit in GeneralizedHyperbolic.

Examples

Run this code
### Consider Hessian of log(1 + x + 2y)
### Example from Lang: A Second Course in Calculus, p.74
fun <- function(param){
  x <- param[1]
  y <- param[2]
  return(log(1 + x + 2*y))
}

### True value of Hessian at (0,0)
trueHessian <- matrix( c(-1,-2,
                         -2,-4), byrow = 2, nrow = 2)
trueHessian

### Value from tsHessian
approxHessian <- tsHessian(c(0,0), fun = fun)
approxHessian
maxDiff <- max(abs(trueHessian - approxHessian))
### Should be approximately 0.045
maxDiff

Run the code above in your browser using DataLab