Snorm.grad: Gradient of the loglikelihood of a multivariate normal with...

Description Usage Arguments Value Examples

View source: R/Snorm-grad.R

Description

Superfast evaluation of loglikelihood gradient.

Usage

1
Snorm.grad(X, mu, acf, dmu, dacf)

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.

Value

A length-p vector containing the gradient of the loglikelihood.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# two parameter inference
acf.fun <- function(theta) theta[2]^2 * exp(-theta[1]*(1:N-1))
mu.fun <- function(theta) theta[1]

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

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

# likelihood gradient
Snorm.grad(X = X, mu = mu.fun(theta), dmu = dmu.fun(theta),
           acf = acf.fun(theta), dacf = dacf.fun(theta))

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