create.vechsR: Create a model implied correlation matrix with implicit...

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/osmasem.R

Description

It creates implicit diagonal constraints on the model implied correlation matrix by treating the error variances as functions of other parameters.

Usage

1
create.vechsR(A0, S0, F0 = NULL, Ax = NULL, Sx = NULL)

Arguments

A0

A Amatrix, which will be converted into MxMatrix-class via as.mxMatrix.

S0

A Smatrix, which will be converted into MxMatrix-class via as.mxMatrix.

F0

A Fmatrix, which will be converted into MxMatrix-class via as.mxMatrix.

Ax

A Amatrix of a list of Amatrix with definition variables as the moderators of the Amatrix.

Sx

A Smatrix of a list of Smatrix with definition variables as the moderators of the Smatrix.

Value

A list of MxMatrix-class. The model implied correlation matrix is computed in impliedR and vechsR.

Note

Since A0 are the intercepts and Ax are the regression coefficients. The parameters in Ax must be a subset of those in A0.

Author(s)

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

See Also

osmasem, create.Tau2, create.V

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: 
## Proposed model
model1 <- 'W2 ~ w2w*W1 + s2w*S1
           S2 ~ w2s*W1 + s2s*S1
           W1 ~~ w1WITHs1*S1
           W2 ~~ w2WITHs2*S2
           W1 ~~ 1*W1
           S1 ~~ 1*S1
           W2 ~~ Errw2*W2
           S2 ~~ Errs2*S2'

## Convert into RAM    
RAM1 <- lavaan2RAM(model1, obs.variables=c("W1", "S1", "W2", "S2"))

## No moderator    
M0 <- create.vechsR(A0=RAM1$A, S0=RAM1$S, F0=NULL, Ax=NULL, Sx=NULL)

## Lag (definition variable) as a moderator on the paths in the Amatrix    
Ax <- matrix(c(0,0,0,0,
               0,0,0,0,
               "0*data.Lag","0*data.Lag",0,0,
               "0*data.Lag","0*data.Lag",0,0),
             nrow=4, ncol=4, byrow=TRUE)
                
M1 <- create.vechsR(A0=RAM1$A, S0=RAM1$S, F0=NULL, Ax=Ax, Sx=NULL)    

## Lag (definition variable) as a moderator on the correlation in the Smatrix
Sx <- matrix(c(0,"0*data.Lag",0,0,
               "0*data.Lag",0,0,0,
               0,0,0,"0*data.Lag",
               0,0,"0*data.Lag",0),
             nrow=4, ncol=4, byrow=TRUE)

M2 <- create.vechsR(A0=RAM1$A, S0=RAM1$S, F0=NULL, Ax=NULL, Sx=Sx)

## End(Not run)

Example output

Loading required package: OpenMx
sh: 1: wc: Permission denied
To take full advantage of multiple cores, use:
  mxOption(key='Number of Threads', value=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".

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