Description Usage Arguments Details Value Author(s) Examples
mre
handles the evaluation of multivariate random effects with two
behaviours. It evaluates the multivariate effects applied to the factor x
if size == NULL
and it simulates the replicated factor x
if
size
is provided.
1 |
x |
A replicated covariate factor of length nq to evaluate the
multivariate effects. It is a q times replicated vector of x*. If
|
sigma |
A qxq covariance matrix S for the random effects. |
groups |
A character vector of length k to name the |
size |
A numeric value n representing the number of units, it is used to
simulate the covariate |
replace |
An logical value provided to the function |
Considering x* the n-length factor under study with k levels and X the associated nxk design matrix with dummy variables corresponding to each level of the factor, the returning multivariate effect is
vec(XU),
where U is a kxq matrix of random effects and vec(.) represents a vectorization by columns of the provided matrix. Each row u_i of U is assumed to come from a zero-mean normal distribution with covariance matrix S of dimension qxq,
A simulated replicated factor x in case size
is provided;
otherwise, a nq-length numeric vector of the evaluated multivariate
effects.
Erick A. Chacón-Montalván
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Multivariate random effects for 10 units belonging to 3 groups.
Sigma <- matrix(c(1, 0.8, 0.5, 0.8, 1, 0.5, 0.5, 0.5, 1), nrow = 3)
(x <- mre(groups = 3, sigma = Sigma, size = 10))
(effect <- mre(x, sigma = Sigma))
# Multivariate independent random effects for 10 units.
Sigma <- matrix(c(1, 0.8, 0.5, 0.8, 1, 0.5, 0.5, 0.5, 1), nrow = 3)
(x <- mre(groups = 10, sigma = Sigma, size = 10, replace = FALSE))
(effect <- mre(x, sigma = Sigma))
# Multivariate random effects for 500 units belonging to 100 groups.
Sigma <- matrix(c(1, 0.8, 0.5, 0.8, 1, 0.5, 0.5, 0.5, 1), nrow = 3)
(x <- mre(groups = 100, sigma = Sigma, size = 500))
(effect <- mre(x, sigma = Sigma))
# Check empirical covariance matrix of the random effects.
cov(unique(matrix(effect, ncol = nrow(Sigma))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.