#Install packages

#read data

#read in data dile
USMexData <- read_spss("Merged_CriticalReflectionPaper.sav")  

#create a data dictionary

data_dictionary <- data.frame(
  variable = names(USMexData),
  item_stem = sapply(USMexData, function(x) attr(x, "label")),
  row.names = NULL
)

#print(data_dictionary, row.names = FALSE)

#Descriptives for CR Items

# Create matrix with cr vars
cr_items <- USMexData |>
  dplyr::select(ShoCCS_Ch_1, ShoCCS_Ch_2, ShoCCS_Ch_3, ShoCCS_Ch_4, ShoCCS_Ch_5, IneqBelfs_Ch_1, IneqBelfs_Ch_2, IneqBelfs_Ch_3,IneqBelfs_Ch_4, IneqBelfs_Ch_5) |>
  as.matrix()

# View the matrix
#cr_items

#descriptives for cr items
describe(cr_items) |> kable()
vars n mean sd median trimmed mad min max range skew kurtosis se
ShoCCS_Ch_1 1 103 3.786408 1.273027 4.0 3.879518 1.4826 1 6 5 -0.6168376 0.2403324 0.1254351
ShoCCS_Ch_2 2 95 3.410526 1.432857 4.0 3.402597 1.4826 1 6 5 -0.1547744 -0.6071670 0.1470080
ShoCCS_Ch_3 3 98 2.765306 1.241889 3.0 2.737500 1.4826 1 6 5 0.0617935 -0.8544308 0.1254498
ShoCCS_Ch_4 4 99 3.202020 1.370087 3.0 3.209877 1.4826 1 6 5 -0.1033213 -0.8441589 0.1376989
ShoCCS_Ch_5 5 106 3.556604 1.568015 4.0 3.569767 1.4826 1 6 5 -0.1623811 -0.9077168 0.1522991
IneqBelfs_Ch_1 6 98 3.051020 1.160985 3.0 3.037500 1.4826 1 6 5 0.0976476 -0.3383210 0.1172772
IneqBelfs_Ch_2 7 103 2.922330 1.177313 3.0 2.915663 1.4826 1 6 5 0.1843830 -0.1371346 0.1160041
IneqBelfs_Ch_3 8 109 3.082569 1.375234 3.0 3.056180 1.4826 1 6 5 -0.0199544 -0.7672483 0.1317235
IneqBelfs_Ch_4 9 112 3.437500 1.367455 3.5 3.466667 0.7413 1 6 5 -0.1005788 -0.6994994 0.1292123
IneqBelfs_Ch_5 10 103 2.844660 1.341329 3.0 2.746988 1.4826 1 6 5 0.4019343 -0.3562579 0.1321650
#now describe to two composites
cr_comps <- USMexData |>
  dplyr::select(CR_US_Ch, CR_MX_Ch) |>
  as.matrix()

#descriptives for cr comps
describe(cr_comps) |> kable()
vars n mean sd median trimmed mad min max range skew kurtosis se
CR_US_Ch 1 115 3.357971 1.1569486 3.4 3.402509 1.08724 1 6 5 -0.2563853 -0.2403438 0.1078860
CR_MX_Ch 2 118 3.084322 0.9803804 3.0 3.113542 0.88956 1 6 5 -0.2048551 0.0060922 0.0902513

##Cronbach’s Alpha for CR US

#create data matrix for alpha command
UScr_items <- USMexData %>%
  dplyr::select(ShoCCS_Ch_1, ShoCCS_Ch_2, ShoCCS_Ch_3, ShoCCS_Ch_4, ShoCCS_Ch_5)

UScralpha <- psych::alpha(UScr_items)


# View the result
print(UScralpha$total$raw_alpha)
## [1] 0.8642755

##Cronbach’s Alpha for CR MX

#create data matrix for alpha command
MXcr_items <- USMexData %>%
  dplyr::select(IneqBelfs_Ch_1, IneqBelfs_Ch_2, IneqBelfs_Ch_3,IneqBelfs_Ch_4, IneqBelfs_Ch_5)

MXcralpha <- psych::alpha(MXcr_items)


# View the result
print(MXcralpha$total$raw_alpha)
## [1] 0.7814966

#See correlation plot for US CR items

#create a correlation matrix for study vars
UScr_items_mat <-cor(UScr_items, use = "complete.obs")


ggcorrplot(UScr_items_mat, hc.order = TRUE, type = "lower", lab = TRUE, ggtheme = ggplot2::theme_gray,
   colors = c("#6D9EC1", "white", "#E46726"))
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## ℹ The deprecated feature was likely used in the ggcorrplot package.
##   Please report the issue at <https://github.com/kassambara/ggcorrplot/issues>.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

#See correlation plot for MX CR items

#create a correlation matrix for study vars
MXcr_items_mat <-cor(MXcr_items, use = "complete.obs")


ggcorrplot(MXcr_items_mat, hc.order = TRUE, type = "lower", lab = TRUE, ggtheme = ggplot2::theme_gray,
   colors = c("#6D9EC1", "white", "#E46726"))

#CFA for US critical reflection

#CFA for Critical Reflection Measures
us_cr_cfa_model <- 'US_CR =~ 1*ShoCCS_Ch_1 + ShoCCS_Ch_2 + ShoCCS_Ch_3 + ShoCCS_Ch_4 + ShoCCS_Ch_5'


