Eq2Data: Equations to Multivariate Normal Sample Data

Description Usage Arguments Details Value Syntax Operations par.label Line breaks Comments Author(s) References See Also Examples

View source: R/Eq2Data.R

Description

Generates data from a multivariate normal distribution from model equations using the MASS::mvrnorm() function. The argument eq is a character string that specifies the associations between the variables. See Syntax, Operations, par.label, Line breaks, and Comments below.

Usage

1
Eq2Data(eq, n, check = TRUE, ...)

Arguments

eq

Character string. Equations. See Details.

n

Integer. Sample size.

check

Logical. If check = TRUE do some preprocessing with input matrices using CheckRAMMatrices().

...

...

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) .

Syntax

Each line should follow the syntax below

lhs <space> op <space> rhs <space> par.label <\n> or <;>

lhs

is the variable on the left-hand side,

rhs

is the variable on the right-hand side,

op

is the operation between lhs and rhs,

par.label

is the column of parameter label,

\n or ;

are line breaks. Each line should end with a line break.

Operations

The associations are defined by the following operations

by

left-hand side measured by right-hand side,

on

left-hand side regressed on right-hand side,

with

left-hand side covarying with right-hand side,

on 1

left-hand side regressed on 1 for mean structure.

par.label

Each parameter should have a numeric value.

Line breaks

The characters \n and ; can be used as line breaks. Each line should end with a line break.

Comments

Comments can be written after a hash (#) sign.

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: RAM2Data()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
eq <- "
  # lhs op   rhs value
    e   by   y   1
    y   on   x   1
    e   with e   1
    x   with x   0.25
    y   on   1   0
    x   on   1   0.50
"
Eq2Data(eq, n = 100)

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