RAM2Data: Generate Data from a Multivariate Normal Distribution Using...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/RAM2Data.R

Description

Generates data from a multivariate normal distribution using the Reticular Action Model (RAM) notation with the MASS::mvrnorm() function.

Usage

1
RAM2Data(n, A, S, u, Filter, ...)

Arguments

n

Integer. Sample size.

A

t by t matrix \mathbf{A}. Asymmetric paths (single-headed arrows), such as regression coefficients and factor loadings.

S

t by t numeric matrix \mathbf{S}. Symmetric paths (double-headed arrows), such as variances and covariances.

u

vector of length t or t by 1 matrix. Mean structure parameters.

Filter

p by t numeric matrix \mathbf{F}. Filter matrix used to select observed variables.

...

Additional arguments to pass to MASS::mvrnorm().

Details

The multivariate normal distribution is given by

\mathbf{X} \sim \mathcal{N}_{k} ≤ft( \boldsymbol{μ}, \boldsymbol{Σ} \right)

with location parameter

\boldsymbol{μ} \in \mathbf{R}^{k}

and a positive definite covariance matrix

\boldsymbol{Σ} \in \mathbf{R}^{k \times k} .

The probability density function is given by

f_{\mathbf{X}} ≤ft( x_1, \cdots, x_k \right) = \frac{ \exp ≤ft[ - \frac{1}{2} ≤ft( \mathbf{x} - \boldsymbol{μ} \right)^{\mathsf{T}} \boldsymbol{Σ}^{-1} ≤ft( \mathbf{x} - \boldsymbol{μ} \right) \right] }{ √{ ≤ft( 2 π \right)^k | \boldsymbol{Σ} | } }

In this function, the model-implied mean vector and variance-covariance matrix are used as parameters to generate the data.

\boldsymbol{μ} ≤ft( \boldsymbol{θ} \right) = \mathbf{g} = \mathbf{F} ≤ft( \mathbf{I} - \mathbf{A} \right)^{\mathsf{T}} \mathbf{u} = \mathbf{F} \mathbf{E} \mathbf{u}

\boldsymbol{Σ} ≤ft( \boldsymbol{θ} \right) = \mathbf{M} = \mathbf{F} ≤ft( \mathbf{I} - \mathbf{A} \right)^{-1} \mathbf{S} ≤ft[ ≤ft( \mathbf{I} - \mathbf{A} \right)^{-1} \right]^{\mathsf{T}} \mathbf{F}^{\mathsf{T}} \\ = \mathbf{F} \mathbf{E} \mathbf{S} \mathbf{E}^{\mathsf{T}} \mathbf{F}^{\mathsf{T}} \\ = \mathbf{F} \mathbf{C} \mathbf{F}^{\mathsf{T}}

Value

n variates from \mathbf{X} \sim \mathcal{N}_{k} ≤ft( \boldsymbol{μ} ≤ft( \boldsymbol{θ} \right), \boldsymbol{Σ} ≤ft( \boldsymbol{θ} \right) \right) .

Author(s)

Ivan Jacob Agaloos Pesigan

References

McArdle, J. J., & McDonald, R. P. (1984). Some algebraic properties of the Reticular Action Model for moment structures. British Journal of Mathematical and Statistical Psychology, 37 (2), 234–251. https://doi.org/10.1111/j.2044-8317.1984.tb00802.x

See Also

Other data generation functions: Eq2Data()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# This is an example for the model
# y = alpha + beta * x + e
# y = 0 + 1 * x + e

n <- 50
A <- S <- matrixR::ZeroMatrix(3)
A[1, ] <- c(0, 1, 1)
diag(S) <- c(0, 0.25, 1)
u <- c(0.00, 0.50, 0.00)
Filter <- diag(2)
Filter <- cbind(Filter, 0)
colnames(Filter) <- c("y", "x", "e")
rownames(Filter) <- c("y", "x")
RAM2Data(n, A, S, u, Filter)

jeksterslab/ramR documentation built on March 14, 2021, 9:38 a.m.