us_cr_cfa <- sem(us_cr_cfa_model, data = USMexData, missing = "ML", estimator = "MLR") #will use MLR 
## Warning: lavaan->lav_data_full():  
##    some cases are empty and will be ignored: 17 46 73 90 96.
summary(us_cr_cfa, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-20 ended normally after 29 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        15
## 
##                                                   Used       Total
##   Number of observations                           115         120
##   Number of missing patterns                        20            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 5.654       4.433
##   Degrees of freedom                                 5           5
##   P-value (Chi-square)                           0.341       0.489
##   Scaling correction factor                                  1.275
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               204.595     142.842
##   Degrees of freedom                                10          10
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.432
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.997       1.000
##   Tucker-Lewis Index (TLI)                       0.993       1.009
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.009
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -768.020    -768.020
##   Scaling correction factor                                  1.105
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)             NA          NA
##   Scaling correction factor                                  1.148
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                1566.040    1566.040
##   Bayesian (BIC)                              1607.214    1607.214
##   Sample-size adjusted Bayesian (SABIC)       1559.802    1559.802
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.034       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.137       0.111
##   P-value H_0: RMSEA <= 0.050                    0.500       0.675
##   P-value H_0: RMSEA >= 0.080                    0.309       0.160
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.170
##   P-value H_0: Robust RMSEA <= 0.050                         0.572
##   P-value H_0: Robust RMSEA >= 0.080                         0.321
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.027       0.027
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   US_CR =~                                                              
##     ShoCCS_Ch_1       1.000                               0.918    0.720
##     ShoCCS_Ch_2       1.274    0.180    7.064    0.000    1.170    0.816
##     ShoCCS_Ch_3       0.873    0.174    5.014    0.000    0.801    0.652
##     ShoCCS_Ch_4       1.157    0.207    5.588    0.000    1.062    0.784
##     ShoCCS_Ch_5       1.276    0.243    5.252    0.000    1.171    0.749
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       3.752    0.125   30.047    0.000    3.752    2.943
##    .ShoCCS_Ch_2       3.373    0.139   24.330    0.000    3.373    2.354
##    .ShoCCS_Ch_3       2.801    0.122   22.944    0.000    2.801    2.279
##    .ShoCCS_Ch_4       3.251    0.131   24.760    0.000    3.251    2.402
##    .ShoCCS_Ch_5       3.561    0.149   23.887    0.000    3.561    2.278
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       0.784    0.174    4.499    0.000    0.784    0.482
##    .ShoCCS_Ch_2       0.684    0.228    3.004    0.003    0.684    0.333
##    .ShoCCS_Ch_3       0.869    0.177    4.901    0.000    0.869    0.575
##    .ShoCCS_Ch_4       0.704    0.161    4.374    0.000    0.704    0.385
##    .ShoCCS_Ch_5       1.072    0.219    4.907    0.000    1.072    0.439
##     US_CR             0.842    0.273    3.080    0.002    1.000    1.000
## 
## R-Square:
##                    Estimate
##     ShoCCS_Ch_1       0.518
##     ShoCCS_Ch_2       0.667
##     ShoCCS_Ch_3       0.425
##     ShoCCS_Ch_4       0.615
##     ShoCCS_Ch_5       0.561

#CFA for MX critical reflection

#CFA for Critical Reflection Measures
mx_cr_cfa_model <- 'MX_CR =~ 1*IneqBelfs_Ch_1 + IneqBelfs_Ch_2 + IneqBelfs_Ch_3 + IneqBelfs_Ch_4 + IneqBelfs_Ch_5'


mx_cr_cfa <- sem(mx_cr_cfa_model, data = USMexData, missing = "ML", estimator = "MLR") 
## Warning: lavaan->lav_data_full():  
##    some cases are empty and will be ignored: 17 45.
summary(mx_cr_cfa, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-20 ended normally after 30 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        15
## 
##                                                   Used       Total
##   Number of observations                           118         120
##   Number of missing patterns                        17            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                12.140      10.374
##   Degrees of freedom                                 5           5
##   P-value (Chi-square)                           0.033       0.065
##   Scaling correction factor                                  1.170
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               145.444     110.012
##   Degrees of freedom                                10          10
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.322
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.947       0.946
##   Tucker-Lewis Index (TLI)                       0.895       0.893
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.951
##   Robust Tucker-Lewis Index (TLI)                            0.902
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)               -807.248    -807.248
##   Scaling correction factor                                  1.090
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)             NA          NA
##   Scaling correction factor                                  1.110
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                1644.495    1644.495
##   Bayesian (BIC)                              1686.056    1686.056
##   Sample-size adjusted Bayesian (SABIC)       1638.637    1638.637
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.110       0.095
##   90 Percent confidence interval - lower         0.029       0.000
##   90 Percent confidence interval - upper         0.190       0.172
##   P-value H_0: RMSEA <= 0.050                    0.091       0.141
##   P-value H_0: RMSEA >= 0.080                    0.780       0.686
##                                                                   
##   Robust RMSEA                                               0.115
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.215
##   P-value H_0: Robust RMSEA <= 0.050                         0.121
##   P-value H_0: Robust RMSEA >= 0.080                         0.772
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.049       0.049
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   MX_CR =~                                                              
##     IneqBelfs_Ch_1    1.000                               0.787    0.680
##     IneqBelfs_Ch_2    1.275    0.200    6.370    0.000    1.003    0.861
##     IneqBelfs_Ch_3    1.042    0.236    4.420    0.000    0.820    0.602
##     IneqBelfs_Ch_4    0.965    0.275    3.512    0.000    0.759    0.558
##     IneqBelfs_Ch_5    0.973    0.242    4.028    0.000    0.766    0.569
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .IneqBelfs_Ch_1    3.054    0.114   26.876    0.000    3.054    2.637
##    .IneqBelfs_Ch_2    2.928    0.112   26.228    0.000    2.928    2.512
##    .IneqBelfs_Ch_3    3.091    0.129   24.053    0.000    3.091    2.269
##    .IneqBelfs_Ch_4    3.430    0.128   26.830    0.000    3.430    2.520
##    .IneqBelfs_Ch_5    2.882    0.131   21.998    0.000    2.882    2.143
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .IneqBelfs_Ch_1    0.722    0.170    4.241    0.000    0.722    0.538
##    .IneqBelfs_Ch_2    0.352    0.147    2.394    0.017    0.352    0.259
##    .IneqBelfs_Ch_3    1.184    0.234    5.072    0.000    1.184    0.638
##    .IneqBelfs_Ch_4    1.276    0.209    6.101    0.000    1.276    0.689
##    .IneqBelfs_Ch_5    1.223    0.230    5.310    0.000    1.223    0.676
##     MX_CR             0.619    0.207    2.993    0.003    1.000    1.000
## 
## R-Square:
##                    Estimate
##     IneqBelfs_Ch_1    0.462
##     IneqBelfs_Ch_2    0.741
##     IneqBelfs_Ch_3    0.362
##     IneqBelfs_Ch_4    0.311
##     IneqBelfs_Ch_5    0.324
modindices(mx_cr_cfa, sort. = TRUE)
##               lhs op            rhs    mi    epc sepc.lv sepc.all sepc.nox
## 18 IneqBelfs_Ch_1 ~~ IneqBelfs_Ch_2 8.464  0.392   0.392    0.777    0.777
## 20 IneqBelfs_Ch_1 ~~ IneqBelfs_Ch_4 6.565 -0.316  -0.316   -0.330   -0.330
## 27 IneqBelfs_Ch_4 ~~ IneqBelfs_Ch_5 4.494  0.302   0.302    0.242    0.242
## 22 IneqBelfs_Ch_2 ~~ IneqBelfs_Ch_3 2.781 -0.236  -0.236   -0.365   -0.365
## 25 IneqBelfs_Ch_3 ~~ IneqBelfs_Ch_4 2.168  0.209   0.209    0.170    0.170
## 21 IneqBelfs_Ch_1 ~~ IneqBelfs_Ch_5 1.473 -0.150  -0.150   -0.159   -0.159
## 24 IneqBelfs_Ch_2 ~~ IneqBelfs_Ch_5 0.682 -0.112  -0.112   -0.170   -0.170
## 23 IneqBelfs_Ch_2 ~~ IneqBelfs_Ch_4 0.227 -0.064  -0.064   -0.096   -0.096
## 26 IneqBelfs_Ch_3 ~~ IneqBelfs_Ch_5 0.199  0.063   0.063    0.053    0.053
## 19 IneqBelfs_Ch_1 ~~ IneqBelfs_Ch_3 0.060  0.031   0.031    0.033    0.033
lavInspect(mx_cr_cfa, "cor.lv")
##       MX_CR
## MX_CR 0.619

