rRxNorm: Conditional sampling for Multivariate-Normal Random-Effects...

View source: R/RandomEffects.R

rRxNormR Documentation

Conditional sampling for Multivariate-Normal Random-Effects model.

Description

Sample from the conditional parameter distribution given the data and hyperparameters of the Multivariate-Normal Random-Effects (mNormRE) model (see Details).

Usage

rRxNorm(n, x, V, lambda, Sigma)

Arguments

n

Integer number of random samples to generate.

x

Data observations. Either a vector of length q or a n x q matrix. In the latter case each row is a different vector.

V

Observation variances. Either a matrix of size q x q or a q x q x n array.

lambda

Prior means. Either a vector of length q or an n x q matrix. In the latter case each row is a different mean. Defaults to zeros.

Sigma

Prior variances. Either a matrix of size q x q or a q x q x n array. Defaults to identity matrix.

Details

Consider the hierarchical multivariate normal model

μ ~ N(λ, Σ) x | μ ~ N(μ, V).

The Multivariate-Normal Random-Effects model μ ~ RxNorm(x, V, λ, Σ) on the random vector μ_q is defined as the posterior distribution p(μ | x, λ, Σ). This distribution is multivariate normal; for the mathematical specification of its parameters please see vignette("mniw-distributions", package = "mniw").

Examples

# data specification
q <- 5
y <- rnorm(q)
V <- rwish(1, diag(q), q+1)
# prior specification
lambda <- rep(0,q)
A <- diag(q)
n <- 10
# random sampling
rRxNorm(n, y, V, lambda, A)

mniw documentation built on Aug. 22, 2022, 5:05 p.m.