corLevDiag: Correlation or Covariance Matrix for a Diagonal Structure

Description Usage Arguments Value Examples

View source: R/q1Diag.R

Description

Compute the correlation or covariance matrix for a diagonal structure.

Usage

1
2
corLevDiag(par, nlevels, levels, lowerSQRT = FALSE, compGrad = TRUE,
  cov = 0)

Arguments

par

A numeric vector with length npVar where npVar is the number of variance parameters, namely 0, 1 or nlevels corresponding to the values of cov: 0, 1 and 2.

nlevels

Number of levels.

levels

Character representing the levels.

lowerSQRT

Logical. When TRUE the (lower) Cholesky root L of the correlation or covariance matrix C is returned instead of the correlation matrix.

compGrad

Logical. Should the gradient be computed?

cov

Integer 0, 1 or 2. If cov is 0, the matrix is a correlation matrix (or its Cholesky root) i.e. an identity matrix. If cov is 1 or 2, the matrix is a covariance (or its square root) with constant variance vector for code = 1 and with arbitrary variance vector for code = 2.

Value

A correlation matrix (or its Cholesky root) with the optional gradient attribute.

Examples

1
2
3
4
5
6
7
set.seed(123)
checkGrad <- TRUE
nlevels <- 12
sigma2 <- rexp(n = nlevels)
T0 <- corLevDiag(nlevels = nlevels, par = sigma2, cov = 2)
L0 <- corLevDiag(nlevels = nlevels, par = sigma2, cov = 2,
                 lowerSQRT = TRUE)

kergp documentation built on March 18, 2021, 5:06 p.m.