#Measurement Configural invariance for CR across US and MX

#CFA for Critical Reflection Measures
mx_cr_conf_model <- 'US_CR =~ 1*ShoCCS_Ch_1 + ShoCCS_Ch_2 + ShoCCS_Ch_3 + ShoCCS_Ch_4 + ShoCCS_Ch_5
                    MX_CR =~ 1*IneqBelfs_Ch_1 + IneqBelfs_Ch_2 + IneqBelfs_Ch_3 + IneqBelfs_Ch_4 +                                IneqBelfs_Ch_5
                    
                    ShoCCS_Ch_1 ~~ IneqBelfs_Ch_1
                    ShoCCS_Ch_2 ~~ IneqBelfs_Ch_2
                    ShoCCS_Ch_3 ~~ IneqBelfs_Ch_3
                    ShoCCS_Ch_4 ~~ IneqBelfs_Ch_4
                    ShoCCS_Ch_5 ~~ IneqBelfs_Ch_5'


mx_cr_conf_fit <- sem(mx_cr_conf_model, data = USMexData, missing = "ML", estimator = "MLR", meanstructure = TRUE) 
## Warning: lavaan->lav_data_full():  
##    some cases are empty and will be ignored: 17.
summary(mx_cr_conf_fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-20 ended normally after 44 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        36
## 
##                                                   Used       Total
##   Number of observations                           119         120
##   Number of missing patterns                        40            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                45.672      38.238
##   Degrees of freedom                                29          29
##   P-value (Chi-square)                           0.025       0.117
##   Scaling correction factor                                  1.194
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               426.299     329.448
##   Degrees of freedom                                45          45
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.294
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.956       0.968
##   Tucker-Lewis Index (TLI)                       0.932       0.950
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.969
##   Robust Tucker-Lewis Index (TLI)                            0.951
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1551.077   -1551.077
##   Scaling correction factor                                  1.144
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)             NA          NA
##   Scaling correction factor                                  1.167
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                3174.154    3174.154
##   Bayesian (BIC)                              3274.203    3274.203
##   Sample-size adjusted Bayesian (SABIC)       3160.393    3160.393
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.070       0.052
##   90 Percent confidence interval - lower         0.025       0.000
##   90 Percent confidence interval - upper         0.106       0.089
##   P-value H_0: RMSEA <= 0.050                    0.193       0.443
##   P-value H_0: RMSEA >= 0.080                    0.348       0.116
##                                                                   
##   Robust RMSEA                                               0.065
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.118
##   P-value H_0: Robust RMSEA <= 0.050                         0.323
##   P-value H_0: Robust RMSEA >= 0.080                         0.355
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.069       0.069
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   US_CR =~                                                              
##     ShoCCS_Ch_1       1.000                               0.918    0.716
##     ShoCCS_Ch_2       1.301    0.190    6.860    0.000    1.195    0.822
##     ShoCCS_Ch_3       0.908    0.179    5.082    0.000    0.834    0.672
##     ShoCCS_Ch_4       1.089    0.200    5.451    0.000    1.000    0.752
##     ShoCCS_Ch_5       1.291    0.255    5.069    0.000    1.185    0.761
##   MX_CR =~                                                              
##     IneqBelfs_Ch_1    1.000                               0.787    0.673
##     IneqBelfs_Ch_2    1.229    0.193    6.354    0.000    0.967    0.824
##     IneqBelfs_Ch_3    1.075    0.263    4.086    0.000    0.846    0.621
##     IneqBelfs_Ch_4    1.059    0.306    3.459    0.001    0.833    0.608
##     IneqBelfs_Ch_5    0.979    0.268    3.648    0.000    0.770    0.576
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .ShoCCS_Ch_1 ~~                                                        
##    .IneqBelfs_Ch_1    0.050    0.110    0.460    0.646    0.050    0.065
##  .ShoCCS_Ch_2 ~~                                                        
##    .IneqBelfs_Ch_2    0.034    0.090    0.373    0.709    0.034    0.061
##  .ShoCCS_Ch_3 ~~                                                        
##    .IneqBelfs_Ch_3    0.201    0.127    1.578    0.114    0.201    0.204
##  .ShoCCS_Ch_4 ~~                                                        
##    .IneqBelfs_Ch_4    0.383    0.130    2.942    0.003    0.383    0.403
##  .ShoCCS_Ch_5 ~~                                                        
##    .IneqBelfs_Ch_5    0.125    0.163    0.763    0.445    0.125    0.113
##   US_CR ~~                                                              
##     MX_CR             0.438    0.117    3.758    0.000    0.606    0.606
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       3.746    0.126   29.817    0.000    3.746    2.918
##    .ShoCCS_Ch_2       3.371    0.139   24.198    0.000    3.371    2.319
##    .ShoCCS_Ch_3       2.813    0.122   22.995    0.000    2.813    2.266
##    .ShoCCS_Ch_4       3.248    0.130   24.962    0.000    3.248    2.445
##    .ShoCCS_Ch_5       3.564    0.149   23.955    0.000    3.564    2.289
##    .IneqBelfs_Ch_1    3.062    0.115   26.716    0.000    3.062    2.619
##    .IneqBelfs_Ch_2    2.951    0.113   26.179    0.000    2.951    2.514
##    .IneqBelfs_Ch_3    3.115    0.128   24.417    0.000    3.115    2.286
##    .IneqBelfs_Ch_4    3.426    0.128   26.790    0.000    3.426    2.503
##    .IneqBelfs_Ch_5    2.885    0.131   21.964    0.000    2.885    2.158
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       0.804    0.173    4.637    0.000    0.804    0.488
##    .ShoCCS_Ch_2       0.685    0.232    2.952    0.003    0.685    0.324
##    .ShoCCS_Ch_3       0.845    0.176    4.815    0.000    0.845    0.549
##    .ShoCCS_Ch_4       0.766    0.160    4.779    0.000    0.766    0.434
##    .ShoCCS_Ch_5       1.019    0.219    4.661    0.000    1.019    0.420
##    .IneqBelfs_Ch_1    0.748    0.192    3.893    0.000    0.748    0.547
##    .IneqBelfs_Ch_2    0.442    0.164    2.693    0.007    0.442    0.321
##    .IneqBelfs_Ch_3    1.141    0.237    4.821    0.000    1.141    0.615
##    .IneqBelfs_Ch_4    1.180    0.216    5.456    0.000    1.180    0.630
##    .IneqBelfs_Ch_5    1.195    0.231    5.174    0.000    1.195    0.668
##     US_CR             0.843    0.274    3.074    0.002    1.000    1.000
##     MX_CR             0.619    0.230    2.691    0.007    1.000    1.000
## 
## R-Square:
##                    Estimate
##     ShoCCS_Ch_1       0.512
##     ShoCCS_Ch_2       0.676
##     ShoCCS_Ch_3       0.451
##     ShoCCS_Ch_4       0.566
##     ShoCCS_Ch_5       0.580
##     IneqBelfs_Ch_1    0.453
##     IneqBelfs_Ch_2    0.679
##     IneqBelfs_Ch_3    0.385
##     IneqBelfs_Ch_4    0.370
##     IneqBelfs_Ch_5    0.332
#inspect correlation between the CR factors
#lavInspect(mx_cr_conf_fit, "cor.lv")

