Learn R Programming

metaSEM (version 2.0)

wls: Conduct a Correlation/Covariance Structure Analysis with WLS

Description

Variable names in the matrices, RAM model, and subset.variables, and ordinary parameter labels, must not contain periods. Rename them consistently, e.g., x.1 to x_1, and check for duplicate names.

It fits a correlation or covariance structure with weighted least squares (WLS) estimation method where the inverse of the asymptotic covariance matrix is used as the weight matrix. tssem2 conducts the second stage analysis of the two-stage structural equation modeling (TSSEM). tssem2 is a wrapper of wls. WLS summaries use the supplied sample size n as the RMSEA denominator; see summary for the formula.

Usage

wls(
  Cov,
  aCov,
  n,
  RAM = NULL,
  Amatrix = NULL,
  Smatrix = NULL,
  Fmatrix = NULL,
  diag.constraints = FALSE,
  cor.analysis = TRUE,
  intervals.type = c("z", "LB"),
  mx.algebras = NULL,
  mxModel.Args = NULL,
  subset.variables = NULL,
  model.name = NULL,
  suppressWarnings = TRUE,
  silent = TRUE,
  run = TRUE,
  ...
)

tssem2( tssem1.obj, RAM = NULL, Amatrix = NULL, Smatrix = NULL, Fmatrix = NULL, diag.constraints = FALSE, intervals.type = c("z", "LB"), mx.algebras = NULL, mxModel.Args = NULL, subset.variables = NULL, model.name = NULL, suppressWarnings = TRUE, silent = TRUE, run = TRUE, ... )

Value

An object of class wls with a list of

call

The matched call

Cov

Input data of either a covariance or correlation matrix

asyCov

The asymptotic covariance matrix of the input data

noObservedStat

Number of observed statistics

n

Sample size

cor.analysis

logical

noConstraints

Number of constraints imposed on S

indepModelChisq

Chi-square statistic of the independent model returned by .indepwlsChisq

indepModelDf

Degrees of freedom of the independent model returned by .indepwlsChisq

mx.fit

A fitted object returned from mxRun

Arguments

Cov

A \(p\) x \(p\) sample correlation/covariance matrix where \(p\) is the number of variables.

aCov

A \(p*\) x \(p*\) asymptotic sampling covariance matrix of either vechs (Cov) or vech (Cov) where \(p* = p(p-1)/2 \) for correlation matrix and \(p* = p(p+1)/2 \) for covariance matrix. When both dimensions have recognizable, unique labels, they are aligned to Cov before subsetting; reversed pair names are accepted when they uniquely identify a pair. Partially matching labels are rejected; wholly different labels produce a warning and use position. Unnamed matrices use position.

n

Sample size.

RAM

A RAM object including a list of matrices of the model returned from lavaan2RAM. When the observed variable names in RAM and Cov match, RAM is reordered to match Cov. If both have names that do not match, positional matching is retained with a warning. Unnamed inputs are matched by position. The number of observed variables must match the matrix dimension. Separately supplied named Fmatrix rows are also aligned to Cov; Amatrix and Smatrix retain their node order. Named node dimensions of the separately supplied matrices must agree in order.

Amatrix

If RAM is not specified, an Amatrix is required. An asymmetric matrix in the RAM specification with MxMatrix-class. If it is NULL, a matrix of zero will be created. If it is a matrix, it will be converted into MxMatrix-class by the as.mxMatrix function.

Smatrix

If RAM is not specified, an Smatrix is required. 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.

Fmatrix

A filter matrix in the RAM specification with MxMatrix-class. If it is NULL (the default), an identity matrix with the same dimensions of Cov will be created. If it is a matrix, it will be converted into MxMatrix-class by the as.mxMatrix function. It is not required when there is no latent variable.

diag.constraints

Logical. This argument is ignored when cor.analysis=FALSE. If diag.constraints=TRUE, the diagonals of the model implied matrix would be constrained at 1 by nonlinear constraints. The drawback is that standard error will not be generated. Parametric bootstrap is used to estimate the standard error by drawing samples from \(\mathcal{N}(vech(Cov), asyCov)\) for covariance analysis and \(\mathcal{N}(vechs(Cov), asyCov)\) for correlation analysis while asyCov is treated as fixed. This process is computationally intensive. A better approach is to request likelihood-based confidence intervals (CIs) by specifying intervals.type="LB". If diag.constraints=FALSE and cor.analysis=TRUE, the diagonals are automatically constrained as ones by treating the error variances as computed values rather than as parameters. Since the error variances are not parameters, they are not reported. Fixed dependent residual variances are ignored with a warning in this implicit method. In the explicit-constraint method, fixed dependent residuals do not receive a unit-variance constraint; a warning asks the user to verify the model-implied variance.

