checkRAM: Check the correctness of the RAM formulation

Description Usage Arguments Value Author(s) See Also Examples

View source: R/checkRAM.R

Description

It provides simple checks on the correctness of the RAM formulation.

Usage

1
checkRAM(Amatrix, Smatrix, cor.analysis=TRUE)

Arguments

Amatrix

An asymmetric matrix in the RAM specification with MxMatrix-class. If it is a matrix, it will be converted into MxMatrix-class by the as.mxMatrix function.

Smatrix

A symmetric matrix in the RAM specification with MxMatrix-class. If it is a matrix, it will be converted into MxMatrix-class by the as.mxMatrix function.

cor.analysis

Logical. Analysis of correlation or covariance structure. There are additional checks for cor.analysis=TRUE.

Value

It returns silently if no error has been detected; otherwise, it returns a warning message.

Author(s)

Mike W.-L. Cheung <mikewlcheung@nus.edu.sg>

See Also

as.mxMatrix, lavaan2RAM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run:  
## Digman97 example
model1 <- "## Factor loadings
           Alpha=~A+C+ES
           Beta=~E+I
           ## Factor correlation
           Alpha~~Beta"

RAM1 <- lavaan2RAM(model1, obs.variables=c("A","C","ES","E","I"),
                   A.notation="on", S.notation="with")
RAM1

## The model is okay.    
checkRAM(Amatrix=RAM1$A, Smatrix=RAM1$S)

## Hunter83 example    
model2 <- "## Regression paths
           Job_knowledge ~ A2J*Ability
           Work_sample ~ A2W*Ability + J2W*Job_knowledge
           Supervisor ~ J2S*Job_knowledge + W2S*Work_sample

           ## Fix the variance of Ability at 1
           Ability ~~ 1*Ability

           ## Label the error variances of the dependent variables
           Job_knowledge ~~ VarE_J*Job_knowledge
           Work_sample ~~ VarE_W*Work_sample
           Supervisor ~~ VarE_S*Supervisor"

RAM2 <- lavaan2RAM(model2, obs.variables=c("Ability","Job_knowledge",
                   "Work_sample","Supervisor"))

## The model is okay.     
checkRAM(Amatrix=RAM2$A, Smatrix=RAM2$S)   

## End(Not run)

Example output

Loading required package: OpenMx
To take full advantage of multiple cores, use:
  mxOption(NULL, 'Number of Threads', parallel::detectCores()) #now
  Sys.setenv(OMP_NUM_THREADS=parallel::detectCores()) #before library(OpenMx)
"SLSQP" is set as the default optimizer in OpenMx.
mxOption(NULL, "Gradient algorithm") is set at "central".
mxOption(NULL, "Optimality tolerance") is set at "6.3e-14".
mxOption(NULL, "Gradient iterations") is set at "2".
$A
      A   C   ES  E   I   Alpha         Beta       
A     "0" "0" "0" "0" "0" "0*AonAlpha"  "0"        
C     "0" "0" "0" "0" "0" "0*ConAlpha"  "0"        
ES    "0" "0" "0" "0" "0" "0*ESonAlpha" "0"        
E     "0" "0" "0" "0" "0" "0"           "0*EonBeta"
I     "0" "0" "0" "0" "0" "0"           "0*IonBeta"
Alpha "0" "0" "0" "0" "0" "0"           "0"        
Beta  "0" "0" "0" "0" "0" "0"           "0"        

$S
      A          C          ES           E          I         
A     "0*AwithA" "0"        "0"          "0"        "0"       
C     "0"        "0*CwithC" "0"          "0"        "0"       
ES    "0"        "0"        "0*ESwithES" "0"        "0"       
E     "0"        "0"        "0"          "0*EwithE" "0"       
I     "0"        "0"        "0"          "0"        "0*IwithI"
Alpha "0"        "0"        "0"          "0"        "0"       
Beta  "0"        "0"        "0"          "0"        "0"       
      Alpha             Beta             
A     "0"               "0"              
C     "0"               "0"              
ES    "0"               "0"              
E     "0"               "0"              
I     "0"               "0"              
Alpha "1"               "0*AlphawithBeta"
Beta  "0*AlphawithBeta" "1"              

$F
   A C ES E I Alpha Beta
A  1 0  0 0 0     0    0
C  0 1  0 0 0     0    0
ES 0 0  1 0 0     0    0
E  0 0  0 1 0     0    0
I  0 0  0 0 1     0    0

$M
  A C ES E I Alpha Beta
1 0 0  0 0 0     0    0

metaSEM documentation built on May 18, 2021, 1:06 a.m.