#inspect the covariance between the factors
#lavInspect(mx_cr_conf_fit, "cov.lv")

#inspect the observed covariance
#lavInspect(mx_cr_conf_fit, "cov.ov")

#inspect the residual (theta) matrix
#lavInspect(mx_cr_conf_fit, "theta")

#insect the theta values
#eigen(lavInspect(mx_cr_conf_fit, "theta"))$values


#eigen(lavInspect(mx_cr_conf_fit, "cov.lv"))$values

#eigen(lavInspect(mx_cr_conf_fit, "cov.ov"))$values


#vcov_matrix <- vcov(mx_cr_conf_fit)
#eigen(vcov_matrix)$values

#lavInspect(mx_cr_conf_fit, "vcov")
#lavInspect(mx_cr_conf_fit, "information")

#inspect(mx_cr_conf_fit, "post.check")
#lavInspect(mx_cr_conf_fit, "estimates")

#Metric Invariance for CR across US and MX

#CFA for Critical Reflection Measures
mx_cr_metric_model <- 'US_CR =~ 1*ShoCCS_Ch_1 + l2*ShoCCS_Ch_2 + l3*ShoCCS_Ch_3 + l4*ShoCCS_Ch_4 +                                            l5*ShoCCS_Ch_5
                       MX_CR =~ 1*IneqBelfs_Ch_1 + l2*IneqBelfs_Ch_2 + l3*IneqBelfs_Ch_3 + l4*IneqBelfs_Ch_4 +                                 l5*IneqBelfs_Ch_5
                    
                       ShoCCS_Ch_1 ~~ IneqBelfs_Ch_1
                       ShoCCS_Ch_2 ~~ IneqBelfs_Ch_2
                       ShoCCS_Ch_3 ~~ IneqBelfs_Ch_3
                       ShoCCS_Ch_4 ~~ IneqBelfs_Ch_4
                       ShoCCS_Ch_5 ~~ IneqBelfs_Ch_5'


mx_cr_metric_fit <- sem(mx_cr_metric_model, data = USMexData, missing = "ML", estimator = "MLR", meanstructure = TRUE) 
## Warning: lavaan->lav_data_full():  
##    some cases are empty and will be ignored: 17.
summary(mx_cr_metric_fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-20 ended normally after 36 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        36
##   Number of equality constraints                     4
## 
##                                                   Used       Total
##   Number of observations                           119         120
##   Number of missing patterns                        40            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                48.866      40.921
##   Degrees of freedom                                33          33
##   P-value (Chi-square)                           0.037       0.162
##   Scaling correction factor                                  1.194
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               426.299     329.448
##   Degrees of freedom                                45          45
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.294
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.958       0.972
##   Tucker-Lewis Index (TLI)                       0.943       0.962
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.973
##   Robust Tucker-Lewis Index (TLI)                            0.963
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1552.674   -1552.674
##   Scaling correction factor                                  1.012
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)             NA          NA
##   Scaling correction factor                                  1.167
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                3169.348    3169.348
##   Bayesian (BIC)                              3258.280    3258.280
##   Sample-size adjusted Bayesian (SABIC)       3157.115    3157.115
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.064       0.045
##   90 Percent confidence interval - lower         0.016       0.000
##   90 Percent confidence interval - upper         0.099       0.082
##   P-value H_0: RMSEA <= 0.050                    0.261       0.553
##   P-value H_0: RMSEA >= 0.080                    0.246       0.061
##                                                                   
##   Robust RMSEA                                               0.056
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.108
##   P-value H_0: Robust RMSEA <= 0.050                         0.404
##   P-value H_0: Robust RMSEA >= 0.080                         0.259
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.076       0.076
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   US_CR =~                                                              
##     ShCCS_C_1         1.000                               0.933    0.722
##     ShCCS_C_2 (l2)    1.276    0.134    9.497    0.000    1.191    0.823
##     ShCCS_C_3 (l3)    0.963    0.148    6.490    0.000    0.898    0.702
##     ShCCS_C_4 (l4)    1.079    0.185    5.826    0.000    1.007    0.755
##     ShCCS_C_5 (l5)    1.183    0.215    5.495    0.000    1.104    0.729
##   MX_CR =~                                                              
##     InqBl_C_1         1.000                               0.763    0.659
##     InqBl_C_2 (l2)    1.276    0.134    9.497    0.000    0.974    0.827
##     InqBl_C_3 (l3)    0.963    0.148    6.490    0.000    0.734    0.558
##     InqBl_C_4 (l4)    1.079    0.185    5.826    0.000    0.823    0.604
##     InqBl_C_5 (l5)    1.183    0.215    5.495    0.000    0.902    0.644
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .ShoCCS_Ch_1 ~~                                                        
##    .IneqBelfs_Ch_1    0.051    0.108    0.469    0.639    0.051    0.065
##  .ShoCCS_Ch_2 ~~                                                        
##    .IneqBelfs_Ch_2    0.027    0.087    0.306    0.759    0.027    0.049
##  .ShoCCS_Ch_3 ~~                                                        
##    .IneqBelfs_Ch_3    0.207    0.130    1.588    0.112    0.207    0.208
##  .ShoCCS_Ch_4 ~~                                                        
##    .IneqBelfs_Ch_4    0.386    0.130    2.968    0.003    0.386    0.406
##  .ShoCCS_Ch_5 ~~                                                        
##    .IneqBelfs_Ch_5    0.097    0.160    0.603    0.546    0.097    0.087
##   US_CR ~~                                                              
##     MX_CR             0.431    0.116    3.701    0.000    0.605    0.605
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       3.745    0.125   30.013    0.000    3.745    2.896
##    .ShoCCS_Ch_2       3.370    0.139   24.181    0.000    3.370    2.327
##    .ShoCCS_Ch_3       2.818    0.123   22.986    0.000    2.818    2.203
##    .ShoCCS_Ch_4       3.249    0.130   24.990    0.000    3.249    2.437
##    .ShoCCS_Ch_5       3.564    0.149   23.955    0.000    3.564    2.355
##    .IneqBelfs_Ch_1    3.062    0.114   26.840    0.000    3.062    2.643
##    .IneqBelfs_Ch_2    2.950    0.112   26.290    0.000    2.950    2.506
##    .IneqBelfs_Ch_3    3.111    0.129   24.124    0.000    3.111    2.364
##    .IneqBelfs_Ch_4    3.426    0.128   26.830    0.000    3.426    2.512
##    .IneqBelfs_Ch_5    2.894    0.132   21.956    0.000    2.894    2.064
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       0.801    0.170    4.720    0.000    0.801    0.479
##    .ShoCCS_Ch_2       0.678    0.223    3.046    0.002    0.678    0.323
##    .ShoCCS_Ch_3       0.829    0.170    4.869    0.000    0.829    0.507
##    .ShoCCS_Ch_4       0.764    0.161    4.755    0.000    0.764    0.429
##    .ShoCCS_Ch_5       1.072    0.218    4.927    0.000    1.072    0.468
##    .IneqBelfs_Ch_1    0.759    0.170    4.476    0.000    0.759    0.566
##    .IneqBelfs_Ch_2    0.437    0.143    3.060    0.002    0.437    0.316
##    .IneqBelfs_Ch_3    1.193    0.207    5.765    0.000    1.193    0.689
##    .IneqBelfs_Ch_4    1.183    0.180    6.556    0.000    1.183    0.636
##    .IneqBelfs_Ch_5    1.152    0.223    5.165    0.000    1.152    0.586
##     US_CR             0.871    0.229    3.812    0.000    1.000    1.000
##     MX_CR             0.582    0.166    3.516    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     ShoCCS_Ch_1       0.521
##     ShoCCS_Ch_2       0.677
##     ShoCCS_Ch_3       0.493
##     ShoCCS_Ch_4       0.571
##     ShoCCS_Ch_5       0.532
##     IneqBelfs_Ch_1    0.434
##     IneqBelfs_Ch_2    0.684
##     IneqBelfs_Ch_3    0.311
##     IneqBelfs_Ch_4    0.364
##     IneqBelfs_Ch_5    0.414

