ihess {SMPracticals}R Documentation

Inverse Hessian

Description

Inverse Hessian matrix, useful for obtaining standard errors

Usage

ihess(f, x, ep = 1e-04, ...)

Arguments

f

Usually a negative log likelihood

x

Usually maximum likelihood estimates for f

ep

Step length used to compute numerical second derivatives

...

Extra arguments for f, if any

Value

Matrix of dimension dim(x) times dim(x), containing inverse Hessian matrix of f at x.

Note

This is not needed in R, where hessian matrices are obtained by setting hessian=T in calls to optimisation functions.

Author(s)

Anthony Davison

References

Based on code written by Stuart Coles of Padova University

Examples

# ML fit of t distribution
nlogL <- function(x, data) # negative log likelihood
{ mu <- x[1]
  sig <- x[2]
  df <- x[3]
  -sum(log( dt((data-mu)/sig, df=df)/sig )) }
y <- rt(n=100, df=10) # generate t data
# this is Splus code.....so remove the #'s for it to work in R
# fit <- nlminb(c(1,1,4), nlogL, upper=c(Inf,Inf,Inf), lower=c(-Inf,0,0),
#               data=y)
# fit$parameters # maximum likelihood estimates
# J <- ihess(nlogL, fit$parameters, data=y)
#  sqrt(diag(J)) # standard errors based on observed information
# 
# In this example the standard error can be a bad measure of
# uncertainty for the df.

[Package SMPracticals version 1.4-3.1 Index]