knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This supplementary document illustrates the use of the accompanying R package equaltestMI. The sample statistics from Table 1 of Lee and Al Otaiba (2015) are used as an example. The description of the data can be found in the original article and the results obtained from equaltestMI are discussed at length in the published article “Advances in Measurement Invariance and Mean Comparison of Latent Variables: Equivalence Testing and A Projection-Based Approach”
The R package equaltestMI is available on CRAN and can be downloaded for use on any R platform with version higher than 3.1.0. Users can pass different arguments to the main function eqMI.main() to examine measurement invariance using the conventional multiple-group approach (NHT) or equivalence testing (ET) approach. Under the framework of equivalence testing, users obtain the minimum tolerable size (T-size) and adjusted cutoff values to evaluate the goodness-of-fit of each invariance test. The projection method is also available for testing the equality of latent means.
This package is developed for complete dataset with two groups/time points. Use of saturated models might lead to problems in calculation of adjusted RMSEA thresholds. Please consider alternative methods if you have datasets that do not satisfy the requirements.
Users can install the package from CRAN:
## load package # install.packages("equaltestMI") library(equaltestMI)
or install the most recent version from the maintainer's GitHub repository:
# install.packages("devtools") # library(devtools) # devtools::install_github("gabriellajg/equaltestMI", force=TRUE) library(equaltestMI)
Load data first:
data(LeeAlOtaiba) # contains sample covariance matrices and sample means of four groups
We will use two of the groups as illustration:
## group 1 = boys ineligible for free-reduced lunches Group1 <- LeeAlOtaiba$BoysIneligible Group1 <- as.matrix(Group1) ## group 2 = boys eligible for free-reduced lunches Group2 <- LeeAlOtaiba$BoysEligible Group2 <- as.matrix(Group2) # sample means: M1 <- Group1[1,] M2 <- Group2[1,] # sample covariance matrices: Cov1 <- Group1[2:7,] Cov2 <- Group2[2:7,]
Sample means:
M1
Sample Covariance Matrix:
round(Cov1, 3)
Sample means:
M2
Sample Covariance Matrix:
round(Cov2, 3)
## lavaan model syntax model <- ' AlphabetKnowledge =~ Letter_Name+ Letter_Sound PhonologicalAwareness =~ Blending + Elision Spelling =~ Real_Words + Pseudo_Words '
## the results using equivalence testing and projection method ## full R output will be presented in Part 3 test <- eqMI.main(model = model, sample.nobs = c(78, 174), sample.mean = list(M1, M2), sample.cov = list(Cov1, Cov2), meanstructure = TRUE, output = 'both', quiet = TRUE, equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE, bootstrap = FALSE)
## the results using equivalence testing and projection method test <- eqMI.main(model = model, sample.nobs = c(78, 174), sample.mean = list(M1, M2), sample.cov = list(Cov1, Cov2), meanstructure = TRUE, output = 'both', quiet = FALSE, equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE, bootstrap = FALSE)
test1 <- eqMI.main(model = model, sample.nobs = c(78, 174), sample.cov = list(Cov1, Cov2), sample.mean = list(M1, M2), meanstructure = TRUE, equivalence.test = FALSE, adjRMSEA = FALSE)
test2 <- eqMI.main(model = model, sample.nobs = c(78, 174), sample.cov = list(Cov1, Cov2), sample.mean = list(M1, M2), meanstructure = TRUE, equivalence.test = FALSE, adjRMSEA = FALSE, projection = TRUE)
test3 <- eqMI.main(model = model, sample.nobs = c(78, 174), sample.cov = list(Cov1, Cov2), sample.mean = list(M1, M2), meanstructure = TRUE, equivalence.test = TRUE, adjRMSEA = FALSE)
test4 <- eqMI.main(model = model, sample.nobs = c(78, 174), sample.cov = list(Cov1, Cov2), sample.mean = list(M1, M2), meanstructure = TRUE, equivalence.test = TRUE, adjRMSEA = TRUE)
test5 <- eqMI.main(model = model, sample.nobs = c(78, 174), sample.cov = list(Cov1, Cov2), sample.mean = list(M1, M2), meanstructure = TRUE, equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE)
test6 <- eqMI.main(model = model, structure = 'mean', sample.nobs = c(78, 174), sample.cov = list(Cov1, Cov2), sample.mean = list(M1, M2), meanstructure = TRUE, equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE)
test7 <- eqMI.main(model = model, data = literacy.dat, group = "FRL", meanstructure = TRUE, equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE)
test8 <- eqMI.main(model = model, data = literacy.dat, group = "FRL", meanstructure = TRUE, equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE, bootstrap = TRUE)
test9 <- eqMI.main(model = model, data = literacy.dat, group = "FRL", meanstructure = TRUE, equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE, bootstrap = FALSE, quite = TRUE)
test10 <- eqMI.main(model = model, data = literacy.dat, group = "FRL", meanstructure = TRUE, group.partial = c("Spelling=~Real_Words", "Blending~1"), equivalence.test = TRUE, adjRMSEA = TRUE, projection = TRUE)
so that the loadings of 'Spelling' on 'Real_Words' and the intercept of 'Blending' are allowed to vary across groups.
For a complete view of the help page of function eqMI.main(), please install R package printr and type ?eqMI.main in R console:
library(printr) ?eqMI.main
# For a complete view of the help page of function eqMI.main(), please install R package printr and type ?eqMI.main in R console: #library(printr) #?eqMI.main #output: pdf_document #devtools::build_vignettes() #R CMD Rd2pdf "~/Box Sync/MacSync/Research/Frontier/equaltestMI" #R CMD check --as-cran equaltestMI_0.6.0.tar.gz #https://bookdown.org/yihui/rmarkdown-cookbook/package-vignette.html
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.