onion_chol: Compute covariance matrix using onion method

Description Usage Arguments Value Examples

View source: R/stats.R

Description

Compute covariance matrix using onion method

Usage

1
2
onion_chol(tau, pi, rho, z, scale = 1/sqrt(2), dispersion = 1,
  as.vec = FALSE)

Arguments

tau

square root of the covariance matrix trace

pi

positive valued vector. Conjugate to dirichlet distribution.

rho

correlation magnitudes (radiuses, as a 0-1 range vector, or R^2)

z

correlation angles and further scale adjustments (vector in range of -Inf, Inf)

scale

scale the value of tau. Defaults to 1/sqrt(2), which would make the trace = tau^2 * (k/2) if dispersion is also 1. If scale=1, and all pi are equal, then trace = tau^2 * k

dispersion

dispersion of standard deviations' errors (for overdispersed models). Set to 1 by default to indicate no overdispersion.

as.vec

return vector (column order) instead of a matrix, omitting zeros from upper triangle.

Value

matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
p <- 4
chol_cov <- onion_chol(
tau = rgamma(1, shape = 1.1, scale = 1.1),
pi = rgamma(p, shape = 2, scale = 1),
rho = rbeta(p - 1, 1, 1.67),
z = rnorm(choose(p, 2) - 1))

cov_mat <- tcrossprod(chol_cov)

s <- 1 / (sqrt(2))
chol_cov <- onion_chol(
tau = 5,
pi = c(1, 1, 1, 1),
rho = c(0, 0.5, 0.5),
z = c(-s, s, -s, s, 0),
scale = 1)

S <- tcrossprod(chol_cov)
Rho <- cov2cor(S)

iamamutt/mejr documentation built on May 18, 2019, 1:27 a.m.