Snorm.hess: Hessian of the loglikelihood of a multivariate normal with...

Description Usage Arguments Value Examples

View source: R/Snorm-hess.R

Description

Superfast evaluation of loglikelihood Hessian.

Usage

1
Snorm.hess(X, mu, acf, dmu, dacf, d2mu, d2acf)

Arguments

X

A length-N vector of multivariate normal observations.

mu

A scalar or length-N vector of means. If missing defaults to the vector of zeros.

acf

A Toeplitz object or length-N vector containing the first column of the Toeplitz variance matrix.

dmu

A length-p vector or N x p matrix of partial derivatives of mu along the columns. If missing defaults to a matrix of zeros.

dacf

An N x p matrix with the partial derivatives of acf along the columns.

d2mu

A p x p matrix or N x p x p array of second partial derivatives of mu. If missing defaults to zeros.

d2acf

A N x p x p array of second partial derivatives of acf.

Value

The p x p Hessian matrix of the loglikelihood.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# two parameter inference
acf.fun <- function(theta) theta[2]^2 * exp(-(1:N-1))
mu.fun <- function(theta) theta[1] * (1:N) + log(theta[2] + 1:N)

# partial derivatives
dacf.fun <- function(theta) {
  cbind(0, 2*theta[2] * exp(-(1:N-1)))
}
dmu.fun <- function(theta) cbind(1:N, 1/(theta[2] + 1:N))

# 2nd order partials
d2acf.fun <- function(theta) {
  H <- array(0, dim = c(N, 2, 2))
  H[,2,2] <- 2*exp(-(1:N-1))
  H
}
d2mu.fun <- function(theta) {
  H <- array(0, dim = c(N, 2, 2))
  H[,2,2] <- -1/(theta[2] + 1:N)^2
  H
}

# generate data
N <- 300
theta <- rexp(2)
X <- rSnorm(n = 1, acf = acf.fun(theta)) + mu.fun(theta)

# likelihood Hessian
Snorm.hess(X = X, mu = mu.fun(theta), acf = acf.fun(theta),
           dmu = dmu.fun(theta), dacf = dacf.fun(theta),
           d2mu = d2mu.fun(theta), d2acf = d2acf.fun(theta))

Example output

            [,1]       [,2]
[1,] -33163206.8 -27915.299
[2,]    -27915.3  -5079.058

SuperGauss documentation built on May 1, 2019, 7:58 p.m.