#Full Scalar Invariance for CR across US and MX

#CFA for Critical Reflection Measures
mx_cr_scalar_model <- 'US_CR =~ 1*ShoCCS_Ch_1 + l2*ShoCCS_Ch_2 + l3*ShoCCS_Ch_3 + l4*ShoCCS_Ch_4 +                                            l5*ShoCCS_Ch_5
                       MX_CR =~ 1*IneqBelfs_Ch_1 + l2*IneqBelfs_Ch_2 + l3*IneqBelfs_Ch_3 + l4*IneqBelfs_Ch_4 +                                l5*IneqBelfs_Ch_5
                    
                    ShoCCS_Ch_1 ~~ IneqBelfs_Ch_1
                    ShoCCS_Ch_2 ~~ IneqBelfs_Ch_2
                    ShoCCS_Ch_3 ~~ IneqBelfs_Ch_3
                    ShoCCS_Ch_4 ~~ IneqBelfs_Ch_4
                    ShoCCS_Ch_5 ~~ IneqBelfs_Ch_5
                    
                    ShoCCS_Ch_1 ~ i1*1 
                    IneqBelfs_Ch_1 ~ i1*1

                    ShoCCS_Ch_2 ~ i2*1 
                    IneqBelfs_Ch_2 ~ i2*1

                    ShoCCS_Ch_3 ~ i3*1
                    IneqBelfs_Ch_3 ~ i3*1

                    ShoCCS_Ch_4 ~ i4*1
                    IneqBelfs_Ch_4 ~ i4*1

                    ShoCCS_Ch_5 ~ i5*1
                    IneqBelfs_Ch_5 ~ i5*1'


