Eq2RAM: Equations to RAM Matrices

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

View source: R/Eq2RAM.R

Description

Converts model equations to RAM matrices.

Usage

1
Eq2RAM(eq, par = FALSE)

Arguments

eq

Character string. Equations. See Details.

par

Logical. If par = TRUE, use par.index as labels. If par = FALSE, use par.label as labels.

Details

The argument eq is a character string that specifies the associations between the variables. See Syntax, Operations, par.label, Line breaks, and Comments below.

Value

Returns a list with the following elements

par.table

Parameter table.

variables

Variable names.

g.variables

Variable names of observed variables.

h.variables

Variable names of latent variables.

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

t by 1 matrix \mathbf{u} of mean structure parameters.

Filter

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

par.tables in the list is a data.frame with the following columns

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,

par.start

is the column of starting values for estimation if eq has a fifth colulmn, and

par.names

is the column of parameter label with NAs on fixed parameters,

par.type

is the type of the parameter,

RAM

is the RAM matrix used to represent the parameter,

RAM.row

is the row index in the RAM matrix for the parameter, and

RAM.col

is the column index in the RAM matrix for the parameter.

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 be labeled. The par.label should be a number for fixed parameters and a character string for free parameters. Equality contraints can be imposed by using the same par.label.

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 eq functions: Eq2Expectations(), EqParse()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Numeric ----------------------------------------------------------
eq <- "
  # lhs op   rhs par.label
    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
"
Eq2RAM(eq)

# Symbolic ----------------------------------------------------------
eq <- "
  # lhs op   rhs par.label
    e   by   y   1
    y   on   x   beta
    e   with e   sigmae2
    x   with x   sigmax2
    y   on   1   alpha
    x   on   1   mux
"
Eq2RAM(eq)

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