cor.analysis

Logical. Analysis of correlation or covariance structure. If cor.analysis=TRUE, vechs is used to vectorize S; otherwise, vech is used to vectorize S.

intervals.type

Either z (default if missing) or LB. If it is z, it calculates the 95% Wald CIs based on the z statistic. If it is LB, it calculates the 95% likelihood-based CIs on the parameter estimates. Please note that the z values and their associated p values are based on the z statistic. They are not related to the likelihood-based CIs.

mx.algebras

A list of mxMatrix or mxAlgebra objects on the Amatrix, Smatrix, and Fmatrx. It can be used to define new functions of parameters and their LBCIs. For example, if the regression coefficients to calculate an indirect effect are stored in A[1,2] and A[1,3], we may define list(ind=mxAlgebra(Amatrix[1,2]*Amatrix[1,3], name="ind")) See the examples in Becker92 and Hunter83. It should be noted that Fmatrix, Amatrix, Smatrix, Iden (a \(p\) x \(p\) identity matrix), sampleS (sample correlation or covariance matrix), impliedS1, impliedS (model implied correlation or covariance matrix), vecS, invAcov, obj, One, select and constraint and Ematrix (computed error variances when diag.constraints=FALSE) have been defined internally. You should not create new matrices using these names.

mxModel.Args

A list of arguments passed to mxModel. These include, for example, additional mxMatrix and mxConstraint.

subset.variables

An optional character vector of variable names to select variables in the analysis. For example, there are 10 variables in Cov, say, x1 to x10. We may use c("x1", "x2", "x3") to select three variables in the analysis. The order supplied here is used for both the selected covariance matrix and its asymptotic covariance matrix.

model.name

A string for the model name in mxModel. If it is missing, the default is "TSSEM2 (or WLS) Analysis of Correlation Structure" for cor.analysis=TRUE and "TSSEM2 (or WLS) Analysis of Covariance Structure" for cor.analysis=FALSE.

suppressWarnings

Logical. If TRUE, warnings are suppressed. The argument to be passed to mxRun.

silent

Logical. An argument to be passed to mxRun

run

Logical. If FALSE, only return the mx model without running the analysis.

...

Further arguments to be passed to mxRun.

tssem1.obj

An object of either class tssem1FEM, class tssem1FEM.cluster or class tssem1REM returned from tssem1()

Author

Mike W.-L. Cheung <[email protected]>

References

Bentler, P.M., & Savalei, V. (2010). Analysis of correlation structures: current status and open problems. In Kolenikov, S., Thombs, L., & Steinley, D. (Eds.). Recent Methodological Developments in Social Science Statistics (pp. 1-36). Hoboken, NJ: Wiley.

Cheung, M. W.-L. (2010). Fixed-effects meta-analyses as multiple-group structural equation models. Structural Equation Modeling, 17, 481-509.

Cheung, M. W.-L. (2014). Fixed- and random-effects meta-analytic structural equation modeling: Examples and analyses in R. Behavior Research Methods, 46, 29-40.

Cheung, M. W.-L., & Chan, W. (2005). Meta-analytic structural equation modeling: A two-stage approach. Psychological Methods, 10, 40-64.

Cheung, M. W.-L., & Chan, W. (2009). A two-stage approach to synthesizing covariance matrices in meta-analytic structural equation modeling. Structural Equation Modeling, 16, 28-53.

Joreskog, K. G., Sorbom, D., Du Toit, S., & Du Toit, M. (1999). LISREL 8: New Statistical Features. Chicago: Scientific Software International.

McArdle, J. J., & MacDonald, R. P. (1984). Some algebraic properties of the Reticular Action Model for moment structures. British Journal of Mathematical and Statistical Psychology, 37, 234-251.

See Also

tssem1, Becker92, Digman97, Hunter83, issp89, issp05

Examples

Run this code

# \donttest{
#### Analysis of correlation structure
R1.labels <- c("a1", "a2", "a3", "a4")

R1 <- matrix(c(1.00, 0.22, 0.24, 0.18,
               0.22, 1.00, 0.30, 0.22,
               0.24, 0.30, 1.00, 0.24,
               0.18, 0.22, 0.24, 1.00), ncol=4, nrow=4,
               dimnames=list(R1.labels, R1.labels))
n <- 1000
acovR1 <- asyCov(R1, n)

#### One-factor CFA model using lavaan specification
model1 <- "f =~ a1 + a2 + a3 + a4"

RAM1 <- lavaan2RAM(model1, obs.variables=R1.labels)

wls.fit1a <- wls(Cov=R1, aCov=acovR1, n=n, RAM=RAM1,
                 cor.analysis=TRUE, intervals="LB")
