rRxNorm {mniw} | R 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 |
V |
Observation variances. Either a matrix of size |
lambda |
Prior means. Either a vector of length |
Sigma |
Prior variances. Either a matrix of size |
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")
.
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)