Description Usage Arguments Value Examples
Compute covariance matrix using onion method
1 2 | onion_chol(tau, pi, rho, z, scale = 1/sqrt(2), dispersion = 1,
as.vec = FALSE)
|
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. |
matrix
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.