rRxNorm: 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
$$
\begin{array}{rcl}
\boldsymbol{\mu} & \sim & \mathcal{N}(\boldsymbol{\lambda}, \boldsymbol{\Sigma}) \\
\boldsymbol{x} \mid \boldsymbol{\mu} & \sim & \mathcal{N}(\boldsymbol{\mu}, \boldsymbol{V}).
\end{array}
$$
The Multivariate-Normal Random-Effects model \(\boldsymbol{\mu} \sim \textrm{RxNorm}(\boldsymbol{x}, \boldsymbol{V}, \boldsymbol{\lambda}, \boldsymbol{\Sigma})\) on the random vector \(\boldsymbol{\mu}_q\) is defined as the posterior distribution \(p(\boldsymbol{\mu} \mid \boldsymbol{x}, \boldsymbol{\lambda}, \boldsymbol{\Sigma})\). This distribution is multivariate normal; for the mathematical specification of its parameters please see vignette("mniw-distributions", package = "mniw").
# data specificationq <- 5
y <- rnorm(q)
V <- rwish(1, diag(q), q+1)
# prior specificationlambda <- rep(0,q)
A <- diag(q)
n <- 10
# random samplingrRxNorm(n, y, V, lambda, A)