[R] Specifying Path Model in SEM for CFA

Rick Bilonick rab at nauticom.net
Wed Aug 16 06:50:29 CEST 2006


I'm using specify.model for the sem package. I can't figure out how to
represent the residual errors for the observed variables for a CFA
model. (Once I get this working I need to add some further constraints.)

Here is what I've tried:

model.sa <- specify.model()
  F1	 -> X1,l11, NA
  F1	 -> X2,l21, NA
  F1	 -> X3,l31, NA
  F1	 -> X4,l41, NA
  F1	 -> X5, NA, 0.20
  F2	 -> X1,l12, NA
  F2	 -> X2,l22, NA
  F2	 -> X3,l32, NA
  F2	 -> X4,l42, NA
  F2	 -> X6, NA, 0.25
  F1	<-> F2,g12, 1
  F1    <-> F1,g11, 1
  F2    <-> F2,g22, 1
  X1	<-> X1, NA, 1
  X2	<-> X2, NA, 1
  X3	<-> X3, NA, 1
  X4	<-> X4, NA, 1
  X5	<-> X5, NA, 1
  X6	<-> X6, NA, 1

This at least converges:

> summary(fit.sem)

 Model Chisquare =  2147   Df =  10 Pr(>Chisq) = 0
 Chisquare (null model) =  2934   Df =  15
 Goodness-of-fit index =  0.4822
 Adjusted goodness-of-fit index =  -0.087387
 RMSEA index =  0.66107   90 % CI: (NA, NA)
 Bentler-Bonnett NFI =  0.26823
 Tucker-Lewis NNFI =  -0.098156
 Bentler CFI =  0.26790
 BIC =  2085.1

 Normalized Residuals
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
 -5.990  -0.618   0.192   0.165   1.700   3.950

 Parameter Estimates
    Estimate  Std Error z value  Pr(>|z|)
l11 -0.245981 0.21863   -1.12510 0.26054748 X1 <--- F1
l21 -0.308249 0.22573   -1.36555 0.17207875 X2 <--- F1
l31  0.202590 0.07910    2.56118 0.01043175 X3 <--- F1
l41 -0.235156 0.21980   -1.06985 0.28468885 X4 <--- F1
l12  0.839985 0.21962    3.82476 0.00013090 X1 <--- F2
l22  0.828460 0.22548    3.67418 0.00023862 X2 <--- F2
l32  0.066722 0.08369    0.79725 0.42530606 X3 <--- F2
l42  0.832037 0.21840    3.80963 0.00013917 X4 <--- F2
g12  0.936719 0.64331    1.45609 0.14536647 F2 <--> F1
g11  2.567669 1.25608    2.04418 0.04093528 F1 <--> F1
g22  1.208497 0.55040    2.19567 0.02811527 F2 <--> F2

 Iterations =  59

And it produces the following path diagram:

> path.diagram(fit.sem)
digraph "fit.sem" {
  rankdir=LR;
  size="8,8";
  node [fontname="Helvetica" fontsize=14 shape=box];
  edge [fontname="Helvetica" fontsize=10];
  center=1;
  "F2" [shape=ellipse]
  "F1" [shape=ellipse]
  "F1" -> "X1" [label="l11"];
  "F1" -> "X2" [label="l21"];
  "F1" -> "X3" [label="l31"];
  "F1" -> "X4" [label="l41"];
  "F1" -> "X5" [label=""];
  "F2" -> "X1" [label="l12"];
  "F2" -> "X2" [label="l22"];
  "F2" -> "X3" [label="l32"];
  "F2" -> "X4" [label="l42"];
  "F2" -> "X6" [label=""];
}

But I don't see the residual error terms that go into each of the
observed variables X1 - X6. I've tried:

model.sa <- specify.model()
  E1	 -> X1, e1,  1
  E2	 -> X2, e2,  1
  E3	 -> X3, e3,  1
  E4	 -> X4, e4,  1
  E5	 -> X5, e5,  1
  E6	 -> X6, e6,  1
  E1	<-> E1, s1, NA
  E2	<-> E2, s2, NA
  E3	<-> E3, s3, NA
  E4	<-> E4, s4, NA
  E5	<-> E5, s5, NA
  E6	<-> E6, s6, NA
  F1	 -> X1,l11, NA
  F1	 -> X2,l21, NA
  F1	 -> X3,l31, NA
  F1	 -> X4,l41, NA
  F1	 -> X5, NA,  1
  F2	 -> X1,l12, NA
  F2	 -> X2,l22, NA
  F2	 -> X3,l32, NA
  F2	 -> X4,l42, NA
  F2	 -> X6, NA,  1
  F1	<-> F2, NA, 1
  F1    <-> F1, NA, 1
  F2    <-> F2,g22, NA
  X1	<-> X1, NA, 1
  X2	<-> X2, NA, 1
  X3	<-> X3, NA, 1
  X4	<-> X4, NA, 1
  X5	<-> X5, NA, 1
  X6	<-> X6, NA, 1

I'm trying to use E1 - E6 as the residual error terms. But I get warning
messages about no variances for X1-X6 and it doesn't converge. Also, the
associated path diagram:

digraph "fit.sem" {
  rankdir=LR;
  size="8,8";
  node [fontname="Helvetica" fontsize=14 shape=box];
  edge [fontname="Helvetica" fontsize=10];
  center=1;
  "E1" [shape=ellipse]
  "E2" [shape=ellipse]
  "E3" [shape=ellipse]
  "E4" [shape=ellipse]
  "E5" [shape=ellipse]
  "E6" [shape=ellipse]
  "F2" [shape=ellipse]
  "F1" [shape=ellipse]
  "E1" -> "X1" [label=""];
  "E2" -> "X2" [label=""];
  "E3" -> "X3" [label=""];
  "E4" -> "X4" [label=""];
  "E5" -> "X5" [label=""];
  "E6" -> "X6" [label=""];
  "F1" -> "X1" [label="l11"];
  "F1" -> "X2" [label="l21"];
  "F1" -> "X3" [label="l31"];
  "F1" -> "X4" [label="l41"];
  "F1" -> "X5" [label=""];
  "F2" -> "X1" [label="l12"];
  "F2" -> "X2" [label="l22"];
  "F2" -> "X3" [label="l32"];
  "F2" -> "X4" [label="l42"];
  "F2" -> "X6" [label=""];
}

Has ellipses around the E1-E6 which I believe indicates they are latent
factors and not residual errors.

If anyone could point in the right direction I would appreciate it.

Rick B.



More information about the R-help mailing list