summary(wls.fit1a)

## One-factor CFA model using RAM specification
(A1 <- cbind(matrix(0, nrow=5, ncol=4),
             matrix(c("0.2*a1","0.2*a2","0.2*a3","0.2*a4",0),
             ncol=1)))

(S1 <- Diag(c("0.2*e1","0.2*e2","0.2*e3","0.2*e4",1)))

## The first 4 variables are observed while the last one is latent.
(F1 <- create.Fmatrix(c(1,1,1,1,0), name="F1"))

wls.fit1b <- wls(Cov=R1, aCov=acovR1, n=n, Fmatrix=F1, Smatrix=S1, Amatrix=A1,
                 cor.analysis=TRUE, intervals="LB")
summary(wls.fit1b)

## Select 3 variables to analyze
model2 <- "f =~ a1 + a2 + a3"

RAM2 <- lavaan2RAM(model2, obs.variables=R1.labels[-4])

wls.fit1c <- wls(Cov=R1, aCov=acovR1, n=n, RAM=RAM2,
                 cor.analysis=TRUE, subset.variables=c("a1", "a2", "a3"))
summary(wls.fit1c)

#### Multiple regression analysis using lavaan specification
R2.labels <- c("y", "x1", "x2")

R2 <- matrix(c(1.00, 0.22, 0.24, 
               0.22, 1.00, 0.30, 
               0.24, 0.30, 1.00), ncol=3, nrow=3,
               dimnames=list(R2.labels, R2.labels))
acovR2 <- asyCov(R2, n)

model3 <- "y ~ x1 + x2
           ## Variances of x1 and x2 are 1
           x1 ~~ 1*x1
           x2 ~~ 1*x2
           ## x1 and x2 are correlated
           x1 ~~ x2"

RAM3 <- lavaan2RAM(model3, obs.variables=R2.labels)

wls.fit2a <- wls(Cov=R2, aCov=acovR2, n=n, RAM=RAM3,
                 cor.analysis=TRUE, intervals="z")
summary(wls.fit2a)


#### Multiple regression analysis using RAM specification

## A2: Regression coefficents
#    y x1 x2
# y  F T  T 
# x1 F F  F 
# x2 F F  F 
(A2 <- mxMatrix("Full", ncol=3, nrow=3, byrow=TRUE,
               free=c(FALSE, rep(TRUE, 2), rep(FALSE, 6)), name="A2"))

## S2: Covariance matrix of free parameters
#    y x1 x2
# y  T F  F 
# x1 F F  F 
# x2 F T  F
(S2 <- mxMatrix("Symm", ncol=3, nrow=3, values=c(0.2,0,0,1,0.2,1),
                labels=c("Var_y", NA, NA, NA, "Cov_x1_x2", NA),
                free=c(TRUE,FALSE,FALSE,FALSE,TRUE,FALSE), name="S2"))

## F may be ignored as there is no latent variable.
wls.fit2b <- wls(Cov=R2, aCov=acovR2, n=n, Amatrix=A2, Smatrix=S2,
                 cor.analysis=TRUE, intervals="LB")
summary(wls.fit2b)


#### Analysis of covariance structure using lavaan specification
R3.labels=c("a1", "a2", "a3", "a4")

R3 <- matrix(c(1.50, 0.22, 0.24, 0.18,
               0.22, 1.60, 0.30, 0.22,
               0.24, 0.30, 1.80, 0.24,
               0.18, 0.22, 0.24, 1.30), ncol=4, nrow=4,
               dimnames=list(R3.labels, R3.labels))
n <- 1000
acovS3 <- asyCov(R3, n, cor.analysis=FALSE)

model3 <- "f =~ a1 + a2 + a3 + a4"

RAM3 <- lavaan2RAM(model3, obs.variables=R3.labels)

wls.fit3a <- wls(Cov=R3, aCov=acovS3, n=n, RAM=RAM3,
                 cor.analysis=FALSE)
summary(wls.fit3a)

#### Analysis of covariance structure using RAM specification
(A3 <- cbind(matrix(0, nrow=5, ncol=4),
             matrix(c("0.2*a1","0.2*a2","0.2*a3","0.2*a4",0),ncol=1)))

(S3 <- Diag(c("0.2*e1","0.2*e2","0.2*e3","0.2*e4",1)))

F3 <- c(TRUE,TRUE,TRUE,TRUE,FALSE)
(F3 <- create.Fmatrix(F3, name="F3", as.mxMatrix=FALSE))

wls.fit3b <- wls(Cov=R3, aCov=acovS3, n=n, Amatrix=A3, Smatrix=S3,
                Fmatrix=F3, cor.analysis=FALSE)
summary(wls.fit3b)
# }

Run the code above in your browser using DataLab