Skip to contents

Calculates the Hessian of the log-likelihood function at the MLEs using either the fdHess function in the nlme package or the optim function. This is a utility function in the MARSS-package and is not exported. Use MARSShessian to access.

Usage

MARSShessian.numerical(MLEobj, fun=c("fdHess", "optim"))

Arguments

MLEobj

An object of class marssMLE. This object must have a $par element containing MLE parameter estimates from e.g. MARSSkem.

fun

The function to use for computing the Hessian. Options are 'fdHess' or 'optim'.

Details

Method fdHess uses fdHess from package nlme to numerically estimate the Hessian matrix (the matrix of partial 2nd derivatives) of the negative log-likelihood function with respect to the parameters. Method optim uses optim with hessian=TRUE and list(maxit=0) to ensure that the Hessian is computed at the values in the par element of the MLE object.

Value

The numerically estimated Hessian of the log-likelihood function at the maximum likelihood estimates.

Author

Eli Holmes, NOAA, Seattle, USA.

Examples

dat <- t(harborSeal)
dat <- dat[c(2, 11), ]
MLEobj <- MARSS(dat)
#> Success! abstol and log-log tests passed at 26 iterations.
#> Alert: conv.test.slope.tol is 0.5.
#> Test with smaller values (<0.1) to ensure convergence.
#> 
#> MARSS fit is
#> Estimation method: kem 
#> Convergence test: conv.test.slope.tol = 0.5, abstol = 0.001
#> Estimation converged in 26 iterations. 
#> Log-likelihood: 11.74016 
#> AIC: -9.480311   AICc: -6.3692   
#>  
#>                                           Estimate
#> R.diag                                      0.0115
#> U.X.CoastalEstuaries                        0.0613
#> U.X.OR.NorthCoast                           0.0510
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries)   0.0147
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)         0.0122
#> x0.X.CoastalEstuaries                       7.3823
#> x0.X.OR.NorthCoast                          6.2707
#> Initial states (x0) defined at t=0
#> 
#> Standard errors have not been calculated. 
#> Use MARSSparamCIs to compute CIs and bias estimates.
#> 
MARSS:::MARSShessian.numerical(MLEobj)
#>                                                R.diag U.X.CoastalEstuaries
#> R.diag                                    53973.87564        -1.799395e+02
#> U.X.CoastalEstuaries                       -179.93953         1.661814e+03
#> U.X.OR.NorthCoast                           183.70930         4.645478e-02
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries) 11923.37817         1.433252e+02
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)       13830.82687         6.482860e-02
#> x0.X.CoastalEstuaries                       -72.27758         6.810709e+01
#> x0.X.OR.NorthCoast                          -15.82861         1.259299e-04
#>                                           U.X.OR.NorthCoast
#> R.diag                                         1.837093e+02
#> U.X.CoastalEstuaries                           4.645478e-02
#> U.X.OR.NorthCoast                              2.332091e+03
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries)      1.940915e-01
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)           -1.760963e+02
#> x0.X.CoastalEstuaries                          5.147224e-04
#> x0.X.OR.NorthCoast                             8.209757e+01
#>                                           Q.(X.CoastalEstuaries,X.CoastalEstuaries)
#> R.diag                                                                 1.192338e+04
#> U.X.CoastalEstuaries                                                   1.433252e+02
#> U.X.OR.NorthCoast                                                      1.940915e-01
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries)                              1.697670e+04
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)                                    2.708586e-01
#> x0.X.CoastalEstuaries                                                  5.658628e+01
#> x0.X.OR.NorthCoast                                                     5.261445e-04
#>                                           Q.(X.OR.NorthCoast,X.OR.NorthCoast)
#> R.diag                                                           1.383083e+04
#> U.X.CoastalEstuaries                                             6.482860e-02
#> U.X.OR.NorthCoast                                               -1.760963e+02
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries)                        2.708586e-01
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)                              2.223240e+04
#> x0.X.CoastalEstuaries                                            1.077459e-03
#> x0.X.OR.NorthCoast                                               2.368783e+01
#>                                           x0.X.CoastalEstuaries
#> R.diag                                            -7.227758e+01
#> U.X.CoastalEstuaries                               6.810709e+01
#> U.X.OR.NorthCoast                                  5.147224e-04
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries)          5.658628e+01
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)                1.077459e-03
#> x0.X.CoastalEstuaries                              4.492212e+01
#> x0.X.OR.NorthCoast                                 2.092970e-06
#>                                           x0.X.OR.NorthCoast
#> R.diag                                         -1.582861e+01
#> U.X.CoastalEstuaries                            1.259299e-04
#> U.X.OR.NorthCoast                               8.209757e+01
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries)       5.261445e-04
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)             2.368783e+01
#> x0.X.CoastalEstuaries                           2.092970e-06
#> x0.X.OR.NorthCoast                              2.156558e+01