Testing Multiple-Group Measurement Invariance using WLSMV in Item Factor Models in lavaan

if (!require(lavaan)) install.packages("lavaan")
Loading required package: lavaan
This is lavaan 0.5-23.1097
lavaan is BETA software! Please report any bugs.
library(lavaan)

Example data: 634 older adults (age 80-100) self-reporting on 7 items assessing the Instrumental Activities of Daily Living (IADL) as follows:

  1. Housework (cleaning and laundry): 1=64%
  2. Bedmaking: 1=84%
  3. Cooking: 1=77%
  4. Everyday shopping: 1=66%
  5. Getting to places outside of walking distance: 1=65%
  6. Handling banking and other business: 1=73%
  7. Using the telephone 1=94%

Two versions of a response format were available:

Binary -> 0 = “needs help”, 1 = “does not need help”

Categorical -> 0 = “can’t do it”, 1=”big problems”, 2=”some problems”, 3=”no problems”

Higher scores indicate greater function. We will look at each response format in turn.

We will be using the categorical items in this example.

Data Import into R

The data are in a text file named adl.dat originally used in Mplus (so no column names were included at the top of the file). The file contains more items than we will use, so we select only items above from the whole file.

#read in data file (Mplus file format so having to label columns)
adlData = read.table(file = "adl2.dat", header = FALSE, na.strings = ".", col.names = c("case", "female", paste0("dpa", 1:14), paste0("dia", 1:7), paste0("cpa", 1:14), paste0("cia", 1:7)))
#select Situations items and PersonID variables
iadlDataInit = adlData[c(paste0("cia", 1:7), "female")]
#remove cases with all items missing
removeCases = which(apply(X = iadlDataInit, MARGIN = 1, FUN = function (x){ length(which(is.na(x)))}) == 7)
iadlData = iadlDataInit[-removeCases,]
#recode group variable
iadlData$sex = NA_character_
iadlData$sex[which(iadlData$female==1)] = "female"
iadlData$sex[which(iadlData$female==0)] = "male"

Configural Invariance Model

Here everything is estimated separately across groups except for parameters needed to be constrained for identification.

configuralSyntax = "
#============================================================================================================
#Factor loadings (AKA slopes/discriminations) all freely estimated in both groups with label for each group
IADL =~ c(L1M, L1F)*cia1 + c(L2M, L2F)*cia2 + c(L3M, L3F)*cia3 + 
        c(L4M, L4F)*cia4 + c(L5M, L5F)*cia5 + c(L6M, L6F)*cia6 + c(L7M, L7F)*cia7
#============================================================================================================
#Item Thresholds all freely estimated in both groups with label for each group
cia1|c(I1T1M, I1T1F)*t1; cia1|c(I1T2M, I1T2F)*t2; cia1|c(I1T3M, I1T3F)*t3;
cia2|c(I2T1M, I2T1F)*t1; cia2|c(I2T2M, I2T2F)*t2; cia2|c(I2T3M, I2T3F)*t3;
cia3|c(I3T1M, I3T1F)*t1; cia3|c(I3T2M, I3T2F)*t2; cia3|c(I3T3M, I3T3F)*t3;
cia4|c(I4T1M, I4T1F)*t1; cia4|c(I4T2M, I4T2F)*t2; cia4|c(I4T3M, I4T3F)*t3;
cia5|c(I5T1M, I5T1F)*t1; cia5|c(I5T2M, I5T2F)*t2; cia5|c(I5T3M, I5T3F)*t3;
cia6|c(I6T1M, I6T1F)*t1; cia6|c(I6T2M, I6T2F)*t2; cia6|c(I6T3M, I6T3F)*t3;
cia7|c(I7T1M, I7T1F)*t1; cia7|c(I7T2M, I7T2F)*t2; cia7|c(I7T3M, I7T3F)*t3;
#============================================================================================================
#Redidual variances all fixed to one for each group
cia1 ~~ c(1, 1)*cia1; cia2 ~~ c(1, 1)*cia2; cia3 ~~ c(1, 1)*cia3; 
cia4 ~~ c(1, 1)*cia4; cia5 ~~ c(1, 1)*cia5; cia6 ~~ c(1, 1)*cia6; cia7 ~~ c(1, 1)*cia7
#============================================================================================================
#Factor variance fixed to 1 for identification in each group
IADL ~~ c(1,1)*IADL
#============================================================================================================
#Factor mean fixed to zero for identification in each group
IADL ~ c(0,0)*0
#============================================================================================================
"
configuralEstimates = lavaan(model = configuralSyntax, data = iadlData, 
                             ordered = c("cia1", "cia2", "cia3", "cia4", "cia5", "cia6", "cia7"), std.lv = TRUE, 
                             parameterization="theta", group = "sex")
lavaan WARNING: 40 bivariate tables have empty cells; to see them, use:
                  lavInspect(fit, "zero.cell.tables")
summary(configuralEstimates, fit.measures = TRUE, rsquare = TRUE, standardized = TRUE)
lavaan (0.5-23.1097) converged normally after 249 iterations

                                                  Used       Total
  Number of observations per group         
  male                                             163         214
  female                                           383         420

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic               26.447      64.705
  Degrees of freedom                                28          28
  P-value (Chi-square)                           0.549       0.000
  Scaling correction factor                                  0.451
  Shift parameter for each group:
    male                                                     1.795
    female                                                   4.217
    for simple second-order correction (Mplus variant)

Chi-square for each group:

  male                                           8.363      20.354
  female                                        18.084      44.351

Model test baseline model:

  Minimum Function Test Statistic            69203.021   35439.603
  Degrees of freedom                                42          42
  P-value                                        0.000       0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    1.000       0.999
  Tucker-Lewis Index (TLI)                       1.000       0.998

  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.000       0.069
  90 Percent Confidence Interval          0.000  0.044       0.047  0.092
  P-value RMSEA <= 0.05                          0.979       0.072

  Robust RMSEA                                                  NA
  90 Percent Confidence Interval                                NA     NA

Standardized Root Mean Square Residual:

  SRMR                                           0.025       0.025

Weighted Root Mean Square Residual:

  WRMR                                           0.794       0.794

Parameter Estimates:

  Information                                 Expected
  Standard Errors                           Robust.sem


