Simulated Example of Ordered Function in Lavaan

R-Code

Data Simulation

> set.seed(1992)
> N<-runif(1,500,1000)
> bA1<-runif(1,1,5)
> bA2<-runif(1,1,5)
> bA3<-runif(1,1,5)
> bA4<-runif(1,1,5)
> cA1<-runif(1,1,5)
> cA2<-runif(1,1,5)
> cA3<-runif(1,1,5)
> cA4<-runif(1,1,5)
> eb<-runif(1,10,20)*sample(c(-1,1),1)
> ec<-runif(1,10,20)*sample(c(-1,1),1)
> 
> ## Random Variables ####
> A1<-rnorm(N,1,10)
> A2<-rnorm(N,1,10)
> A3<-rnorm(N,1,10)
> A4<-rnorm(N,1,10)
> eB<-rnorm(N,1,10)
> eC<-rnorm(N,1,10)
> ## Directed Equations ####
> B_C<-(bA1*A1)+(bA2*A2)+(bA3*A3)+(bA4*A4)+(eb*eB)
> summary(B_C)
         Min.       1st Qu.        Median          Mean       3rd Qu.          Max. 
-636.65158031 -136.24443920  -10.56683713   -1.56843134  137.18856826  632.45821131 
> B_n<-((B_C)-min(B_C-100))/((max(B_C+100))-min(B_C-100))
> summary(B_n)
       Min.     1st Qu.      Median        Mean     3rd Qu.        Max. 
0.068068432 0.408687727 0.494234500 0.500359574 0.594809288 0.931931568 
> B<-rbinom(N,1,prob=B_n)
> table(B)
B
  0   1 
417 395 
> C<-0*B+(cA1*A1)+(cA2*A2)+(cA3*A3)+(cA4*A4)+(ec*eC)
> 
> DF<-data.frame(A1,A2,A3,A4,B,C)
> DF$C<-DF$C*.01

DWLS estimator without specifying B as ordered

> 
> F1<-'
+ # Latent Factor ####
+ B~A1
+ C~B
+ 
+ '
> M<-sem(F1,orthogonal = T, data=DF, estimator = "DWLS")
> summary(M, fit.measures= TRUE, standardized = TRUE, ci = TRUE, rsquare = T)
lavaan 0.6-9 ended normally after 14 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                         5
                                                      
  Number of observations                           812
                                                      
Model Test User Model:
                                                      
  Test statistic                                45.349
  Degrees of freedom                                 1
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                                45.352
  Degrees of freedom                                 3
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.000
  Tucker-Lewis Index (TLI)                      -2.141

Root Mean Square Error of Approximation:

  RMSEA                                          0.234
  90 Percent confidence interval - lower         0.179
  90 Percent confidence interval - upper         0.294
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.094

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
  B ~                                                                                     
    A1               -0.000    0.002   -0.032    0.975   -0.004    0.003   -0.000   -0.001
  C ~                                                                                     
    B                 0.003    0.086    0.038    0.970   -0.166    0.172    0.003    0.001

Variances:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
   .B                 0.250    0.000  525.565    0.000    0.249    0.251    0.250    1.000
   .C                 1.511    0.076   19.938    0.000    1.363    1.660    1.511    1.000
    A1               95.802    4.333   22.108    0.000   87.308  104.295   95.802    1.000

R-Square:
                   Estimate
    B                 0.000
    C                 0.000

DWLS estimator with specifying B as ordered

> F2<-'
+ # Latent Factor ####
+ B~A1
+ C~B
+ 
+ '
> M2<-sem(F2, orthogonal = T, data=DF, estimator = "DWLS", ordered = "B")
> summary(M2, fit.measures= TRUE, standardized = TRUE, ci = TRUE, rsquare = T)
lavaan 0.6-9 ended normally after 11 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                         5
                                                      
  Number of observations                           812
                                                      
Model Test User Model:
                                                      
  Test statistic                                40.935
  Degrees of freedom                                 1
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                                 0.003
  Degrees of freedom                                 1
  P-value                                        0.955

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.000
  Tucker-Lewis Index (TLI)                      41.061

Root Mean Square Error of Approximation:

  RMSEA                                          0.222
  90 Percent confidence interval - lower         0.167
  90 Percent confidence interval - upper         0.282
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.000

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
  B ~                                                                                     
    A1               -0.000    0.005   -0.025    0.980   -0.009    0.009   -0.000   -0.001
  C ~                                                                                     
    B                 0.003    0.053    0.048    0.962   -0.101    0.106    0.003    0.002

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
   .B                 0.000                               0.000    0.000    0.000    0.000
   .C                 0.226    0.042    5.323    0.000    0.142    0.309    0.226    0.189

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
    B|t1              0.034    0.044    0.765    0.444   -0.053    0.120    0.034    0.034

Variances:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
   .B                 1.000                               1.000    1.000    1.000    1.000
   .C                 1.429    0.069   20.859    0.000    1.295    1.564    1.429    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
    B                 1.000                               1.000    1.000    1.000    1.000

R-Square:
                   Estimate
    B                 0.000
    C                 0.000