mx_cr_scalar_fit <- sem(mx_cr_scalar_model, data = USMexData, missing = "ML", estimator = "MLR", meanstructure = TRUE) 
## Warning: lavaan->lav_data_full():  
##    some cases are empty and will be ignored: 17.
summary(mx_cr_scalar_fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-20 ended normally after 36 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        36
##   Number of equality constraints                     9
## 
##                                                   Used       Total
##   Number of observations                           119         120
##   Number of missing patterns                        40            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               105.890      89.178
##   Degrees of freedom                                38          38
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.187
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               426.299     329.448
##   Degrees of freedom                                45          45
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.294
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.822       0.820
##   Tucker-Lewis Index (TLI)                       0.789       0.787
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.837
##   Robust Tucker-Lewis Index (TLI)                            0.807
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1581.186   -1581.186
##   Scaling correction factor                                  0.853
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)             NA          NA
##   Scaling correction factor                                  1.167
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                3216.372    3216.372
##   Bayesian (BIC)                              3291.409    3291.409
##   Sample-size adjusted Bayesian (SABIC)       3206.051    3206.051
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.123       0.106
##   90 Percent confidence interval - lower         0.095       0.080
##   90 Percent confidence interval - upper         0.151       0.133
##   P-value H_0: RMSEA <= 0.050                    0.000       0.000
##   P-value H_0: RMSEA >= 0.080                    0.994       0.951
##                                                                   
##   Robust RMSEA                                               0.129
##   90 Percent confidence interval - lower                     0.092
##   90 Percent confidence interval - upper                     0.166
##   P-value H_0: Robust RMSEA <= 0.050                         0.001
##   P-value H_0: Robust RMSEA >= 0.080                         0.984
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.115       0.115
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   US_CR =~                                                              
##     ShCCS_C_1         1.000                               0.988    0.730
##     ShCCS_C_2 (l2)    1.261    0.129    9.740    0.000    1.246    0.838
##     ShCCS_C_3 (l3)    0.874    0.163    5.380    0.000    0.863    0.674
##     ShCCS_C_4 (l4)    0.988    0.197    5.017    0.000    0.976    0.735
##     ShCCS_C_5 (l5)    1.168    0.211    5.534    0.000    1.154    0.738
##   MX_CR =~                                                              
##     InqBl_C_1         1.000                               0.792    0.659
##     InqBl_C_2 (l2)    1.261    0.129    9.740    0.000    0.998    0.844
##     InqBl_C_3 (l3)    0.874    0.163    5.380    0.000    0.692    0.519
##     InqBl_C_4 (l4)    0.988    0.197    5.017    0.000    0.782    0.570
##     InqBl_C_5 (l5)    1.168    0.211    5.534    0.000    0.924    0.639
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .ShoCCS_Ch_1 ~~                                                        
##    .IneqBelfs_Ch_1    0.012    0.118    0.104    0.917    0.012    0.015
##  .ShoCCS_Ch_2 ~~                                                        
##    .IneqBelfs_Ch_2    0.013    0.091    0.146    0.884    0.013    0.026
##  .ShoCCS_Ch_3 ~~                                                        
##    .IneqBelfs_Ch_3    0.170    0.136    1.252    0.210    0.170    0.157
##  .ShoCCS_Ch_4 ~~                                                        
##    .IneqBelfs_Ch_4    0.373    0.143    2.616    0.009    0.373    0.367
##  .ShoCCS_Ch_5 ~~                                                        
##    .IneqBelfs_Ch_5    0.007    0.151    0.049    0.961    0.007    0.006
##   US_CR ~~                                                              
##     MX_CR             0.448    0.119    3.766    0.000    0.573    0.573
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShCCS_C_1 (i1)    3.363    0.108   31.069    0.000    3.363    2.486
##    .InqBl_C_1 (i1)    3.363    0.108   31.069    0.000    3.363    2.802
##    .ShCCS_C_2 (i2)    3.079    0.107   28.753    0.000    3.079    2.072
##    .InqBl_C_2 (i2)    3.079    0.107   28.753    0.000    3.079    2.603
##    .ShCCS_C_3 (i3)    2.893    0.108   26.754    0.000    2.893    2.258
##    .InqBl_C_3 (i3)    2.893    0.108   26.754    0.000    2.893    2.170
##    .ShCCS_C_4 (i4)    3.255    0.118   27.542    0.000    3.255    2.450
##    .InqBl_C_4 (i4)    3.255    0.118   27.542    0.000    3.255    2.373
##    .ShCCS_C_5 (i5)    3.199    0.131   24.505    0.000    3.199    2.046
##    .InqBl_C_5 (i5)    3.199    0.131   24.505    0.000    3.199    2.211
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       0.855    0.198    4.312    0.000    0.855    0.467
##    .ShoCCS_Ch_2       0.656    0.236    2.779    0.005    0.656    0.297
##    .ShoCCS_Ch_3       0.896    0.188    4.763    0.000    0.896    0.546
##    .ShoCCS_Ch_4       0.813    0.179    4.546    0.000    0.813    0.460
##    .ShoCCS_Ch_5       1.114    0.230    4.852    0.000    1.114    0.456
##    .IneqBelfs_Ch_1    0.814    0.186    4.374    0.000    0.814    0.565
##    .IneqBelfs_Ch_2    0.403    0.154    2.609    0.009    0.403    0.288
##    .IneqBelfs_Ch_3    1.298    0.226    5.743    0.000    1.298    0.731
##    .IneqBelfs_Ch_4    1.270    0.197    6.443    0.000    1.270    0.675
##    .IneqBelfs_Ch_5    1.239    0.227    5.452    0.000    1.239    0.592
##     US_CR             0.975    0.262    3.721    0.000    1.000    1.000
##     MX_CR             0.627    0.176    3.552    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     ShoCCS_Ch_1       0.533
##     ShoCCS_Ch_2       0.703
##     ShoCCS_Ch_3       0.454
##     ShoCCS_Ch_4       0.540
##     ShoCCS_Ch_5       0.544
##     IneqBelfs_Ch_1    0.435
##     IneqBelfs_Ch_2    0.712
##     IneqBelfs_Ch_3    0.269
##     IneqBelfs_Ch_4    0.325
##     IneqBelfs_Ch_5    0.408

#Partial Scalar Invariance for CR across US and MX

#CFA for Critical Reflection Measures
mx_cr_scalar_model <- 'US_CR =~ 1*ShoCCS_Ch_1 + l2*ShoCCS_Ch_2 + l3*ShoCCS_Ch_3 + l4*ShoCCS_Ch_4 +                                            l5*ShoCCS_Ch_5
                       MX_CR =~ 1*IneqBelfs_Ch_1 + l2*IneqBelfs_Ch_2 + l3*IneqBelfs_Ch_3 + l4*IneqBelfs_Ch_4 +                                l5*IneqBelfs_Ch_5
                    
                    ShoCCS_Ch_1 ~~ IneqBelfs_Ch_1
                    ShoCCS_Ch_2 ~~ IneqBelfs_Ch_2
                    ShoCCS_Ch_3 ~~ IneqBelfs_Ch_3
                    ShoCCS_Ch_4 ~~ IneqBelfs_Ch_4
                    ShoCCS_Ch_5 ~~ IneqBelfs_Ch_5
                    
                    ShoCCS_Ch_1 ~ 1 #free the first item intercepts due to fit
                    IneqBelfs_Ch_1 ~ 1

                    ShoCCS_Ch_2 ~ 1 
                    IneqBelfs_Ch_2 ~ 1

                    ShoCCS_Ch_3 ~ i3*1
                    IneqBelfs_Ch_3 ~ i3*1

                    ShoCCS_Ch_4 ~ i4*1
                    IneqBelfs_Ch_4 ~ i4*1

                    ShoCCS_Ch_5 ~ 1
                    IneqBelfs_Ch_5 ~ 1 #free the last item intercepts due to fit'


