Replace (some of) the first‑order latent variables in a lavaan measurement model by single composite indicators whose error variances are fixed from Cronbach's \(\alpha\). The function returns a modified lavaan model syntax together with an augmented data set that contains the newly created composite variables, so that you can fit the full SEM in a single step.
Usage
relcorr_single_item(
syntax,
data,
choose = NULL,
scale.corrected = TRUE,
missing = "fiml",
warn.lav = TRUE,
group = NULL
)Arguments
- syntax
A character string containing lavaan model syntax. Must at least include the measurement relations (
=~).- data
A
data.frame,tibbleor object coercible to a data frame that holds the raw observed indicators.- choose
Optional. Character vector with the names of the latent variables you wish to replace by single indicators. Defaults to all first‑order latent variables in
syntax.- scale.corrected
Should reliability-corrected items be scale-corrected? If
TRUEreliability-corrected single items are corrected for differences in factor loadings between the items. Default isTRUE.- missing
How should missing values be handled in the CFA? Default is
"fiml".- warn.lav
Should warnings from
lavaan::cfabe displayed? IfFALSE, they are suppressed.- group
Character. A variable name in the data frame defining the groups in a multiple group analysis
Value
An object of S3 class ModsemRelcorr (a named list) with elements:
syntaxModified lavaan syntax string.
dataData frame with additional composite indicator columns.
parTableParameter table corresponding to `syntax`.
reliabilityNamed numeric vector of reliabilities (one per latent variable).
AVENamed numeric vector with Average Variance Extracted values.
lVsCharacter vector of latent variables that were corrected.
single.itemsCharacter vector with names for the generated reliability corrected items
Details
The resulting object can be fed directly into modsem or lavaan::sem
by supplying syntax = $syntax and data = $data.
Examples
# \dontrun{
tpb_uk <- "
# Outer Model (Based on Hagger et al., 2007)
ATT =~ att1 + att2 + att3 + att4 + att5
SN =~ sn1 + sn2 + sn3
PBC =~ pbc1 + pbc2 + pbc3 + pbc4
INT =~ int1 + int2 + int3 + int4
BEH =~ beh1 + beh2 + beh3
# Inner Model (Based on Steinmetz et al., 2011)
INT ~ ATT + SN + PBC
BEH ~ INT + PBC
BEH ~ INT:PBC
"
corrected <- relcorr_single_item(syntax = tpb_uk, data = TPB_UK)
print(corrected)
#> Average Variance Extracted:
#> ATT: 0.695
#> SN: 0.796
#> PBC: 0.504
#> INT: 0.931
#> BEH: 0.881
#>
#> Chronbach's Alpha:
#> ATT: 0.921
#> SN: 0.917
#> PBC: 0.786
#> INT: 0.982
#> BEH: 0.955
#>
#> Generated Syntax:
#> INT ~ ATT
#> INT ~ SN
#> INT ~ PBC
#> BEH ~ INT
#> BEH ~ PBC
#> BEH ~ INT:PBC
#> ATT =~ 1*composite_ATT_
#> SN =~ 1*composite_SN_
#> PBC =~ 1*composite_PBC_
#> INT =~ 1*composite_INT_
#> BEH =~ 1*composite_BEH_
#> composite_ATT_ ~~ 0.19391723*composite_ATT_
#> composite_SN_ ~~ 0.15072929*composite_SN_
#> composite_PBC_ ~~ 0.06217143*composite_PBC_
#> composite_INT_ ~~ 0.07815740*composite_INT_
#> composite_BEH_ ~~ 0.14644270*composite_BEH_
#>
#> Generated Items:
#> 'data.frame': 1894 obs. of 5 variables:
#> $ composite_ATT_: num 3.73 3.73 5.68 1.95 1.78 ...
#> $ composite_SN_ : num 3.114 4.247 5.38 0.849 3.398 ...
#> $ composite_PBC_: num 1.62 1.62 2.23 1.62 1.62 ...
#> $ composite_INT_: num 0.978 3.423 3.912 0.978 0.978 ...
#> $ composite_BEH_: num 0.872 0.872 0.872 0.872 0.872 ...
syntax <- corrected$syntax
data <- corrected$data
est_dca <- modsem(syntax, data = data, method = "dblcent")
est_lms <- modsem(syntax, data = data, method="lms", nodes=32)
summary(est_lms)
#>
#> modsem (1.0.24) ended normally after 54 iterations
#>
#> Estimator LMS
#> Optimization method EMA-NLMINB
#> Number of model parameters 19
#>
#> Number of observations 1894
#>
#> Loglikelihood and Information Criteria:
#> Loglikelihood -12151.28
#> Akaike (AIC) 24340.56
#> Bayesian (BIC) 24445.94
#>
#> Numerical Integration:
#> Standard Effective
#> Points of integration (per dim) 32 175
#> Dimensions 1 1
#> Total points of integration 32 175
#>
#> Fit Measures for Baseline Model (H0):
#> Standard
#> Chi-square 21.06
#> Degrees of Freedom (Chi-square) 2
#> P-value (Chi-square) 0.000
#> RMSEA 0.071
#>
#> Loglikelihood -12272.68
#> Akaike (AIC) 24581.36
#> Bayesian (BIC) 24681.19
#>
#> Comparative Fit to H0 (LRT test):
#> Loglikelihood change 121.40
#> Difference test (D) 242.80
#> Degrees of freedom (D) 1
#> P-value (D) 0.000
#>
#> R-Squared Interaction Model (H1):
#> INT 0.853
#> BEH 0.867
#> R-Squared Baseline Model (H0):
#> INT 0.852
#> BEH 0.828
#> R-Squared Change (H1 - H0):
#> INT 0.002
#> BEH 0.039
#>
#> Parameter Estimates:
#> Coefficients unstandardized
#> Information observed
#> Standard errors standard
#>
#> Latent Variables:
#> Estimate Std.Error z.value P(>|z|)
#> ATT =~
#> cmpst_ATT_ 1.000
#> SN =~
#> compst_SN_ 1.000
#> PBC =~
#> cmpst_PBC_ 1.000
#> INT =~
#> cmpst_INT_ 1.000
#> BEH =~
#> cmpst_BEH_ 1.000
#>
#> Regressions:
#> Estimate Std.Error z.value P(>|z|)
#> INT ~
#> ATT 0.703 0.041 17.236 0.000
#> SN -0.168 0.033 -5.028 0.000
#> PBC 1.970 0.115 17.120 0.000
#> BEH ~
#> PBC 0.431 0.109 3.961 0.000
#> INT 0.707 0.028 25.507 0.000
#> INT:PBC 0.338 0.021 15.731 0.000
#>
#> Intercepts:
#> Estimate Std.Error z.value P(>|z|)
#> .cmpst_PBC_ 1.935 0.014 138.669 0.000
#> .cmpst_ATT_ 3.895 0.037 106.550 0.000
#> .compst_SN_ 3.917 0.032 121.767 0.000
#> .cmpst_INT_ 3.796 0.048 79.361 0.000
#> .cmpst_BEH_ 2.427 0.048 50.922 0.000
#>
#> Covariances:
#> Estimate Std.Error z.value P(>|z|)
#> ATT ~~
#> SN 1.591 0.063 25.297 0.000
#> PBC ~~
#> ATT 0.714 0.028 25.889 0.000
#> SN 0.551 0.023 23.660 0.000
#>
#> Variances:
#> Estimate Std.Error z.value P(>|z|)
#> .cmpst_PBC_ 0.062
#> .cmpst_ATT_ 0.194
#> .compst_SN_ 0.151
#> .cmpst_INT_ 0.078
#> .cmpst_BEH_ 0.146
#> ATT 2.337 0.082 28.415 0.000
#> SN 1.810 0.064 28.407 0.000
#> PBC 0.307 0.012 25.570 0.000
#> .INT 0.624 0.034 18.392 0.000
#> .BEH 0.471 0.023 20.877 0.000
#>
# }