
A Function That Fits and Examines Competing Dyadic Uni-construct Models
Source:R/getUniConstructMods.R
getUniConstructMods.Rd
This function takes the outputted object from scrapeVarCross()
along with the corresponding dataset and automatically tests competing
uni-construct dyadic models for the latent variable under consideration.
It inspects four possible model variants:
Unidimensional (via
scriptUni
)Correlated Factors (via
scriptCor
)Hierarchical (via
scriptHier
)Bifactor (via
scriptBifac
)
Usage
getUniConstructMods(
dvn,
dat,
indexes = c("npar", "df", "chisq", "cfi", "rmsea", "tli", "aic", "bic"),
modelCompare = TRUE,
genTEFI = TRUE,
...
)
Arguments
- dvn
Input dvn list from
scrapeVarCross()
.- dat
Input data frame containing the dataset for model estimation.
- indexes
Input character vector specifying which index(es) to return. Default is
c("npar", "df", "chisq", "cfi", "rmsea", "tli", "aic", "bic")
. Note: Must be valid options fromlavaan::fitMeasures()
.- modelCompare
A logical input indicating whether to compare fit statistics (i.e., chi-squared, AIC, and BIC) of the fitted models. The default is
TRUE
. Note: A scaled chi-squared difference test will automatically be applied (vialavaan::lavTestLRT()
) if a robust estimator variant (e.g.,estimator = "mlr"
) is used.- genTEFI
A logical input indicating whether to compute the Generalized Total Entropy Fit Index (genTEFI) (see Golino et al., 2024). Default is
TRUE
.- ...
Additional arguments to be passed to
lavaan::cfa()
, allowing users to customize model estimation settings. By default, the models will be fit with robust maximum-likelihood (MLR) estimation—estimator = "mlr"
—and missing data will handled using full-information maximum likelihood (FIML)—missing = "fiml"
.
Value
A list
containing up to three components:
Global Fit
: Atibble
with the desired index(es) for each fitted model (requested via theindexes
argument).Model Comparisons
: Atibble
summarizing the differences in fit statistics between the fitted models. (ifmodelCompare = TRUE
).genTEFI
: Atibble
of the genTEFI (ifgenTEFI = TRUE
).
Examples
dvn <- scrapeVarCross(
commitmentQ,
x_order = "spi",
x_stem = "sat.g",
x_delim1 = ".",
x_delim2="_",
distinguish_1="1",
distinguish_2="2"
)
getUniConstructMods(
dvn,
commitmentQ
)
#> $`Global Fit`
#> # A tibble: 4 × 9
#> Model npar df chisq cfi rmsea tli aic bic
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Bifactor 45 20 41.3 0.983 0.0951 0.962 3953. 4077.
#> 2 Hierarchical 36 29 49.1 0.984 0.0767 0.975 3942. 4042.
#> 3 Correlated Factors 36 29 49.1 0.984 0.0767 0.975 3942. 4042.
#> 4 Unidimensional 35 30 235. 0.839 0.240 0.758 4126. 4223.
#>
#> $`Model Comparisons`
#> # A tibble: 3 × 7
#> Comparison chisq_diff df_diff pvalue sig aic_diff bic_diff
#> <chr> <dbl> <int> <dbl> <chr> <dbl> <dbl>
#> 1 Hierarchical vs. Bifactor 5.14 9 8.22e-1 NA -10.2 -35.2
#> 2 Correlated factors vs. Hi… 0 0 NA NA 0 0
#> 3 Unidimensional vs. Correl… 24.9 1 5.96e-7 *** 184. 181.
#>
#> $genTEFI
#> # A tibble: 1 × 3
#> VN.Entropy.Fit Lower.Order.VN Higher.Order.VN
#> <dbl> <dbl> <dbl>
#> 1 -15.2 -5.75 -9.42
#>
getUniConstructMods(
dvn,
commitmentQ,
indexes = c("npar", "df", "bic"),
modelCompare = FALSE,
genTEFI = TRUE
)
#> $`Global Fit`
#> # A tibble: 4 × 4
#> Model npar df bic
#> <chr> <dbl> <dbl> <dbl>
#> 1 Bifactor 45 20 4077.
#> 2 Hierarchical 36 29 4042.
#> 3 Correlated Factors 36 29 4042.
#> 4 Unidimensional 35 30 4223.
#>
#> $genTEFI
#> # A tibble: 1 × 3
#> VN.Entropy.Fit Lower.Order.VN Higher.Order.VN
#> <dbl> <dbl> <dbl>
#> 1 -15.2 -5.75 -9.42
#>
getUniConstructMods(
dvn,
commitmentQ,
indexes = c("npar", "df", "bic"),
modelCompare = FALSE,
genTEFI = TRUE,
estimator = "ml"
)
#> $`Global Fit`
#> # A tibble: 4 × 4
#> Model npar df bic
#> <chr> <dbl> <dbl> <dbl>
#> 1 Bifactor 45 20 4077.
#> 2 Hierarchical 36 29 4042.
#> 3 Correlated Factors 36 29 4042.
#> 4 Unidimensional 35 30 4223.
#>
#> $genTEFI
#> # A tibble: 1 × 3
#> VN.Entropy.Fit Lower.Order.VN Higher.Order.VN
#> <dbl> <dbl> <dbl>
#> 1 -15.2 -5.75 -9.42
#>