mx_cr_scalar_fit <- sem(mx_cr_scalar_model, data = USMexData, missing = "ML", estimator = "MLR", meanstructure = TRUE) 
## Warning: lavaan->lav_data_full():  
##    some cases are empty and will be ignored: 17.
summary(mx_cr_scalar_fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-20 ended normally after 38 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        36
##   Number of equality constraints                     6
## 
##                                                   Used       Total
##   Number of observations                           119         120
##   Number of missing patterns                        40            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                53.502      45.518
##   Degrees of freedom                                35          35
##   P-value (Chi-square)                           0.023       0.110
##   Scaling correction factor                                  1.175
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               426.299     329.448
##   Degrees of freedom                                45          45
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.294
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.951       0.963
##   Tucker-Lewis Index (TLI)                       0.938       0.952
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.966
##   Robust Tucker-Lewis Index (TLI)                            0.956
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1554.992   -1554.992
##   Scaling correction factor                                  0.964
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)             NA          NA
##   Scaling correction factor                                  1.167
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                3169.984    3169.984
##   Bayesian (BIC)                              3253.358    3253.358
##   Sample-size adjusted Bayesian (SABIC)       3158.516    3158.516
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.067       0.050
##   90 Percent confidence interval - lower         0.025       0.000
##   90 Percent confidence interval - upper         0.101       0.085
##   P-value H_0: RMSEA <= 0.050                    0.212       0.468
##   P-value H_0: RMSEA >= 0.080                    0.283       0.084
##                                                                   
##   Robust RMSEA                                               0.061
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.110
##   P-value H_0: Robust RMSEA <= 0.050                         0.347
##   P-value H_0: Robust RMSEA >= 0.080                         0.295
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.081       0.081
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   US_CR =~                                                              
##     ShCCS_C_1         1.000                               0.938    0.724
##     ShCCS_C_2 (l2)    1.276    0.134    9.512    0.000    1.197    0.825
##     ShCCS_C_3 (l3)    0.971    0.147    6.594    0.000    0.910    0.705
##     ShCCS_C_4 (l4)    1.082    0.184    5.885    0.000    1.015    0.758
##     ShCCS_C_5 (l5)    1.178    0.215    5.482    0.000    1.105    0.729
##   MX_CR =~                                                              
##     InqBl_C_1         1.000                               0.763    0.659
##     InqBl_C_2 (l2)    1.276    0.134    9.512    0.000    0.974    0.828
##     InqBl_C_3 (l3)    0.971    0.147    6.594    0.000    0.741    0.560
##     InqBl_C_4 (l4)    1.082    0.184    5.885    0.000    0.825    0.604
##     InqBl_C_5 (l5)    1.178    0.215    5.482    0.000    0.899    0.642
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .ShoCCS_Ch_1 ~~                                                        
##    .IneqBelfs_Ch_1    0.053    0.108    0.489    0.625    0.053    0.068
##  .ShoCCS_Ch_2 ~~                                                        
##    .IneqBelfs_Ch_2    0.030    0.087    0.343    0.732    0.030    0.055
##  .ShoCCS_Ch_3 ~~                                                        
##    .IneqBelfs_Ch_3    0.198    0.129    1.535    0.125    0.198    0.197
##  .ShoCCS_Ch_4 ~~                                                        
##    .IneqBelfs_Ch_4    0.386    0.131    2.950    0.003    0.386    0.405
##  .ShoCCS_Ch_5 ~~                                                        
##    .IneqBelfs_Ch_5    0.097    0.161    0.605    0.545    0.097    0.087
##   US_CR ~~                                                              
##     MX_CR             0.423    0.116    3.648    0.000    0.591    0.591
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShCCS_C_1         3.818    0.120   31.944    0.000    3.818    2.948
##    .InqBl_C_1         3.037    0.115   26.417    0.000    3.037    2.625
##    .ShCCS_C_2         3.464    0.136   25.453    0.000    3.464    2.388
##    .InqBl_C_2         2.917    0.108   27.119    0.000    2.917    2.481
##    .ShCCS_C_3 (i3)    2.974    0.104   28.517    0.000    2.974    2.302
##    .InqBl_C_3 (i3)    2.974    0.104   28.517    0.000    2.974    2.247
##    .ShCCS_C_4 (i4)    3.356    0.113   29.594    0.000    3.356    2.507
##    .InqBl_C_4 (i4)    3.356    0.113   29.594    0.000    3.356    2.455
##    .ShCCS_C_5         3.650    0.152   24.072    0.000    3.650    2.408
##    .InqBl_C_5         2.863    0.129   22.247    0.000    2.863    2.045
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       0.799    0.170    4.706    0.000    0.799    0.476
##    .ShoCCS_Ch_2       0.672    0.220    3.052    0.002    0.672    0.319
##    .ShoCCS_Ch_3       0.840    0.173    4.848    0.000    0.840    0.503
##    .ShoCCS_Ch_4       0.763    0.161    4.742    0.000    0.763    0.426
##    .ShoCCS_Ch_5       1.078    0.219    4.933    0.000    1.078    0.469
##    .IneqBelfs_Ch_1    0.756    0.169    4.476    0.000    0.756    0.565
##    .IneqBelfs_Ch_2    0.434    0.142    3.064    0.002    0.434    0.314
##    .IneqBelfs_Ch_3    1.202    0.214    5.623    0.000    1.202    0.687
##    .IneqBelfs_Ch_4    1.187    0.182    6.511    0.000    1.187    0.635
##    .IneqBelfs_Ch_5    1.153    0.223    5.171    0.000    1.153    0.588
##     US_CR             0.879    0.230    3.820    0.000    1.000    1.000
##     MX_CR             0.582    0.166    3.517    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     ShoCCS_Ch_1       0.524
##     ShoCCS_Ch_2       0.681
##     ShoCCS_Ch_3       0.497
##     ShoCCS_Ch_4       0.574
##     ShoCCS_Ch_5       0.531
##     IneqBelfs_Ch_1    0.435
##     IneqBelfs_Ch_2    0.686
##     IneqBelfs_Ch_3    0.313
##     IneqBelfs_Ch_4    0.365
##     IneqBelfs_Ch_5    0.412

#For key analyses: run a cfa model with two cr factors (US vs MEX), check via wald/lrt if their mean is sig. dif #CFA with Wald Test for MX vs US critical reflection

#CFA for Critical Reflection Measures
mx_cr_key_model <- 'US_CR =~ 1*ShoCCS_Ch_1 + l2*ShoCCS_Ch_2 + l3*ShoCCS_Ch_3 + l4*ShoCCS_Ch_4 +                                            l5*ShoCCS_Ch_5
                    MX_CR =~ 1*IneqBelfs_Ch_1 + l2*IneqBelfs_Ch_2 + l3*IneqBelfs_Ch_3 + l4*IneqBelfs_Ch_4 +                                l5*IneqBelfs_Ch_5
                    
                    ShoCCS_Ch_1 ~~ IneqBelfs_Ch_1
                    ShoCCS_Ch_2 ~~ IneqBelfs_Ch_2
                    ShoCCS_Ch_3 ~~ IneqBelfs_Ch_3
                    ShoCCS_Ch_4 ~~ IneqBelfs_Ch_4
                    ShoCCS_Ch_5 ~~ IneqBelfs_Ch_5
                    
                    ShoCCS_Ch_1 ~ 1
                    IneqBelfs_Ch_1 ~ 1

                    ShoCCS_Ch_2 ~ 1
                    IneqBelfs_Ch_2 ~ 1

                    ShoCCS_Ch_3 ~ i3*1
                    IneqBelfs_Ch_3 ~ i3*1

                    ShoCCS_Ch_4 ~ i4*1
                    IneqBelfs_Ch_4 ~ i4*1

                    ShoCCS_Ch_5 ~ 1
                    IneqBelfs_Ch_5 ~ 1
                    
                    US_CR ~ 0*1
                    MX_CR ~ m1*1'


