ihess: Inverse Hessian

Description Usage Arguments Value Note Author(s) References Examples

Description

Inverse Hessian matrix, useful for obtaining standard errors

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# 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.

SMPracticals documentation built on May 2, 2019, 11:12 a.m.