Last data update: 2014.03.03

R: Calculate Two-Sided Hessian for the Generalized Inverse...
gigHessianR Documentation

Calculate Two-Sided Hessian for the Generalized Inverse Gaussian Distribution

Description

Calculates the Hessian of a function, either exactly or approximately. Used to obtaining the information matrix for maximum likelihood estimation.

Usage

gigHessian(x, param, hessianMethod = c("tsHessian", "exact"),
           whichParam = 1)

Arguments

x

Data vector.

param

The maximum likelihood estimates parameter vector of the generalized inverse Gaussian distribution. There are five different sets of parameterazations can be used in this function, the first four sets are listed in gigChangePars and the last set is the log scale of the first set of the parameterization, i.e., mu,log(delta),Pi,log(zeta).

hessianMethod

Only the approximate method ("tsHessian") has actually been implemented so far.

whichParam

Numeric. A number between indicating which parameterization the argument param relates to. Only parameterization 1 is available so far.

Details

The approximate Hessian is obtained via a call to tsHessian from the package DistributionUtils. summary.gigFit calls the function gigHessian to calculate the Hessian matrix when the argument hessian = TRUE.

Value

gigHessian gives the approximate Hessian matrix for the data vector x and the estimated parameter vector param.

Author(s)

David Scott d.scott@auckland.ac.nz, David Cusack

Examples

### Calculate the approximate Hessian using gigHessian:
param <- c(1,1,1)
dataVector <- rgig(500, param = param)
fit <- gigFit(dataVector)
coef <- coef(fit)
gigHessian(x = dataVector, param = coef, hessianMethod = "tsHessian",
              whichParam = 1)

### Or calculate the approximate Hessian using summary.gigFit method:
summary(fit, hessian = TRUE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(GeneralizedHyperbolic)
Loading required package: DistributionUtils
Loading required package: RUnit
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GeneralizedHyperbolic/gigHessian.Rd_%03d_medium.png", width=480, height=480)
> ### Name: gigHessian
> ### Title: Calculate Two-Sided Hessian for the Generalized Inverse Gaussian
> ###   Distribution
> ### Aliases: gigHessian
> 
> ### ** Examples
> 
> ### Calculate the approximate Hessian using gigHessian:
> param <- c(1,1,1)
> dataVector <- rgig(500, param = param)
> fit <- gigFit(dataVector)
> coef <- coef(fit)
> gigHessian(x = dataVector, param = coef, hessianMethod = "tsHessian",
+               whichParam = 1)
           chi        psi    lambda
[1,] -162.5720   363.9220 -184.9427
[2,]  363.9220 -1564.1836  315.0629
[3,] -184.9427   315.0629 -141.3789
> 
> ### Or calculate the approximate Hessian using summary.gigFit method:
> summary(fit, hessian = TRUE)

Data:      dataVector 
Hessian:  tsHessian exact 
           chi        psi    lambda
[1,] -162.5720   363.9220 -184.9427
[2,]  363.9220 -1564.1836  315.0629
[3,] -184.9427   315.0629 -141.3789
Parameter estimates:
      chi        psi      lambda 
   1.15183    1.03991    1.03413 
  (    NaN)  (0.03349)  (    NaN)
Likelihood:         -569.6427 
Method:             Nelder-Mead 
Convergence code:   0 
Iterations:         234 
Warning messages:
1: In if (hessianMethod == "exact") { :
  the condition has length > 1 and only the first element will be used
2: In if (hessianMethod == "tsHessian") { :
  the condition has length > 1 and only the first element will be used
3: In sqrt(diag(varcov)) : NaNs produced
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>