mx_cr_key_fit <- sem(mx_cr_key_model, data = USMexData, missing = "ML", estimator = "MLR", meanstructure = TRUE) 
## Warning: lavaan->lav_data_full():  
##    some cases are empty and will be ignored: 17.
summary(mx_cr_key_fit, fit.measures = T, standardized = T, rsquare = T)
## lavaan 0.6-20 ended normally after 39 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        37
##   Number of equality constraints                     6
## 
##                                                   Used       Total
##   Number of observations                           119         120
##   Number of missing patterns                        40            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                49.553      41.736
##   Degrees of freedom                                34          34
##   P-value (Chi-square)                           0.041       0.170
##   Scaling correction factor                                  1.187
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               426.299     329.448
##   Degrees of freedom                                45          45
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.294
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.959       0.973
##   Tucker-Lewis Index (TLI)                       0.946       0.964
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.974
##   Robust Tucker-Lewis Index (TLI)                            0.965
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1553.017   -1553.017
##   Scaling correction factor                                  0.959
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)             NA          NA
##   Scaling correction factor                                  1.167
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                3168.035    3168.035
##   Bayesian (BIC)                              3254.188    3254.188
##   Sample-size adjusted Bayesian (SABIC)       3156.185    3156.185
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.062       0.044
##   90 Percent confidence interval - lower         0.013       0.000
##   90 Percent confidence interval - upper         0.097       0.081
##   P-value H_0: RMSEA <= 0.050                    0.282       0.573
##   P-value H_0: RMSEA >= 0.080                    0.222       0.053
##                                                                   
##   Robust RMSEA                                               0.055
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.106
##   P-value H_0: Robust RMSEA <= 0.050                         0.420
##   P-value H_0: Robust RMSEA >= 0.080                         0.240
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.076       0.076
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   US_CR =~                                                              
##     ShCCS_C_1         1.000                               0.934    0.722
##     ShCCS_C_2 (l2)    1.276    0.134    9.498    0.000    1.192    0.823
##     ShCCS_C_3 (l3)    0.973    0.148    6.587    0.000    0.908    0.706
##     ShCCS_C_4 (l4)    1.067    0.184    5.793    0.000    0.997    0.751
##     ShCCS_C_5 (l5)    1.182    0.215    5.502    0.000    1.104    0.729
##   MX_CR =~                                                              
##     InqBl_C_1         1.000                               0.763    0.659
##     InqBl_C_2 (l2)    1.276    0.134    9.498    0.000    0.973    0.827
##     InqBl_C_3 (l3)    0.973    0.148    6.587    0.000    0.742    0.562
##     InqBl_C_4 (l4)    1.067    0.184    5.793    0.000    0.814    0.598
##     InqBl_C_5 (l5)    1.182    0.215    5.502    0.000    0.901    0.643
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .ShoCCS_Ch_1 ~~                                                        
##    .IneqBelfs_Ch_1    0.050    0.108    0.466    0.641    0.050    0.064
##  .ShoCCS_Ch_2 ~~                                                        
##    .IneqBelfs_Ch_2    0.027    0.087    0.304    0.761    0.027    0.049
##  .ShoCCS_Ch_3 ~~                                                        
##    .IneqBelfs_Ch_3    0.205    0.129    1.583    0.113    0.205    0.206
##  .ShoCCS_Ch_4 ~~                                                        
##    .IneqBelfs_Ch_4    0.387    0.130    2.967    0.003    0.387    0.405
##  .ShoCCS_Ch_5 ~~                                                        
##    .IneqBelfs_Ch_5    0.098    0.161    0.612    0.541    0.098    0.088
##   US_CR ~~                                                              
##     MX_CR             0.431    0.116    3.701    0.000    0.605    0.605
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShCCS_C_1         3.745    0.125   30.009    0.000    3.745    2.895
##    .InqBl_C_1         2.844    0.151   18.801    0.000    2.844    2.457
##    .ShCCS_C_2         3.370    0.139   24.174    0.000    3.370    2.327
##    .InqBl_C_2         2.672    0.155   17.200    0.000    2.672    2.271
##    .ShCCS_C_3 (i3)    2.852    0.117   24.465    0.000    2.852    2.218
##    .InqBl_C_3 (i3)    2.852    0.117   24.465    0.000    2.852    2.161
##    .ShCCS_C_4 (i4)    3.228    0.126   25.583    0.000    3.228    2.431
##    .InqBl_C_4 (i4)    3.228    0.126   25.583    0.000    3.228    2.372
##    .ShCCS_C_5         3.563    0.149   23.952    0.000    3.563    2.355
##    .InqBl_C_5         2.637    0.179   14.769    0.000    2.637    1.881
##     US_CR             0.000                               0.000    0.000
##     MX_CR     (m1)    0.218    0.112    1.934    0.053    0.285    0.285
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .ShoCCS_Ch_1       0.801    0.170    4.723    0.000    0.801    0.479
##    .ShoCCS_Ch_2       0.678    0.223    3.039    0.002    0.678    0.323
##    .ShoCCS_Ch_3       0.829    0.172    4.828    0.000    0.829    0.501
##    .ShoCCS_Ch_4       0.769    0.160    4.814    0.000    0.769    0.436
##    .ShoCCS_Ch_5       1.072    0.218    4.914    0.000    1.072    0.468
##    .IneqBelfs_Ch_1    0.758    0.169    4.474    0.000    0.758    0.566
##    .IneqBelfs_Ch_2    0.437    0.143    3.053    0.002    0.437    0.315
##    .IneqBelfs_Ch_3    1.191    0.208    5.733    0.000    1.191    0.684
##    .IneqBelfs_Ch_4    1.188    0.181    6.574    0.000    1.188    0.642
##    .IneqBelfs_Ch_5    1.152    0.223    5.162    0.000    1.152    0.586
##     US_CR             0.872    0.228    3.821    0.000    1.000    1.000
##     MX_CR             0.582    0.165    3.518    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     ShoCCS_Ch_1       0.521
##     ShoCCS_Ch_2       0.677
##     ShoCCS_Ch_3       0.499
##     ShoCCS_Ch_4       0.564
##     ShoCCS_Ch_5       0.532
##     IneqBelfs_Ch_1    0.434
##     IneqBelfs_Ch_2    0.685
##     IneqBelfs_Ch_3    0.316
##     IneqBelfs_Ch_4    0.358
##     IneqBelfs_Ch_5    0.414
#Wald test the means on cr 
lavTestWald(mx_cr_key_fit, constraints = "m1 == 0")
## $stat
## [1] 3.741744
## 
## $df
## [1] 1
## 
## $p.value
## [1] 0.05306904
## 
## $se
## [1] "robust.huber.white"