Group 1 [male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1     (L1M)    4.973    0.883    5.633    0.000    4.973    0.980
    cia2     (L2M)    3.749    0.825    4.546    0.000    3.749    0.966
    cia3     (L3M)    3.436    0.538    6.383    0.000    3.436    0.960
    cia4     (L4M)    4.693    0.983    4.774    0.000    4.693    0.978
    cia5     (L5M)    2.997    0.525    5.705    0.000    2.997    0.949
    cia6     (L6M)    3.342    0.854    3.914    0.000    3.342    0.958
    cia7     (L7M)    1.116    0.238    4.686    0.000    1.116    0.745

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -6.378    1.093   -5.837    0.000   -6.378   -1.257
    cia1|t2 (I1T2)   -4.683    0.844   -5.551    0.000   -4.683   -0.923
    cia1|t3 (I1T3)   -1.061    0.589   -1.802    0.072   -1.061   -0.209
    cia2|t1 (I2T1)   -5.013    0.939   -5.341    0.000   -5.013   -1.292
    cia2|t2 (I2T2)   -4.626    0.897   -5.159    0.000   -4.626   -1.192
    cia2|t3 (I2T3)   -2.827    0.727   -3.889    0.000   -2.827   -0.729
    cia3|t1 (I3T1)   -4.381    0.602   -7.272    0.000   -4.381   -1.224
    cia3|t2 (I3T2)   -3.389    0.579   -5.857    0.000   -3.389   -0.947
    cia3|t3 (I3T3)   -0.918    0.403   -2.280    0.023   -0.918   -0.257
    cia4|t1 (I4T1)   -5.722    1.075   -5.320    0.000   -5.722   -1.192
    cia4|t2 (I4T2)   -4.905    0.923   -5.314    0.000   -4.905   -1.022
    cia4|t3 (I4T3)   -2.679    0.730   -3.671    0.000   -2.679   -0.558
    cia5|t1 (I5T1)   -5.043    0.750   -6.724    0.000   -5.043   -1.596
    cia5|t2 (I5T2)   -3.312    0.556   -5.959    0.000   -3.312   -1.048
    cia5|t3 (I5T3)   -1.764    0.441   -3.997    0.000   -1.764   -0.558
    cia6|t1 (I6T1)   -5.770    1.270   -4.544    0.000   -5.770   -1.654
    cia6|t2 (I6T2)   -4.635    1.056   -4.388    0.000   -4.635   -1.328
    cia6|t3 (I6T3)   -3.140    0.854   -3.676    0.000   -3.140   -0.900
    cia7|t1 (I7T1)   -3.128    0.424   -7.374    0.000   -3.128   -2.088
    cia7|t2 (I7T2)   -2.573    0.324   -7.953    0.000   -2.573   -1.717
    cia7|t3 (I7T3)   -1.884    0.265   -7.120    0.000   -1.884   -1.257

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.039
   .cia2              1.000                               1.000    0.066
   .cia3              1.000                               1.000    0.078
   .cia4              1.000                               1.000    0.043
   .cia5              1.000                               1.000    0.100
   .cia6              1.000                               1.000    0.082
   .cia7              1.000                               1.000    0.446
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.197                               0.197    1.000
    cia2              0.258                               0.258    1.000
    cia3              0.279                               0.279    1.000
    cia4              0.208                               0.208    1.000
    cia5              0.317                               0.317    1.000
    cia6              0.287                               0.287    1.000
    cia7              0.667                               0.667    1.000

R-Square:
                   Estimate
    cia1              0.961
    cia2              0.934
    cia3              0.922
    cia4              0.957
    cia5              0.900
    cia6              0.918
    cia7              0.554


Group 2 [female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1     (L1F)    3.029    0.309    9.790    0.000    3.029    0.950
    cia2     (L2F)    3.465    0.506    6.845    0.000    3.465    0.961
    cia3     (L3F)    5.205    1.101    4.728    0.000    5.205    0.982
    cia4     (L4F)    3.204    0.317   10.108    0.000    3.204    0.955
    cia5     (L5F)    2.271    0.216   10.512    0.000    2.271    0.915
    cia6     (L6F)    1.736    0.175    9.941    0.000    1.736    0.867
    cia7     (L7F)    1.011    0.157    6.452    0.000    1.011    0.711

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -4.575    0.407  -11.248    0.000   -4.575   -1.434
    cia1|t2 (I1T2)   -3.358    0.345   -9.731    0.000   -3.358   -1.053
    cia1|t3 (I1T3)   -0.856    0.232   -3.690    0.000   -0.856   -0.268
    cia2|t1 (I2T1)   -5.605    0.687   -8.154    0.000   -5.605   -1.554
    cia2|t2 (I2T2)   -4.748    0.619   -7.670    0.000   -4.748   -1.317
    cia2|t3 (I2T3)   -2.955    0.496   -5.957    0.000   -2.955   -0.819
    cia3|t1 (I3T1)   -7.802    1.453   -5.371    0.000   -7.802   -1.472
    cia3|t2 (I3T2)   -6.737    1.308   -5.151    0.000   -6.737   -1.271
    cia3|t3 (I3T3)   -4.441    1.026   -4.329    0.000   -4.441   -0.838
    cia4|t1 (I4T1)   -4.526    0.387  -11.698    0.000   -4.526   -1.348
    cia4|t2 (I4T2)   -2.844    0.309   -9.202    0.000   -2.844   -0.847
    cia4|t3 (I4T3)   -0.742    0.240   -3.090    0.002   -0.742   -0.221
    cia5|t1 (I5T1)   -3.970    0.322  -12.338    0.000   -3.970   -1.600
    cia5|t2 (I5T2)   -1.944    0.211   -9.215    0.000   -1.944   -0.783
    cia5|t3 (I5T3)   -0.285    0.165   -1.729    0.084   -0.285   -0.115
    cia6|t1 (I6T1)   -3.303    0.249  -13.270    0.000   -3.303   -1.649
    cia6|t2 (I6T2)   -2.227    0.196  -11.351    0.000   -2.227   -1.112
    cia6|t3 (I6T3)   -1.250    0.168   -7.441    0.000   -1.250   -0.624
    cia7|t1 (I7T1)   -3.437    0.343  -10.006    0.000   -3.437   -2.417
    cia7|t2 (I7T2)   -2.761    0.243  -11.340    0.000   -2.761   -1.941
    cia7|t3 (I7T3)   -1.747    0.168  -10.369    0.000   -1.747   -1.228

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.098
   .cia2              1.000                               1.000    0.077
   .cia3              1.000                               1.000    0.036
   .cia4              1.000                               1.000    0.089
   .cia5              1.000                               1.000    0.162
   .cia6              1.000                               1.000    0.249
   .cia7              1.000                               1.000    0.494
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.314                               0.314    1.000
    cia2              0.277                               0.277    1.000
    cia3              0.189                               0.189    1.000
    cia4              0.298                               0.298    1.000
    cia5              0.403                               0.403    1.000
    cia6              0.499                               0.499    1.000
    cia7              0.703                               0.703    1.000

R-Square:
                   Estimate
    cia1              0.902
    cia2              0.923
    cia3              0.964
    cia4              0.911
    cia5              0.838
    cia6              0.751
    cia7              0.506

Metric Invariance Models

Here the IFA factor loadings are held equal across groups but the factor variance is freed.

metricSyntax1 = "
#============================================================================================================
#Factor loadings (AKA slopes/discriminations) all constriaind across both groups with same label for both groups *****
IADL =~ c(L1, L1)*cia1 + c(L2, L2)*cia2 + c(L3, L3)*cia3 + 
        c(L4, L4)*cia4 + c(L5, L5)*cia5 + c(L6, L6)*cia6 + c(L7, L7)*cia7
#============================================================================================================
#Item Thresholds all freely estimated in both groups with label for each group
cia1|c(I1T1M, I1T1F)*t1; cia1|c(I1T2M, I1T2F)*t2; cia1|c(I1T3M, I1T3F)*t3;
cia2|c(I2T1M, I2T1F)*t1; cia2|c(I2T2M, I2T2F)*t2; cia2|c(I2T3M, I2T3F)*t3;
cia3|c(I3T1M, I3T1F)*t1; cia3|c(I3T2M, I3T2F)*t2; cia3|c(I3T3M, I3T3F)*t3;
cia4|c(I4T1M, I4T1F)*t1; cia4|c(I4T2M, I4T2F)*t2; cia4|c(I4T3M, I4T3F)*t3;
cia5|c(I5T1M, I5T1F)*t1; cia5|c(I5T2M, I5T2F)*t2; cia5|c(I5T3M, I5T3F)*t3;
cia6|c(I6T1M, I6T1F)*t1; cia6|c(I6T2M, I6T2F)*t2; cia6|c(I6T3M, I6T3F)*t3;
cia7|c(I7T1M, I7T1F)*t1; cia7|c(I7T2M, I7T2F)*t2; cia7|c(I7T3M, I7T3F)*t3;
#============================================================================================================
#Redidual variances all fixed to one for each group
cia1 ~~ c(1, 1)*cia1; cia2 ~~ c(1, 1)*cia2; cia3 ~~ c(1, 1)*cia3; 
cia4 ~~ c(1, 1)*cia4; cia5 ~~ c(1, 1)*cia5; cia6 ~~ c(1, 1)*cia6; cia7 ~~ c(1, 1)*cia7
#============================================================================================================
#Factor variance fixed to 1 for identification in group1; estimated for group 2
IADL ~~ c(1,NA)*IADL
#============================================================================================================
#Factor mean fixed to zero for identification in each group
IADL ~ c(0,0)*0
#============================================================================================================
"
metricEstimates1 = lavaan(model = metricSyntax1, data = iadlData, ordered = c("cia1", "cia2", "cia3", "cia4", "cia5", "cia6", "cia7"),
                          parameterization="theta", group = "sex")
lavaan WARNING: 40 bivariate tables have empty cells; to see them, use:
                  lavInspect(fit, "zero.cell.tables")
summary(metricEstimates1, fit.measures = TRUE, rsquare = TRUE, standardized = TRUE)
lavaan (0.5-23.1097) converged normally after 210 iterations

                                                  Used       Total
  Number of observations per group         
  male                                             163         214
  female                                           383         420

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic               42.967      63.802
  Degrees of freedom                                34          34
  P-value (Chi-square)                           0.139       0.001
  Scaling correction factor                                  0.792
  Shift parameter for each group:
    male                                                     2.851
    female                                                   6.700
    for simple second-order correction (Mplus variant)

Chi-square for each group:

  male                                          20.789      29.099
  female                                        22.178      34.702

Model test baseline model:

  Minimum Function Test Statistic            69203.021   35439.603
  Degrees of freedom                                42          42
  P-value                                        0.000       0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    1.000       0.999
  Tucker-Lewis Index (TLI)                       1.000       0.999

  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.031       0.057
  90 Percent Confidence Interval          0.000  0.057       0.035  0.078
  P-value RMSEA <= 0.05                          0.874       0.282

  Robust RMSEA                                                  NA
  90 Percent Confidence Interval                                NA     NA

Standardized Root Mean Square Residual:

  SRMR                                           0.031       0.031

Weighted Root Mean Square Residual:

  WRMR                                           1.011       1.011

Parameter Estimates:

  Information                                 Expected
  Standard Errors                           Robust.sem


Group 1 [male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.054    0.463    8.747    0.000    4.054    0.971
    cia2      (L2)    4.658    0.757    6.153    0.000    4.658    0.978
    cia3      (L3)    5.637    0.931    6.052    0.000    5.637    0.985
    cia4      (L4)    4.415    0.556    7.940    0.000    4.415    0.975
    cia5      (L5)    3.011    0.370    8.145    0.000    3.011    0.949
    cia6      (L6)    2.571    0.316    8.147    0.000    2.571    0.932
    cia7      (L7)    1.266    0.191    6.614    0.000    1.266    0.785

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.250    0.542   -9.687    0.000   -5.250   -1.257
    cia1|t2 (I1T2)   -3.855    0.539   -7.152    0.000   -3.855   -0.923
    cia1|t3 (I1T3)   -0.873    0.444   -1.965    0.049   -0.873   -0.209
    cia2|t1 (I2T1)   -6.156    0.909   -6.772    0.000   -6.156   -1.292
    cia2|t2 (I2T2)   -5.681    0.879   -6.464    0.000   -5.681   -1.192
    cia2|t3 (I2T3)   -3.471    0.728   -4.769    0.000   -3.471   -0.729
    cia3|t1 (I3T1)   -7.009    1.048   -6.687    0.000   -7.009   -1.224
    cia3|t2 (I3T2)   -5.423    0.976   -5.558    0.000   -5.423   -0.947
    cia3|t3 (I3T3)   -1.469    0.648   -2.265    0.024   -1.469   -0.257
    cia4|t1 (I4T1)   -5.397    0.651   -8.295    0.000   -5.397   -1.192
    cia4|t2 (I4T2)   -4.626    0.633   -7.309    0.000   -4.626   -1.022
    cia4|t3 (I4T3)   -2.527    0.560   -4.514    0.000   -2.527   -0.558
    cia5|t1 (I5T1)   -5.064    0.566   -8.949    0.000   -5.064   -1.596
    cia5|t2 (I5T2)   -3.326    0.451   -7.379    0.000   -3.326   -1.048
    cia5|t3 (I5T3)   -1.771    0.380   -4.659    0.000   -1.771   -0.558
    cia6|t1 (I6T1)   -4.562    0.495   -9.225    0.000   -4.562   -1.654
    cia6|t2 (I6T2)   -3.664    0.409   -8.960    0.000   -3.664   -1.328
    cia6|t3 (I6T3)   -2.483    0.385   -6.455    0.000   -2.483   -0.900
    cia7|t1 (I7T1)   -3.368    0.399   -8.434    0.000   -3.368   -2.088
    cia7|t2 (I7T2)   -2.771    0.297   -9.329    0.000   -2.771   -1.717
    cia7|t3 (I7T3)   -2.029    0.248   -8.180    0.000   -2.029   -1.257

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.057
   .cia2              1.000                               1.000    0.044
   .cia3              1.000                               1.000    0.031
   .cia4              1.000                               1.000    0.049
   .cia5              1.000                               1.000    0.099
   .cia6              1.000                               1.000    0.131
   .cia7              1.000                               1.000    0.384
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.239                               0.239    1.000
    cia2              0.210                               0.210    1.000
    cia3              0.175                               0.175    1.000
    cia4              0.221                               0.221    1.000
    cia5              0.315                               0.315    1.000
    cia6              0.363                               0.363    1.000
    cia7              0.620                               0.620    1.000

R-Square:
                   Estimate
    cia1              0.943
    cia2              0.956
    cia3              0.969
    cia4              0.951
    cia5              0.901
    cia6              0.869
    cia7              0.616


Group 2 [female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.054    0.463    8.747    0.000    3.033    0.950
    cia2      (L2)    4.658    0.757    6.153    0.000    3.485    0.961
    cia3      (L3)    5.637    0.931    6.052    0.000    4.218    0.973
    cia4      (L4)    4.415    0.556    7.940    0.000    3.303    0.957
    cia5      (L5)    3.011    0.370    8.145    0.000    2.253    0.914
    cia6      (L6)    2.571    0.316    8.147    0.000    1.923    0.887
    cia7      (L7)    1.266    0.191    6.614    0.000    0.947    0.688

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -4.581    0.370  -12.366    0.000   -4.581   -1.434
    cia1|t2 (I1T2)   -3.362    0.320  -10.519    0.000   -3.362   -1.053
    cia1|t3 (I1T3)   -0.857    0.228   -3.759    0.000   -0.857   -0.268
    cia2|t1 (I2T1)   -5.636    0.633   -8.903    0.000   -5.636   -1.554
    cia2|t2 (I2T2)   -4.774    0.574   -8.321    0.000   -4.774   -1.317
    cia2|t3 (I2T3)   -2.971    0.468   -6.351    0.000   -2.971   -0.819
    cia3|t1 (I3T1)   -6.381    0.741   -8.608    0.000   -6.381   -1.472
    cia3|t2 (I3T2)   -5.510    0.687   -8.025    0.000   -5.510   -1.271
    cia3|t3 (I3T3)   -3.632    0.581   -6.250    0.000   -3.632   -0.838
    cia4|t1 (I4T1)   -4.653    0.392  -11.875    0.000   -4.653   -1.348
    cia4|t2 (I4T2)   -2.924    0.318   -9.209    0.000   -2.924   -0.847
    cia4|t3 (I4T3)   -0.763    0.246   -3.106    0.002   -0.763   -0.221
    cia5|t1 (I5T1)   -3.943    0.307  -12.857    0.000   -3.943   -1.600
    cia5|t2 (I5T2)   -1.931    0.205   -9.412    0.000   -1.931   -0.783
    cia5|t3 (I5T3)   -0.283    0.163   -1.733    0.083   -0.283   -0.115
    cia6|t1 (I6T1)   -3.574    0.289  -12.379    0.000   -3.574   -1.649
    cia6|t2 (I6T2)   -2.410    0.222  -10.844    0.000   -2.410   -1.112
    cia6|t3 (I6T3)   -1.353    0.185   -7.304    0.000   -1.353   -0.624
    cia7|t1 (I7T1)   -3.329    0.308  -10.791    0.000   -3.329   -2.417
    cia7|t2 (I7T2)   -2.674    0.212  -12.596    0.000   -2.674   -1.941
    cia7|t3 (I7T3)   -1.692    0.147  -11.548    0.000   -1.692   -1.228

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.098
   .cia2              1.000                               1.000    0.076
   .cia3              1.000                               1.000    0.053
   .cia4              1.000                               1.000    0.084
   .cia5              1.000                               1.000    0.165
   .cia6              1.000                               1.000    0.213
   .cia7              1.000                               1.000    0.527
    IADL              0.560    0.138    4.048    0.000    1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.313                               0.313    1.000
    cia2              0.276                               0.276    1.000
    cia3              0.231                               0.231    1.000
    cia4              0.290                               0.290    1.000
    cia5              0.406                               0.406    1.000
    cia6              0.461                               0.461    1.000
    cia7              0.726                               0.726    1.000

R-Square:
                   Estimate
    cia1              0.902
    cia2              0.924
    cia3              0.947
    cia4              0.916
    cia5              0.835
    cia6              0.787
    cia7              0.473

To check if the metric invariance model fits as well as the configural model, we can use the anova function:

anova(configuralEstimates, metricEstimates1)
the condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be used
Scaled Chi Square Difference Test (method = "satorra.2000")

                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)
configuralEstimates 28         26.447                              
metricEstimates1    34         42.967     2.0956  1.8595     0.3211

Here, disregard the error text. The p-value is large, so we will claim metric invariance holds and move onto scalar invariance.

Full Threshold Invariance Model (all IFA thresholds held equal across groups, except item 6)

thresholdSyntax1 = "
#============================================================================================================
#Factor loadings (AKA slopes/discriminations) from final metric model
IADL =~ c(L1, L1)*cia1 + c(L2, L2)*cia2 + c(L3, L3)*cia3 + 
        c(L4, L4)*cia4 + c(L5, L5)*cia5 + c(L6, L6)*cia6 + c(L7, L7)*cia7
#============================================================================================================
#Item Thresholds all constrained to be equal across groups except non-invariant item ****
cia1|c(I1T1, I1T1)*t1; cia1|c(I1T2, I1T2)*t2; cia1|c(I1T3, I1T3)*t3;
cia2|c(I2T1, I2T1)*t1; cia2|c(I2T2, I2T2)*t2; cia2|c(I2T3, I2T3)*t3;
cia3|c(I3T1, I3T1)*t1; cia3|c(I3T2, I3T2)*t2; cia3|c(I3T3, I3T3)*t3;
cia4|c(I4T1, I4T1)*t1; cia4|c(I4T2, I4T2)*t2; cia4|c(I4T3, I4T3)*t3;
cia5|c(I5T1, I5T1)*t1; cia5|c(I5T2, I5T2)*t2; cia5|c(I5T3, I5T3)*t3;
cia6|c(I6T1, I6T1)*t1; cia6|c(I6T2, I6T2)*t2; cia6|c(I6T3, I6T3)*t3;
cia7|c(I7T1, I7T1)*t1; cia7|c(I7T2, I7T2)*t2; cia7|c(I7T3, I7T3)*t3;
#============================================================================================================
#Redidual variances all fixed to one for each group
cia1 ~~ c(1, 1)*cia1; cia2 ~~ c(1, 1)*cia2; cia3 ~~ c(1, 1)*cia3; 
cia4 ~~ c(1, 1)*cia4; cia5 ~~ c(1, 1)*cia5; cia6 ~~ c(1, 1)*cia6; cia7 ~~ c(1, 1)*cia7
#============================================================================================================
#Factor variance fixed to 1 for identification in males; estimated for females
IADL ~~ c(1,NA)*IADL
#============================================================================================================
#Factor mean fixed to zero for identification in males; estimated for females ****
IADL ~ c(0,NA)*0
#============================================================================================================
"
thresholdEstimates1 = lavaan(model = thresholdSyntax1, data = iadlData, 
                             ordered = c("cia1", "cia2", "cia3", "cia4", "cia5", "cia6", "cia7"),
                             parameterization="theta", group = "sex")
lavaan WARNING: 40 bivariate tables have empty cells; to see them, use:
                  lavInspect(fit, "zero.cell.tables")
summary(thresholdEstimates1, fit.measures = TRUE, rsquare = TRUE, standardized = TRUE)
lavaan (0.5-23.1097) converged normally after 161 iterations

                                                  Used       Total
  Number of observations per group         
  male                                             163         214
  female                                           383         420

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic               97.897     151.935
  Degrees of freedom                                54          54
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  0.721
  Shift parameter for each group:
    male                                                     4.850
    female                                                  11.396
    for simple second-order correction (Mplus variant)

Chi-square for each group:

  male                                          64.842      94.724
  female                                        33.055      57.211

Model test baseline model:

  Minimum Function Test Statistic            69203.021   35439.603
  Degrees of freedom                                42          42
  P-value                                        0.000       0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    0.999       0.997
  Tucker-Lewis Index (TLI)                       1.000       0.998

  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.055       0.082
  90 Percent Confidence Interval          0.037  0.072       0.066  0.097
  P-value RMSEA <= 0.05                          0.311       0.000

  Robust RMSEA                                                  NA
  90 Percent Confidence Interval                                NA     NA

Standardized Root Mean Square Residual:

  SRMR                                           0.031       0.031

Weighted Root Mean Square Residual:

  WRMR                                           1.527       1.527

Parameter Estimates:

  Information                                 Expected
  Standard Errors                           Robust.sem


Group 1 [male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.093    0.471    8.687    0.000    4.093    0.971
    cia2      (L2)    4.715    0.762    6.190    0.000    4.715    0.978
    cia3      (L3)    5.798    0.967    5.998    0.000    5.798    0.985
    cia4      (L4)    4.465    0.558    8.007    0.000    4.465    0.976
    cia5      (L5)    3.044    0.373    8.152    0.000    3.044    0.950
    cia6      (L6)    2.579    0.316    8.155    0.000    2.579    0.932
    cia7      (L7)    1.283    0.193    6.630    0.000    1.283    0.789

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.386    0.520  -10.358    0.000   -5.386   -1.278
    cia1|t2 (I1T2)   -4.134    0.493   -8.392    0.000   -4.134   -0.981
    cia1|t3 (I1T3)   -1.545    0.444   -3.478    0.001   -1.545   -0.367
    cia2|t1 (I2T1)   -6.512    0.872   -7.467    0.000   -6.512   -1.351
    cia2|t2 (I2T2)   -5.744    0.820   -7.002    0.000   -5.744   -1.192
    cia2|t3 (I2T3)   -3.859    0.715   -5.400    0.000   -3.859   -0.801
    cia3|t1 (I3T1)   -7.560    1.036   -7.295    0.000   -7.560   -1.285
    cia3|t2 (I3T2)   -6.499    0.982   -6.618    0.000   -6.499   -1.105
    cia3|t3 (I3T3)   -4.110    0.836   -4.918    0.000   -4.110   -0.699
    cia4|t1 (I4T1)   -5.543    0.590   -9.392    0.000   -5.543   -1.211
    cia4|t2 (I4T2)   -3.990    0.535   -7.454    0.000   -3.990   -0.872
    cia4|t3 (I4T3)   -1.846    0.498   -3.708    0.000   -1.846   -0.403
    cia5|t1 (I5T1)   -4.674    0.425  -11.002    0.000   -4.674   -1.459
    cia5|t2 (I5T2)   -2.696    0.362   -7.455    0.000   -2.696   -0.841
    cia5|t3 (I5T3)   -1.076    0.331   -3.248    0.001   -1.076   -0.336
    cia6|t1 (I6T1)   -4.178    0.386  -10.838    0.000   -4.178   -1.511
    cia6|t2 (I6T2)   -3.054    0.342   -8.930    0.000   -3.054   -1.104
    cia6|t3 (I6T3)   -1.987    0.320   -6.213    0.000   -1.987   -0.719
    cia7|t1 (I7T1)   -3.521    0.308  -11.434    0.000   -3.521   -2.165
    cia7|t2 (I7T2)   -2.895    0.244  -11.876    0.000   -2.895   -1.780
    cia7|t3 (I7T3)   -1.978    0.196  -10.093    0.000   -1.978   -1.216

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.056
   .cia2              1.000                               1.000    0.043
   .cia3              1.000                               1.000    0.029
   .cia4              1.000                               1.000    0.048
   .cia5              1.000                               1.000    0.097
   .cia6              1.000                               1.000    0.131
   .cia7              1.000                               1.000    0.378
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.237                               0.237    1.000
    cia2              0.207                               0.207    1.000
    cia3              0.170                               0.170    1.000
    cia4              0.219                               0.219    1.000
    cia5              0.312                               0.312    1.000
    cia6              0.362                               0.362    1.000
    cia7              0.615                               0.615    1.000

R-Square:
                   Estimate
    cia1              0.944
    cia2              0.957
    cia3              0.971
    cia4              0.952
    cia5              0.903
    cia6              0.869
    cia7              0.622


Group 2 [female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.093    0.471    8.687    0.000    3.016    0.949
    cia2      (L2)    4.715    0.762    6.190    0.000    3.474    0.961
    cia3      (L3)    5.798    0.967    5.998    0.000    4.272    0.974
    cia4      (L4)    4.465    0.558    8.007    0.000    3.290    0.957
    cia5      (L5)    3.044    0.373    8.152    0.000    2.243    0.913
    cia6      (L6)    2.579    0.316    8.155    0.000    1.900    0.885
    cia7      (L7)    1.283    0.193    6.630    0.000    0.945    0.687

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL             -0.209    0.107   -1.942    0.052   -0.283   -0.283
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.386    0.520  -10.358    0.000   -5.386   -1.695
    cia1|t2 (I1T2)   -4.134    0.493   -8.392    0.000   -4.134   -1.301
    cia1|t3 (I1T3)   -1.545    0.444   -3.478    0.001   -1.545   -0.486
    cia2|t1 (I2T1)   -6.512    0.872   -7.467    0.000   -6.512   -1.801
    cia2|t2 (I2T2)   -5.744    0.820   -7.002    0.000   -5.744   -1.589
    cia2|t3 (I2T3)   -3.859    0.715   -5.400    0.000   -3.859   -1.067
    cia3|t1 (I3T1)   -7.560    1.036   -7.295    0.000   -7.560   -1.723
    cia3|t2 (I3T2)   -6.499    0.982   -6.618    0.000   -6.499   -1.481
    cia3|t3 (I3T3)   -4.110    0.836   -4.918    0.000   -4.110   -0.937
    cia4|t1 (I4T1)   -5.543    0.590   -9.392    0.000   -5.543   -1.612
    cia4|t2 (I4T2)   -3.990    0.535   -7.454    0.000   -3.990   -1.160
    cia4|t3 (I4T3)   -1.846    0.498   -3.708    0.000   -1.846   -0.537
    cia5|t1 (I5T1)   -4.674    0.425  -11.002    0.000   -4.674   -1.903
    cia5|t2 (I5T2)   -2.696    0.362   -7.455    0.000   -2.696   -1.098
    cia5|t3 (I5T3)   -1.076    0.331   -3.248    0.001   -1.076   -0.438
    cia6|t1 (I6T1)   -4.178    0.386  -10.838    0.000   -4.178   -1.946
    cia6|t2 (I6T2)   -3.054    0.342   -8.930    0.000   -3.054   -1.422
    cia6|t3 (I6T3)   -1.987    0.320   -6.213    0.000   -1.987   -0.926
    cia7|t1 (I7T1)   -3.521    0.308  -11.434    0.000   -3.521   -2.559
    cia7|t2 (I7T2)   -2.895    0.244  -11.876    0.000   -2.895   -2.104
    cia7|t3 (I7T3)   -1.978    0.196  -10.093    0.000   -1.978   -1.437

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.099
   .cia2              1.000                               1.000    0.077
   .cia3              1.000                               1.000    0.052
   .cia4              1.000                               1.000    0.085
   .cia5              1.000                               1.000    0.166
   .cia6              1.000                               1.000    0.217
   .cia7              1.000                               1.000    0.528
    IADL              0.543    0.132    4.101    0.000    1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.315                               0.315    1.000
    cia2              0.277                               0.277    1.000
    cia3              0.228                               0.228    1.000
    cia4              0.291                               0.291    1.000
    cia5              0.407                               0.407    1.000
    cia6              0.466                               0.466    1.000
    cia7              0.727                               0.727    1.000

R-Square:
                   Estimate
    cia1              0.901
    cia2              0.923
    cia3              0.948
    cia4              0.915
    cia5              0.834
    cia6              0.783
    cia7              0.472
anova(metricEstimates1, thresholdEstimates1)
the condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be used
Scaled Chi Square Difference Test (method = "satorra.2000")

                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)  
metricEstimates1    34         42.967                                
thresholdEstimates1 54         97.897     8.8105  2.2088    0.01532 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova(configuralEstimates, thresholdEstimates1)
the condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be used
Scaled Chi Square Difference Test (method = "satorra.2000")

                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)
configuralEstimates 28         26.447                              
thresholdEstimates1 54         97.897     4.7991  2.3969     0.1253

The difference tests showed the scalar model fit significantly no worse than the configural model but significantly worse than the metric invariance model, which is an odd finding. That said, we look at the modification indices to see if there are any parameters to free.

thresholdMI1 = modificationindices(thresholdEstimates1, free.remove = FALSE, maximum.number = 10000)
#restrict output to only factor loading parameters
thresholdMI1a = thresholdMI1[which(thresholdMI1$op == "|"),]
thresholdMI1a[order(-thresholdMI1a$mi),]
    lhs op rhs block     mi mi.scaled    epc sepc.lv sepc.all sepc.nox
16 cia3  |  t3     1 19.549    27.096  2.585   2.585    0.439    0.439
67 cia3  |  t3     2  5.856     8.117 -0.774  -0.774   -0.176   -0.176
22 cia5  |  t3     1  4.522     6.267 -0.708  -0.708   -0.221   -0.221
21 cia5  |  t2     1  2.910     4.033 -0.659  -0.659   -0.206   -0.206
24 cia6  |  t2     1  2.642     3.662 -0.617  -0.617   -0.223   -0.223
10 cia1  |  t3     1  2.502     3.468  0.659   0.659    0.157    0.157
25 cia6  |  t3     1  2.500     3.465 -0.499  -0.499   -0.180   -0.180
19 cia4  |  t3     1  2.193     3.039 -0.704  -0.704   -0.154   -0.154
15 cia3  |  t2     1  1.820     2.523  0.921   0.921    0.156    0.156
18 cia4  |  t2     1  1.563     2.167 -0.682  -0.682   -0.149   -0.149
73 cia5  |  t3     2  1.013     1.404  0.159   0.159    0.065    0.065
23 cia6  |  t1     1  0.730     1.012 -0.393  -0.393   -0.142   -0.142
20 cia5  |  t1     1  0.727     1.008 -0.438  -0.438   -0.137   -0.137
61 cia1  |  t3     2  0.612     0.848 -0.161  -0.161   -0.051   -0.051
72 cia5  |  t2     2  0.605     0.839  0.137   0.137    0.056    0.056
66 cia3  |  t2     2  0.568     0.788 -0.287  -0.287   -0.066   -0.066
75 cia6  |  t2     2  0.552     0.764  0.129   0.129    0.060    0.060
76 cia6  |  t3     2  0.548     0.759  0.109   0.109    0.051    0.051
70 cia4  |  t3     2  0.479     0.663  0.154   0.154    0.045    0.045
13 cia2  |  t3     1  0.437     0.606  0.345   0.345    0.072    0.072
69 cia4  |  t2     2  0.332     0.460  0.145   0.145    0.042    0.042
9  cia1  |  t2     1  0.250     0.347  0.242   0.242    0.058    0.058
14 cia3  |  t1     1  0.214     0.296  0.354   0.354    0.060    0.060
11 cia2  |  t1     1  0.189     0.262  0.282   0.282    0.059    0.059
74 cia6  |  t1     2  0.186     0.258  0.100   0.100    0.047    0.047
71 cia5  |  t1     2  0.183     0.253  0.110   0.110    0.045    0.045
27 cia7  |  t2     1  0.128     0.178  0.101   0.101    0.062    0.062
64 cia2  |  t3     2  0.110     0.153 -0.087  -0.087   -0.024   -0.024
26 cia7  |  t1     1  0.107     0.149  0.124   0.124    0.076    0.076
28 cia7  |  t3     1  0.097     0.135 -0.067  -0.067   -0.041   -0.041
60 cia1  |  t2     2  0.067     0.092 -0.065  -0.065   -0.020   -0.020
65 cia3  |  t1     2  0.066     0.091 -0.109  -0.109   -0.025   -0.025
77 cia7  |  t1     2  0.062     0.086 -0.072  -0.072   -0.052   -0.052
62 cia2  |  t1     2  0.061     0.084 -0.091  -0.091   -0.025   -0.025
78 cia7  |  t2     2  0.055     0.076 -0.043  -0.043   -0.031   -0.031
79 cia7  |  t3     2  0.029     0.040  0.020   0.020    0.014    0.014
8  cia1  |  t1     1  0.025     0.034  0.087   0.087    0.021    0.021
17 cia4  |  t1     1  0.022     0.031  0.087   0.087    0.019    0.019
59 cia1  |  t1     2  0.007     0.010 -0.026  -0.026   -0.008   -0.008
68 cia4  |  t1     2  0.006     0.009 -0.024  -0.024   -0.007   -0.007
12 cia2  |  t2     1  0.000     0.000 -0.003  -0.003   -0.001   -0.001
63 cia2  |  t2     2  0.000     0.000  0.001   0.001    0.000    0.000

We see an issue with several items, but we will add one parameter at a time, starting with the third threshold for item 3.

thresholdSyntax2 = "
#============================================================================================================
#Factor loadings (AKA slopes/discriminations) from final metric model
IADL =~ c(L1, L1)*cia1 + c(L2, L2)*cia2 + c(L3, L3)*cia3 + 
        c(L4, L4)*cia4 + c(L5, L5)*cia5 + c(L6, L6)*cia6 + c(L7, L7)*cia7
#============================================================================================================
#Item Thresholds all constrained to be equal across groups except non-invariant item ****
cia1|c(I1T1, I1T1)*t1; cia1|c(I1T2, I1T2)*t2; cia1|c(I1T3, I1T3)*t3;
cia2|c(I2T1, I2T1)*t1; cia2|c(I2T2, I2T2)*t2; cia2|c(I2T3, I2T3)*t3;
cia3|c(I3T1, I3T1)*t1; cia3|c(I3T2, I3T2)*t2; cia3|c(I3T3M, I3T3F)*t3;
cia4|c(I4T1, I4T1)*t1; cia4|c(I4T2, I4T2)*t2; cia4|c(I4T3, I4T3)*t3;
cia5|c(I5T1, I5T1)*t1; cia5|c(I5T2, I5T2)*t2; cia5|c(I5T3, I5T3)*t3;
cia6|c(I6T1, I6T1)*t1; cia6|c(I6T2M, I6T2F)*t2; cia6|c(I6T3M, I6T3F)*t3;
cia7|c(I7T1, I7T1)*t1; cia7|c(I7T2, I7T2)*t2; cia7|c(I7T3, I7T3)*t3;
#============================================================================================================
#Redidual variances all fixed to one for each group
cia1 ~~ c(1, 1)*cia1; cia2 ~~ c(1, 1)*cia2; cia3 ~~ c(1, 1)*cia3; 
cia4 ~~ c(1, 1)*cia4; cia5 ~~ c(1, 1)*cia5; cia6 ~~ c(1, 1)*cia6; cia7 ~~ c(1, 1)*cia7
#============================================================================================================
#Factor variance fixed to 1 for identification in males; estimated for females
IADL ~~ c(1,NA)*IADL
#============================================================================================================
#Factor mean fixed to zero for identification in males; estimated for females ****
IADL ~ c(0,NA)*1
#============================================================================================================
"
thresholdEstimates2 = lavaan(model = thresholdSyntax2, data = iadlData, 
                             ordered = c("cia1", "cia2", "cia3", "cia4", "cia5", "cia6", "cia7"),
                             std.lv = TRUE, parameterization="theta", group = "sex")
lavaan WARNING: 40 bivariate tables have empty cells; to see them, use:
                  lavInspect(fit, "zero.cell.tables")
summary(thresholdEstimates2, fit.measures = TRUE, rsquare = TRUE, standardized = TRUE)
lavaan (0.5-23.1097) converged normally after 167 iterations

                                                  Used       Total
  Number of observations per group         
  male                                             163         214
  female                                           383         420

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic               65.498     105.179
  Degrees of freedom                                51          51
  P-value (Chi-square)                           0.083       0.000
  Scaling correction factor                                  0.729
  Shift parameter for each group:
    male                                                     4.564
    female                                                  10.723
    for simple second-order correction (Mplus variant)

Chi-square for each group:

  male                                          39.524      58.809
  female                                        25.974      46.371

Model test baseline model:

  Minimum Function Test Statistic            69203.021   35439.603
  Degrees of freedom                                42          42
  P-value                                        0.000       0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    1.000       0.998
  Tucker-Lewis Index (TLI)                       1.000       0.999

  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.032       0.062
  90 Percent Confidence Interval          0.000  0.053       0.045  0.079
  P-value RMSEA <= 0.05                          0.912       0.109

  Robust RMSEA                                                  NA
  90 Percent Confidence Interval                                NA     NA

Standardized Root Mean Square Residual:

  SRMR                                           0.031       0.031

Weighted Root Mean Square Residual:

  WRMR                                           1.249       1.249

Parameter Estimates:

  Information                                 Expected
  Standard Errors                           Robust.sem


Group 1 [male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.130    0.479    8.620    0.000    4.130    0.972
    cia2      (L2)    4.778    0.777    6.151    0.000    4.778    0.979
    cia3      (L3)    5.856    0.977    5.993    0.000    5.856    0.986
    cia4      (L4)    4.512    0.567    7.958    0.000    4.512    0.976
    cia5      (L5)    3.077    0.380    8.099    0.000    3.077    0.951
    cia6      (L6)    2.605    0.321    8.112    0.000    2.605    0.934
    cia7      (L7)    1.296    0.196    6.600    0.000    1.296    0.792

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.495    0.530  -10.360    0.000   -5.495   -1.293
    cia1|t2 (I1T2)   -4.247    0.504   -8.419    0.000   -4.247   -0.999
    cia1|t3 (I1T3)   -1.664    0.455   -3.660    0.000   -1.664   -0.392
    cia2|t1 (I2T1)   -6.663    0.903   -7.383    0.000   -6.663   -1.365
    cia2|t2 (I2T2)   -5.895    0.850   -6.934    0.000   -5.895   -1.208
    cia2|t3 (I2T3)   -4.008    0.743   -5.394    0.000   -4.008   -0.821
    cia3|t1 (I3T1)   -7.721    1.058   -7.299    0.000   -7.721   -1.300
    cia3|t2 (I3T2)   -6.662    1.003   -6.642    0.000   -6.662   -1.121
    cia3|t3 (I3T3)   -1.524    0.674   -2.260    0.024   -1.524   -0.257
    cia4|t1 (I4T1)   -5.672    0.606   -9.356    0.000   -5.672   -1.227
    cia4|t2 (I4T2)   -4.122    0.553   -7.457    0.000   -4.122   -0.892
    cia4|t3 (I4T3)   -1.978    0.513   -3.853    0.000   -1.978   -0.428
    cia5|t1 (I5T1)   -4.763    0.435  -10.954    0.000   -4.763   -1.472
    cia5|t2 (I5T2)   -2.787    0.372   -7.485    0.000   -2.787   -0.861
    cia5|t3 (I5T3)   -1.166    0.341   -3.419    0.001   -1.166   -0.360
    cia6|t1 (I6T1)   -4.251    0.393  -10.809    0.000   -4.251   -1.524
    cia6|t2 (I6T2)   -3.707    0.411   -9.025    0.000   -3.707   -1.328
    cia6|t3 (I6T3)   -2.511    0.391   -6.427    0.000   -2.511   -0.900
    cia7|t1 (I7T1)   -3.556    0.313  -11.369    0.000   -3.556   -2.172
    cia7|t2 (I7T2)   -2.931    0.249  -11.770    0.000   -2.931   -1.790
    cia7|t3 (I7T3)   -2.014    0.202   -9.973    0.000   -2.014   -1.230

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.055
   .cia2              1.000                               1.000    0.042
   .cia3              1.000                               1.000    0.028
   .cia4              1.000                               1.000    0.047
   .cia5              1.000                               1.000    0.096
   .cia6              1.000                               1.000    0.128
   .cia7              1.000                               1.000    0.373
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.235                               0.235    1.000
    cia2              0.205                               0.205    1.000
    cia3              0.168                               0.168    1.000
    cia4              0.216                               0.216    1.000
    cia5              0.309                               0.309    1.000
    cia6              0.358                               0.358    1.000
    cia7              0.611                               0.611    1.000

R-Square:
                   Estimate
    cia1              0.945
    cia2              0.958
    cia3              0.972
    cia4              0.953
    cia5              0.904
    cia6              0.872
    cia7              0.627


Group 2 [female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.130    0.479    8.620    0.000    3.002    0.949
    cia2      (L2)    4.778    0.777    6.151    0.000    3.474    0.961
    cia3      (L3)    5.856    0.977    5.993    0.000    4.257    0.974
    cia4      (L4)    4.512    0.567    7.958    0.000    3.280    0.957
    cia5      (L5)    3.077    0.380    8.099    0.000    2.237    0.913
    cia6      (L6)    2.605    0.321    8.112    0.000    1.894    0.884
    cia7      (L7)    1.296    0.196    6.600    0.000    0.942    0.686

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL             -0.242    0.108   -2.248    0.025   -0.333   -0.333
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.495    0.530  -10.360    0.000   -5.495   -1.737
    cia1|t2 (I1T2)   -4.247    0.504   -8.419    0.000   -4.247   -1.342
    cia1|t3 (I1T3)   -1.664    0.455   -3.660    0.000   -1.664   -0.526
    cia2|t1 (I2T1)   -6.663    0.903   -7.383    0.000   -6.663   -1.843
    cia2|t2 (I2T2)   -5.895    0.850   -6.934    0.000   -5.895   -1.631
    cia2|t3 (I2T3)   -4.008    0.743   -5.394    0.000   -4.008   -1.109
    cia3|t1 (I3T1)   -7.721    1.058   -7.299    0.000   -7.721   -1.765
    cia3|t2 (I3T2)   -6.662    1.003   -6.642    0.000   -6.662   -1.523
    cia3|t3 (I3T3)   -5.081    0.916   -5.546    0.000   -5.081   -1.162
    cia4|t1 (I4T1)   -5.672    0.606   -9.356    0.000   -5.672   -1.654
    cia4|t2 (I4T2)   -4.122    0.553   -7.457    0.000   -4.122   -1.202
    cia4|t3 (I4T3)   -1.978    0.513   -3.853    0.000   -1.978   -0.577
    cia5|t1 (I5T1)   -4.763    0.435  -10.954    0.000   -4.763   -1.944
    cia5|t2 (I5T2)   -2.787    0.372   -7.485    0.000   -2.787   -1.137
    cia5|t3 (I5T3)   -1.166    0.341   -3.419    0.001   -1.166   -0.476
    cia6|t1 (I6T1)   -4.251    0.393  -10.809    0.000   -4.251   -1.985
    cia6|t2 (I6T2)   -3.011    0.357   -8.443    0.000   -3.011   -1.406
    cia6|t3 (I6T3)   -1.967    0.333   -5.905    0.000   -1.967   -0.918
    cia7|t1 (I7T1)   -3.556    0.313  -11.369    0.000   -3.556   -2.588
    cia7|t2 (I7T2)   -2.931    0.249  -11.770    0.000   -2.931   -2.133
    cia7|t3 (I7T3)   -2.014    0.202   -9.973    0.000   -2.014   -1.466

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.100
   .cia2              1.000                               1.000    0.077
   .cia3              1.000                               1.000    0.052
   .cia4              1.000                               1.000    0.085
   .cia5              1.000                               1.000    0.167
   .cia6              1.000                               1.000    0.218
   .cia7              1.000                               1.000    0.530
    IADL              0.529    0.129    4.087    0.000    1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.316                               0.316    1.000
    cia2              0.277                               0.277    1.000
    cia3              0.229                               0.229    1.000
    cia4              0.292                               0.292    1.000
    cia5              0.408                               0.408    1.000
    cia6              0.467                               0.467    1.000
    cia7              0.728                               0.728    1.000

R-Square:
                   Estimate
    cia1              0.900
    cia2              0.923
    cia3              0.948
    cia4              0.915
    cia5              0.833
    cia6              0.782
    cia7              0.470
anova(metricEstimates1, thresholdEstimates2)
the condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be used
Scaled Chi Square Difference Test (method = "satorra.2000")

                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)
metricEstimates1    34         42.967                              
thresholdEstimates2 51         65.498      3.951  2.0848     0.1484
anova(configuralEstimates, thresholdEstimates2)
the condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be used
Scaled Chi Square Difference Test (method = "satorra.2000")

                    Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)
configuralEstimates 28         26.447                              
thresholdEstimates2 51         65.498     2.9814  2.5016     0.3087

The difference tests showed the scalar model did not fit significantly worse than both the configural model and the metric invariance model. We will now move on to test residual invariance.

Partial Residual Variance Invariance Model (thresholds unconstrained between groups)

Because lavaan does not function like Mplus, we cannot execute this step. We will move onto the test for the structural model.

Structural Model Invariance: Factor Variance

To test the equality of factor variance across groups, we use our last model and constrain the factor variance.

factorVarSyntax = "
#============================================================================================================
#Factor loadings (AKA slopes/discriminations) from final metric model
IADL =~ c(L1, L1)*cia1 + c(L2, L2)*cia2 + c(L3, L3)*cia3 + 
        c(L4, L4)*cia4 + c(L5, L5)*cia5 + c(L6, L6)*cia6 + c(L7, L7)*cia7
#============================================================================================================
#Item Thresholds all constrained to be equal across groups except non-invariant item
cia1|c(I1T1, I1T1)*t1; cia1|c(I1T2, I1T2)*t2; cia1|c(I1T3, I1T3)*t3;
cia2|c(I2T1, I2T1)*t1; cia2|c(I2T2, I2T2)*t2; cia2|c(I2T3, I2T3)*t3;
cia3|c(I3T1, I3T1)*t1; cia3|c(I3T2, I3T2)*t2; cia3|c(I3T3M, I3T3F)*t3;
cia4|c(I4T1, I4T1)*t1; cia4|c(I4T2, I4T2)*t2; cia4|c(I4T3, I4T3)*t3;
cia5|c(I5T1, I5T1)*t1; cia5|c(I5T2, I5T2)*t2; cia5|c(I5T3, I5T3)*t3;
cia6|c(I6T1, I6T1)*t1; cia6|c(I6T2M, I6T2F)*t2; cia6|c(I6T3M, I6T3F)*t3;
cia7|c(I7T1, I7T1)*t1; cia7|c(I7T2, I7T2)*t2; cia7|c(I7T3, I7T3)*t3;
#============================================================================================================
#Redidual variances all fixed to one for each group
cia1 ~~ c(1, 1)*cia1; cia2 ~~ c(1, 1)*cia2; cia3 ~~ c(1, 1)*cia3; 
cia4 ~~ c(1, 1)*cia4; cia5 ~~ c(1, 1)*cia5; cia6 ~~ c(1, 1)*cia6; cia7 ~~ c(1, 1)*cia7
#============================================================================================================
#Factor variance fixed to 1 for identification in males; estimated for females ****
IADL ~~ c(1,1)*IADL
#============================================================================================================
#Factor mean fixed to zero for identification in males; estimated for females
IADL ~ c(0,NA)*0
#============================================================================================================
"
factorVarEstimates = lavaan(model = factorVarSyntax, data = iadlData, 
                             ordered = c("cia1", "cia2", "cia3", "cia4", "cia5", "cia6", "cia7"),
                             std.lv = TRUE, parameterization="theta", group = "sex")
lavaan WARNING: 40 bivariate tables have empty cells; to see them, use:
                  lavInspect(fit, "zero.cell.tables")
summary(factorVarEstimates, fit.measures = TRUE, rsquare = TRUE, standardized = TRUE)
lavaan (0.5-23.1097) converged normally after 144 iterations

                                                  Used       Total
  Number of observations per group         
  male                                             163         214
  female                                           383         420

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic              125.625     133.981
  Degrees of freedom                                52          52
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  1.117
  Shift parameter for each group:
    male                                                     6.428
    female                                                  15.105
    for simple second-order correction (Mplus variant)

Chi-square for each group:

  male                                          65.439      65.003
  female                                        60.186      68.978

Model test baseline model:

  Minimum Function Test Statistic            69203.021   35439.603
  Degrees of freedom                                42          42
  P-value                                        0.000       0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    0.999       0.998
  Tucker-Lewis Index (TLI)                       0.999       0.998

  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.072       0.076
  90 Percent Confidence Interval          0.056  0.088       0.060  0.092
  P-value RMSEA <= 0.05                          0.013       0.004

  Robust RMSEA                                                  NA
  90 Percent Confidence Interval                                NA     NA

Standardized Root Mean Square Residual:

  SRMR                                           0.039       0.039

Weighted Root Mean Square Residual:

  WRMR                                           1.729       1.729

Parameter Estimates:

  Information                                 Expected
  Standard Errors                           Robust.sem


Group 1 [male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    3.604    0.301   11.975    0.000    3.604    0.964
    cia2      (L2)    3.762    0.490    7.680    0.000    3.762    0.966
    cia3      (L3)    4.184    0.487    8.589    0.000    4.184    0.973
    cia4      (L4)    3.721    0.349   10.671    0.000    3.721    0.966
    cia5      (L5)    2.479    0.207   11.965    0.000    2.479    0.927
    cia6      (L6)    2.335    0.242    9.642    0.000    2.335    0.919
    cia7      (L7)    1.042    0.130    8.020    0.000    1.042    0.721

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.139    0.469  -10.969    0.000   -5.139   -1.374
    cia1|t2 (I1T2)   -3.781    0.428   -8.836    0.000   -3.781   -1.011
    cia1|t3 (I1T3)   -0.935    0.374   -2.501    0.012   -0.935   -0.250
    cia2|t1 (I2T1)   -5.678    0.705   -8.053    0.000   -5.678   -1.458
    cia2|t2 (I2T2)   -4.966    0.660   -7.522    0.000   -4.966   -1.276
    cia2|t3 (I2T3)   -3.078    0.560   -5.497    0.000   -3.078   -0.791
    cia3|t1 (I3T1)   -5.952    0.659   -9.027    0.000   -5.952   -1.383
    cia3|t2 (I3T2)   -4.966    0.621   -7.992    0.000   -4.966   -1.154
    cia3|t3 (I3T3)   -1.104    0.460   -2.399    0.016   -1.104   -0.257
    cia4|t1 (I4T1)   -4.994    0.512   -9.762    0.000   -4.994   -1.296
    cia4|t2 (I4T2)   -3.446    0.461   -7.468    0.000   -3.446   -0.894
    cia4|t3 (I4T3)   -1.210    0.414   -2.923    0.003   -1.210   -0.314
    cia5|t1 (I5T1)   -4.272    0.365  -11.719    0.000   -4.272   -1.598
    cia5|t2 (I5T2)   -2.277    0.302   -7.531    0.000   -2.277   -0.852
    cia5|t3 (I5T3)   -0.632    0.274   -2.306    0.021   -0.632   -0.236
    cia6|t1 (I6T1)   -4.191    0.403  -10.401    0.000   -4.191   -1.650
    cia6|t2 (I6T2)   -3.375    0.396   -8.521    0.000   -3.375   -1.328
    cia6|t3 (I6T3)   -2.286    0.355   -6.440    0.000   -2.286   -0.900
    cia7|t1 (I7T1)   -3.278    0.277  -11.815    0.000   -3.278   -2.270
    cia7|t2 (I7T2)   -2.682    0.216  -12.434    0.000   -2.682   -1.857
    cia7|t3 (I7T3)   -1.785    0.169  -10.561    0.000   -1.785   -1.236

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.071
   .cia2              1.000                               1.000    0.066
   .cia3              1.000                               1.000    0.054
   .cia4              1.000                               1.000    0.067
   .cia5              1.000                               1.000    0.140
   .cia6              1.000                               1.000    0.155
   .cia7              1.000                               1.000    0.480
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.267                               0.267    1.000
    cia2              0.257                               0.257    1.000
    cia3              0.232                               0.232    1.000
    cia4              0.260                               0.260    1.000
    cia5              0.374                               0.374    1.000
    cia6              0.394                               0.394    1.000
    cia7              0.692                               0.692    1.000

R-Square:
                   Estimate
    cia1              0.929
    cia2              0.934
    cia3              0.946
    cia4              0.933
    cia5              0.860
    cia6              0.845
    cia7              0.520


Group 2 [female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    3.604    0.301   11.975    0.000    3.604    0.964
    cia2      (L2)    3.762    0.490    7.680    0.000    3.762    0.966
    cia3      (L3)    4.184    0.487    8.589    0.000    4.184    0.973
    cia4      (L4)    3.721    0.349   10.671    0.000    3.721    0.966
    cia5      (L5)    2.479    0.207   11.965    0.000    2.479    0.927
    cia6      (L6)    2.335    0.242    9.642    0.000    2.335    0.919
    cia7      (L7)    1.042    0.130    8.020    0.000    1.042    0.721

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.001    0.120    0.008    0.993    0.001    0.001
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.139    0.469  -10.969    0.000   -5.139   -1.374
    cia1|t2 (I1T2)   -3.781    0.428   -8.836    0.000   -3.781   -1.011
    cia1|t3 (I1T3)   -0.935    0.374   -2.501    0.012   -0.935   -0.250
    cia2|t1 (I2T1)   -5.678    0.705   -8.053    0.000   -5.678   -1.458
    cia2|t2 (I2T2)   -4.966    0.660   -7.522    0.000   -4.966   -1.276
    cia2|t3 (I2T3)   -3.078    0.560   -5.497    0.000   -3.078   -0.791
    cia3|t1 (I3T1)   -5.952    0.659   -9.027    0.000   -5.952   -1.383
    cia3|t2 (I3T2)   -4.966    0.621   -7.992    0.000   -4.966   -1.154
    cia3|t3 (I3T3)   -3.601    0.603   -5.976    0.000   -3.601   -0.837
    cia4|t1 (I4T1)   -4.994    0.512   -9.762    0.000   -4.994   -1.296
    cia4|t2 (I4T2)   -3.446    0.461   -7.468    0.000   -3.446   -0.894
    cia4|t3 (I4T3)   -1.210    0.414   -2.923    0.003   -1.210   -0.314
    cia5|t1 (I5T1)   -4.272    0.365  -11.719    0.000   -4.272   -1.598
    cia5|t2 (I5T2)   -2.277    0.302   -7.531    0.000   -2.277   -0.852
    cia5|t3 (I5T3)   -0.632    0.274   -2.306    0.021   -0.632   -0.236
    cia6|t1 (I6T1)   -4.191    0.403  -10.401    0.000   -4.191   -1.650
    cia6|t2 (I6T2)   -2.822    0.348   -8.099    0.000   -2.822   -1.111
    cia6|t3 (I6T3)   -1.583    0.312   -5.066    0.000   -1.583   -0.623
    cia7|t1 (I7T1)   -3.278    0.277  -11.815    0.000   -3.278   -2.270
    cia7|t2 (I7T2)   -2.682    0.216  -12.434    0.000   -2.682   -1.857
    cia7|t3 (I7T3)   -1.785    0.169  -10.561    0.000   -1.785   -1.236

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.071
   .cia2              1.000                               1.000    0.066
   .cia3              1.000                               1.000    0.054
   .cia4              1.000                               1.000    0.067
   .cia5              1.000                               1.000    0.140
   .cia6              1.000                               1.000    0.155
   .cia7              1.000                               1.000    0.480
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.267                               0.267    1.000
    cia2              0.257                               0.257    1.000
    cia3              0.232                               0.232    1.000
    cia4              0.260                               0.260    1.000
    cia5              0.374                               0.374    1.000
    cia6              0.394                               0.394    1.000
    cia7              0.692                               0.692    1.000

R-Square:
                   Estimate
    cia1              0.929
    cia2              0.934
    cia3              0.946
    cia4              0.933
    cia5              0.860
    cia6              0.845
    cia7              0.520
anova(thresholdEstimates2, factorVarEstimates)
the condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be used
Scaled Chi Square Difference Test (method = "satorra.2000")

                    Df AIC BIC   Chisq Chisq diff Df diff Pr(>Chisq)  
thresholdEstimates2 51          65.498                                
factorVarEstimates  52         125.625     4.2538 0.55946    0.01708 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova(configuralEstimates, factorVarEstimates)
the condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be usedthe condition has length > 1 and only the first element will be used
Scaled Chi Square Difference Test (method = "satorra.2000")

                    Df AIC BIC   Chisq Chisq diff Df diff Pr(>Chisq)  
configuralEstimates 28          26.447                                
factorVarEstimates  52         125.625     7.5719  2.5016    0.03695 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

As the factor variance model fit significantly worse than the configural and last threshold model, we can conclude the factor variances are different.

To test the factor mean, we only need to look at the Wald test for the factor means from the last threshold model:

summary(thresholdEstimates2, fit.measures = TRUE, rsquare = TRUE, standardized = TRUE)
lavaan (0.5-23.1097) converged normally after 167 iterations

                                                  Used       Total
  Number of observations per group         
  male                                             163         214
  female                                           383         420

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic               65.498     105.179
  Degrees of freedom                                51          51
  P-value (Chi-square)                           0.083       0.000
  Scaling correction factor                                  0.729
  Shift parameter for each group:
    male                                                     4.564
    female                                                  10.723
    for simple second-order correction (Mplus variant)

Chi-square for each group:

  male                                          39.524      58.809
  female                                        25.974      46.371

Model test baseline model:

  Minimum Function Test Statistic            69203.021   35439.603
  Degrees of freedom                                42          42
  P-value                                        0.000       0.000

User model versus baseline model:

  Comparative Fit Index (CFI)                    1.000       0.998
  Tucker-Lewis Index (TLI)                       1.000       0.999

  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.032       0.062
  90 Percent Confidence Interval          0.000  0.053       0.045  0.079
  P-value RMSEA <= 0.05                          0.912       0.109

  Robust RMSEA                                                  NA
  90 Percent Confidence Interval                                NA     NA

Standardized Root Mean Square Residual:

  SRMR                                           0.031       0.031

Weighted Root Mean Square Residual:

  WRMR                                           1.249       1.249

Parameter Estimates:

  Information                                 Expected
  Standard Errors                           Robust.sem


Group 1 [male]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.130    0.479    8.620    0.000    4.130    0.972
    cia2      (L2)    4.778    0.777    6.151    0.000    4.778    0.979
    cia3      (L3)    5.856    0.977    5.993    0.000    5.856    0.986
    cia4      (L4)    4.512    0.567    7.958    0.000    4.512    0.976
    cia5      (L5)    3.077    0.380    8.099    0.000    3.077    0.951
    cia6      (L6)    2.605    0.321    8.112    0.000    2.605    0.934
    cia7      (L7)    1.296    0.196    6.600    0.000    1.296    0.792

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL              0.000                               0.000    0.000
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.495    0.530  -10.360    0.000   -5.495   -1.293
    cia1|t2 (I1T2)   -4.247    0.504   -8.419    0.000   -4.247   -0.999
    cia1|t3 (I1T3)   -1.664    0.455   -3.660    0.000   -1.664   -0.392
    cia2|t1 (I2T1)   -6.663    0.903   -7.383    0.000   -6.663   -1.365
    cia2|t2 (I2T2)   -5.895    0.850   -6.934    0.000   -5.895   -1.208
    cia2|t3 (I2T3)   -4.008    0.743   -5.394    0.000   -4.008   -0.821
    cia3|t1 (I3T1)   -7.721    1.058   -7.299    0.000   -7.721   -1.300
    cia3|t2 (I3T2)   -6.662    1.003   -6.642    0.000   -6.662   -1.121
    cia3|t3 (I3T3)   -1.524    0.674   -2.260    0.024   -1.524   -0.257
    cia4|t1 (I4T1)   -5.672    0.606   -9.356    0.000   -5.672   -1.227
    cia4|t2 (I4T2)   -4.122    0.553   -7.457    0.000   -4.122   -0.892
    cia4|t3 (I4T3)   -1.978    0.513   -3.853    0.000   -1.978   -0.428
    cia5|t1 (I5T1)   -4.763    0.435  -10.954    0.000   -4.763   -1.472
    cia5|t2 (I5T2)   -2.787    0.372   -7.485    0.000   -2.787   -0.861
    cia5|t3 (I5T3)   -1.166    0.341   -3.419    0.001   -1.166   -0.360
    cia6|t1 (I6T1)   -4.251    0.393  -10.809    0.000   -4.251   -1.524
    cia6|t2 (I6T2)   -3.707    0.411   -9.025    0.000   -3.707   -1.328
    cia6|t3 (I6T3)   -2.511    0.391   -6.427    0.000   -2.511   -0.900
    cia7|t1 (I7T1)   -3.556    0.313  -11.369    0.000   -3.556   -2.172
    cia7|t2 (I7T2)   -2.931    0.249  -11.770    0.000   -2.931   -1.790
    cia7|t3 (I7T3)   -2.014    0.202   -9.973    0.000   -2.014   -1.230

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.055
   .cia2              1.000                               1.000    0.042
   .cia3              1.000                               1.000    0.028
   .cia4              1.000                               1.000    0.047
   .cia5              1.000                               1.000    0.096
   .cia6              1.000                               1.000    0.128
   .cia7              1.000                               1.000    0.373
    IADL              1.000                               1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.235                               0.235    1.000
    cia2              0.205                               0.205    1.000
    cia3              0.168                               0.168    1.000
    cia4              0.216                               0.216    1.000
    cia5              0.309                               0.309    1.000
    cia6              0.358                               0.358    1.000
    cia7              0.611                               0.611    1.000

R-Square:
                   Estimate
    cia1              0.945
    cia2              0.958
    cia3              0.972
    cia4              0.953
    cia5              0.904
    cia6              0.872
    cia7              0.627


Group 2 [female]:

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IADL =~                                                               
    cia1      (L1)    4.130    0.479    8.620    0.000    3.002    0.949
    cia2      (L2)    4.778    0.777    6.151    0.000    3.474    0.961
    cia3      (L3)    5.856    0.977    5.993    0.000    4.257    0.974
    cia4      (L4)    4.512    0.567    7.958    0.000    3.280    0.957
    cia5      (L5)    3.077    0.380    8.099    0.000    2.237    0.913
    cia6      (L6)    2.605    0.321    8.112    0.000    1.894    0.884
    cia7      (L7)    1.296    0.196    6.600    0.000    0.942    0.686

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    IADL             -0.242    0.108   -2.248    0.025   -0.333   -0.333
   .cia1              0.000                               0.000    0.000
   .cia2              0.000                               0.000    0.000
   .cia3              0.000                               0.000    0.000
   .cia4              0.000                               0.000    0.000
   .cia5              0.000                               0.000    0.000
   .cia6              0.000                               0.000    0.000
   .cia7              0.000                               0.000    0.000

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1|t1 (I1T1)   -5.495    0.530  -10.360    0.000   -5.495   -1.737
    cia1|t2 (I1T2)   -4.247    0.504   -8.419    0.000   -4.247   -1.342
    cia1|t3 (I1T3)   -1.664    0.455   -3.660    0.000   -1.664   -0.526
    cia2|t1 (I2T1)   -6.663    0.903   -7.383    0.000   -6.663   -1.843
    cia2|t2 (I2T2)   -5.895    0.850   -6.934    0.000   -5.895   -1.631
    cia2|t3 (I2T3)   -4.008    0.743   -5.394    0.000   -4.008   -1.109
    cia3|t1 (I3T1)   -7.721    1.058   -7.299    0.000   -7.721   -1.765
    cia3|t2 (I3T2)   -6.662    1.003   -6.642    0.000   -6.662   -1.523
    cia3|t3 (I3T3)   -5.081    0.916   -5.546    0.000   -5.081   -1.162
    cia4|t1 (I4T1)   -5.672    0.606   -9.356    0.000   -5.672   -1.654
    cia4|t2 (I4T2)   -4.122    0.553   -7.457    0.000   -4.122   -1.202
    cia4|t3 (I4T3)   -1.978    0.513   -3.853    0.000   -1.978   -0.577
    cia5|t1 (I5T1)   -4.763    0.435  -10.954    0.000   -4.763   -1.944
    cia5|t2 (I5T2)   -2.787    0.372   -7.485    0.000   -2.787   -1.137
    cia5|t3 (I5T3)   -1.166    0.341   -3.419    0.001   -1.166   -0.476
    cia6|t1 (I6T1)   -4.251    0.393  -10.809    0.000   -4.251   -1.985
    cia6|t2 (I6T2)   -3.011    0.357   -8.443    0.000   -3.011   -1.406
    cia6|t3 (I6T3)   -1.967    0.333   -5.905    0.000   -1.967   -0.918
    cia7|t1 (I7T1)   -3.556    0.313  -11.369    0.000   -3.556   -2.588
    cia7|t2 (I7T2)   -2.931    0.249  -11.770    0.000   -2.931   -2.133
    cia7|t3 (I7T3)   -2.014    0.202   -9.973    0.000   -2.014   -1.466

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .cia1              1.000                               1.000    0.100
   .cia2              1.000                               1.000    0.077
   .cia3              1.000                               1.000    0.052
   .cia4              1.000                               1.000    0.085
   .cia5              1.000                               1.000    0.167
   .cia6              1.000                               1.000    0.218
   .cia7              1.000                               1.000    0.530
    IADL              0.529    0.129    4.087    0.000    1.000    1.000

Scales y*:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
    cia1              0.316                               0.316    1.000
    cia2              0.277                               0.277    1.000
    cia3              0.229                               0.229    1.000
    cia4              0.292                               0.292    1.000
    cia5              0.408                               0.408    1.000
    cia6              0.467                               0.467    1.000
    cia7              0.728                               0.728    1.000

R-Square:
                   Estimate
    cia1              0.900
    cia2              0.923
    cia3              0.948
    cia4              0.915
    cia5              0.833
    cia6              0.782
    cia7              0.470

Here, we see the estimate of the factor mean for the female group was .611, which was significant (p < .01). Therefore we determine that the female group has a significantly higher mean than the male group, indicating that on average, females are more able to perform the activities noted on the scale.

Example write-up of these IFA analyses

The extent to which am item factor model measuring independent daily living (with seven observed items) exhibited measurement invariance and structural invariance between men and women was examined using the lavaan package (Rosseel, 2012) in R (R Core Team, 2017). WLSMV estimation including a probit link and the THETA parameterization was used to estimate all models. Thus, model fit statistics describe the fit of the item factor model to the polychoric correlation matrix among the items for each group. Nested model comparisons were conducted using the DIFFTEST procedure included in the package. A configural invariance model was initially specified in which a single factor was estimated simultaneously in each group. The factor variance was fixed to 1 and the factor mean was fixed to 0 in each group for identification, such that all item factor loadings (one per item) and thresholds (three per item given four response options) were then estimated. The residual variances are not uniquely identified in the configural invariance model and as such were all constrained to 1 in both groups. As shown in Table 1, the configural invariance model had good fit. The analysis proceeded by applying parameter constraints in successive models to examine potential decreases in fit resulting from measurement or structural non-invariance between men and women, with men as the reference group.

Equality of the unstandardized item factor loadings between groups was then examined in a metric invariance model. The factor variance was fixed to 1 in men for identification but was freely estimated in women; the factor mean was fixed to 0 in both groups for identification. All factor loadings were constrained equal across groups, all item thresholds were estimated, and all residual variances were constrained to 1 across groups. The metric invariance model did not fit significantly worse than the configural invariance model, DIFFTEST (df = 1.86) = 2.10, p = .32. Therefore, we concluded there was full metric invariance between groups.

Equality of the unstandardized item thresholds across groups was then examined in a scalar invariance model. The factor mean and variance were fixed to 0 and 1, respectively, in men for identification, but the factor mean and variance were then estimated for women. All factor loadings and all item thresholds were constrained equal across groups; all residual variances were still constrained equal to 1 in both groups. The full scalar invariance model A fit significantly worse than the partial metric invariance model, DIFFTEST (2.21) = 8.81 p = .015. Modification indices indicted that the third threshold for item three was a source of misfit. After freeing item 3’s third threshold, the partial scalar invariance model B fit as well as the partial metric invariance model, DIFFTEST (2.08) = 3.95, p = .15.

After achieving partial measurement invariance as was just described, structural invariance was then tested with one additional model. The factor variance in the women (which had been estimated freely) was constrained to 1 (i.e., to be equal to the factor variance in men), resulting in a significant decrease in fit relative to the last partial residual invariance model B, DIFFTEST (.56) = 4.25, p = .02. Thus, women showed significantly less variability in ability to live independently (factor variance of 0.552) than did men (factor variance fixed = 1). The factor mean for women in the partial measurement invariance model was significantly different from 0 (difference = −0.242, SE = 0.11, p < .01), indicating that women were marginally less able to live independently than men (factor mean fixed = 0).

In conclusion, these analyses showed that partial measurement invariance was obtained across men and women-that is, the relationships of the items to the latent factor of independent living were equivalent between men women. Structural invariance was not obtained, such that women were less variable and less able on average than men. Model parameters from the final model are given in Table 2.

(Table 1 would have model comparison tests; Table 2 would have unstandardized and standardized estimates and their SEs)

LS0tCnRpdGxlOiAiRVBTWSA5MDYvQ0xEUCA5NDggRXhhbXBsZSA3QjogTXVsdGlwbGUgR3JvdXAgSW52YXJpYW5jZSB3aXRoIElGQS9JUlQgYW5kIFdMU01WIgpvdXRwdXQ6CiAgaHRtbF9ub3RlYm9vazogZGVmYXVsdAogIGh0bWxfZG9jdW1lbnQ6IGRlZmF1bHQKLS0tCgojIyBUZXN0aW5nIE11bHRpcGxlLUdyb3VwIE1lYXN1cmVtZW50IEludmFyaWFuY2UgdXNpbmcgV0xTTVYgaW4gSXRlbSBGYWN0b3IgTW9kZWxzIGluIGBsYXZhYW5gCgpgYGB7ciBzZXR1cCwgaW5jbHVkZT1UUlVFfQppZiAoIXJlcXVpcmUobGF2YWFuKSkgaW5zdGFsbC5wYWNrYWdlcygibGF2YWFuIikKbGlicmFyeShsYXZhYW4pCmBgYAoKRXhhbXBsZSBkYXRhOiA2MzQgb2xkZXIgYWR1bHRzIChhZ2UgODAtMTAwKSBzZWxmLXJlcG9ydGluZyBvbiA3IGl0ZW1zIGFzc2Vzc2luZyB0aGUgSW5zdHJ1bWVudGFsIEFjdGl2aXRpZXMgb2YgRGFpbHkgTGl2aW5nIChJQURMKSBhcyBmb2xsb3dzOgoKMS4gSG91c2V3b3JrIChjbGVhbmluZyBhbmQgbGF1bmRyeSk6IDE9NjQlCjIuIEJlZG1ha2luZzogMT04NCUK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uY2UgZml4ZWQgdG8gMSBmb3IgaWRlbnRpZmljYXRpb24gaW4gZWFjaCBncm91cApJQURMIH5+IGMoMSwxKSpJQURMCgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNGYWN0b3IgbWVhbiBmaXhlZCB0byB6ZXJvIGZvciBpZGVudGlmaWNhdGlvbiBpbiBlYWNoIGdyb3VwCklBREwgfiBjKDAsMCkqMAoKIz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQoiCgpjb25maWd1cmFsRXN0aW1hdGVzID0gbGF2YWFuKG1vZGVsID0gY29uZmlndXJhbFN5bnRheCwgZGF0YSA9IGlhZGxEYXRhLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcmRlcmVkID0gYygiY2lhMSIsICJjaWEyIiwgImNpYTMiLCAiY2lhNCIsICJjaWE1IiwgImNpYTYiLCAiY2lhNyIpLCBzdGQubHYgPSBUUlVFLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJpemF0aW9uPSJ0aGV0YSIsIGdyb3VwID0gInNleCIpCnN1bW1hcnkoY29uZmlndXJhbEVzdGltYXRlcywgZml0Lm1lYXN1cmVzID0gVFJVRSwgcnNxdWFyZSA9IFRSVUUsIHN0YW5kYXJkaXplZCA9IFRSVUUpCgpgYGAKCiMjIyBNZXRyaWMgSW52YXJpYW5jZSBNb2RlbHMKCkhlcmUgdGhlIElGQSBmYWN0b3IgbG9hZGluZ3MgYXJlIGhlbGQgZXF1YWwgYWNyb3NzIGdyb3VwcyBidXQgdGhlIGZhY3RvciB2YXJpYW5jZSBpcyBmcmVlZC4KCmBgYHtyIG1ldHJpYzEsIGluY2x1ZGU9V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0sIEk0VDJGKSp0MjsgY2lhNHxjKEk0VDNNLCBJNFQzRikqdDM7CmNpYTV8YyhJNVQxTSwgSTVUMUYpKnQxOyBjaWE1fGMoSTVUMk0sIEk1VDJGKSp0MjsgY2lhNXxjKEk1VDNNLCBJNVQzRikqdDM7CmNpYTZ8YyhJNlQxTSwgSTZUMUYpKnQxOyBjaWE2fGMoSTZUMk0sIEk2VDJGKSp0MjsgY2lhNnxjKEk2VDNNLCBJNlQzRikqdDM7CmNpYTd8YyhJN1QxTSwgSTdUMUYpKnQxOyBjaWE3fGMoSTdUMk0sIEk3VDJGKSp0MjsgY2lhN3xjKEk3VDNNLCBJN1QzRikqdDM7CgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNSZWRpZHVhbCB2YXJpYW5jZXMgYWxsIGZpeGVkIHRvIG9uZSBmb3IgZWFjaCBncm91cApjaWExIH5+IGMoMSwgMSkqY2lhMTsgY2lhMiB+fiBjKDEsIDEpKmNpYTI7IGNpYTMgfn4gYygxLCAxKSpjaWEzOyAKY2lhNCB+fiBjKDEsIDEpKmNpYTQ7IGNpYTUgfn4gYygxLCAxKSpjaWE1OyBjaWE2IH5+IGMoMSwgMSkqY2lhNjsgY2lhNyB+fiBjKDEsIDEpKmNpYTcKCiM9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KI0ZhY3RvciB2YXJpYW5jZSBmaXhlZCB0byAxIGZvciBpZGVudGlmaWNhdGlvbiBpbiBncm91cDE7IGVzdGltYXRlZCBmb3IgZ3JvdXAgMgpJQURMIH5+IGMoMSxOQSkqSUFETAoKIz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT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BzY2FsYXIgaW52YXJpYW5jZS4KCiMjIyBGdWxsIFRocmVzaG9sZCBJbnZhcmlhbmNlIE1vZGVsIChhbGwgSUZBIHRocmVzaG9sZHMgaGVsZCBlcXVhbCBhY3Jvc3MgZ3JvdXBzLCBleGNlcHQgaXRlbSA2KQoKYGBge3IgdGhyZXNob2xkMSwgaW5jbHVkZT1UUlVFfQp0aHJlc2hvbGRTeW50YXgxID0gIgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNGYWN0b3IgbG9hZGluZ3MgKEFLQSBzbG9wZXMvZGlzY3JpbWluYXRpb25zKSBmcm9tIGZpbmFsIG1ldHJpYyBtb2RlbApJQURMID1+IGMoTDEsIEwxKSpjaWExICsgYyhMMiwgTDIpKmNpYTIgKyBjKEwzLCBMMykqY2lhMyArIAogICAgICAgIGMoTDQsIEw0KSpjaWE0ICsgYyhMNSwgTDUpKmNpYTUgKyBjKEw2LCBMNikqY2lhNiArIGMoTDcsIEw3KSpjaWE3CgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNJdGVtIFRocmVzaG9sZHMgYWxsIGNvbnN0cmFpbmVkIHRvIGJlIGVxdWFsIGFjcm9zcyBncm91cHMgZXhjZXB0IG5vbi1pbnZhcmlhbnQgaXRlbSAqKioqCmNpYTF8YyhJMVQxLCBJMVQxKSp0MTsgY2lhMXxjKEkxVDIsIEkxVDIpKnQyOyBjaWExfGMoSTFUMywgSTFUMykqdDM7CmNpYTJ8YyhJMlQxLCBJMlQxKSp0MTsgY2lhMnxjKEkyVDIsIEkyVDIpKnQyOyBjaWEyfGMoSTJUMywgSTJUMykqdDM7CmNpYTN8YyhJM1QxLCBJM1QxKSp0M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4gYygxLE5BKSpJQURMCgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNGYWN0b3IgbWVhbiBmaXhlZCB0byB6ZXJvIGZvciBpZGVudGlmaWNhdGlvbiBpbiBtYWxlczsgZXN0aW1hdGVkIGZvciBmZW1hbGVzICoqKioKSUFETCB+IGMoMCxOQSkqMAoKIz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQoiCgp0aHJlc2hvbGRFc3RpbWF0ZXMxID0gbGF2YWFuKG1vZGVsID0gdGhyZXNob2xkU3ludGF4MSwgZGF0YSA9IGlhZGxEYXRhLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcmRlcmVkID0gYygiY2lhMSIsICJjaWEyIiwgImNpYTMiLCAiY2lhNCIsICJjaWE1IiwgImNpYTYiLCAiY2lhNyIpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlcml6YXRpb249InRoZXRhIiwgZ3JvdXAgPSAic2V4IikKc3VtbWFyeSh0aHJlc2hvbGRFc3RpbWF0ZXMxLCBmaXQubWVhc3VyZXMgPSBUUlVFLCByc3F1YXJlID0gVFJVRSwgc3RhbmRhcmRpemVkID0gVFJVRSkKYW5vdmEobWV0cmljRXN0aW1hdGVzMSwgdGhyZXNob2xkRXN0aW1hdGVzMSkKYW5vdmEoY29uZmlndXJhbEVzdGltYXRlcywgdGhyZXNob2xkRXN0aW1hdGVzMSkKYGBgCgpUaGUgZGlmZmVyZW5jZSB0ZXN0cyBzaG93ZWQgdGhlIHNjYWxhciBtb2RlbCBmaXQgc2lnbmlmaWNhbnRseSBubyB3b3JzZSB0aGFuIHRoZSBjb25maWd1cmFsIG1vZGVsIGJ1d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MoSTdUMywgSTdUMykqdDM7CgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNSZWRpZHVhbCB2YXJpYW5jZXMgYWxsIGZpeGVkIHRvIG9uZSBmb3IgZWFjaCBncm91cApjaWExIH5+IGMoMSwgMSkqY2lhMTsgY2lhMiB+fiBjKDEsIDEpKmNpYTI7IGNpYTMgfn4gYygxLCAxKSpjaWEzOyAKY2lhNCB+fiBjKDEsIDEpKmNpYTQ7IGNpYTUgfn4gYygxLCAxKSpjaWE1OyBjaWE2IH5+IGMoMSwgMSkqY2lhNjsgY2lhNyB+fiBjKDEsIDEpKmNpYTcKCiM9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KI0ZhY3RvciB2YXJpYW5jZSBmaXhlZCB0byAxIGZvciBpZGVudGlmaWNhdGlvbiBpbiBtYWxlczsgZXN0aW1hdGVkIGZvciBmZW1hbGVzCklBREwgfn4gYygxLE5BKSpJQURMCgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNGYWN0b3IgbWVhbiBmaXhlZCB0byB6ZXJvIGZvciBpZGVudGlmaWNhdGlvbiBpbiBtYWxlczsgZXN0aW1hdGVkIGZvciBmZW1hbGVzICoqKioKSUFETCB+IGMoMCxOQSkqMQoKIz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQoiCgp0aHJlc2hvbGRFc3RpbWF0ZXMyID0gbG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cmlhbmNlIGZpeGVkIHRvIDEgZm9yIGlkZW50aWZpY2F0aW9uIGluIG1hbGVzOyBlc3RpbWF0ZWQgZm9yIGZlbWFsZXMgKioqKgpJQURMIH5+IGMoMSwxKSpJQURMCgojPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CiNGYWN0b3IgbWVhbiBmaXhlZCB0byB6ZXJvIGZvciBpZGVudGlmaWNhdGlvbiBpbiBtYWxlczsgZXN0aW1hdGVkIGZvciBmZW1hbGVzCklBREwgfiBjKDAsTkEpKjAKCiM9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KCiIKCmZhY3RvclZhckVzdGltYXRlcyA9IGxhdmFhbihtb2RlbCA9IGZhY3RvclZhclN5bnRheCwgZGF0YSA9IGlhZGxEYXRhLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcmRlcmVkID0gYygiY2lhMSIsICJjaWEyIiwgImNpYTMiLCAiY2lhNCIsICJjaWE1IiwgImNpYTYiLCAiY2lhNyIpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZC5sdiA9IFRSVUUsIHBhcmFtZXRlcml6YXRpb249InRoZXRhIiwgZ3JvdXAgPSAic2V4IikKc3VtbWFyeShmYWN0b3JWYXJFc3RpbWF0ZXMsIGZpdC5tZWFzdXJlcyA9IFRSVUUsIHJzcXVhcmUgPSBUUlVFLCBzdGFuZGFyZGl6ZWQgPSBUUlVFKQphbm92YSh0aHJlc2hvbGRFc3RpbWF0ZXMyLCBmYWN0b3JWYXJFc3RpbWF0ZXMpCmFub3ZhKGNvbmZpZ3VyYWxFc3RpbWF0ZXMsIGZhY3RvclZhckVzdGltYXRlcykKYGBgCgpBcyB0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