Skip to contents

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)

Arguments

syntax

A character string containing lavaan model syntax. Must at least include the measurement relations (=~).

data

A data.frame, tibble or 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`.

Value

An object of S3 class `modsem_relcorr` (a named list) with elements:

`syntax`

Modified lavaan syntax string.

`data`

Data frame with additional composite indicator columns.

`parTable`

Parameter table corresponding to `syntax`.

`reliability`

Named numeric vector of reliabilities (one per latent variable).

`AVE`

Named numeric vector with Average Variance Extracted values.

`lVs`

Character vector of latent variables that were corrected.

`single.items`

Character 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 =~ att3 + att2 + att1 + att4
 SN =~ sn4 + sn2 + sn3 + sn1
 PBC =~ pbc2 + pbc1 + pbc3 + pbc4
 INT =~ int2 + int1 + int3 + int4
 BEH =~ beh3 + beh2 + beh1 + beh4

# 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.773
#>   SN:     0.759
#>   PBC:    0.765
#>   INT:    0.790
#>   BEH:    0.769
#> 
#> Chronbach's Alpha:
#>   ATT:    0.941
#>   SN:     0.917
#>   PBC:    0.931
#>   INT:    0.984
#>   BEH:    0.942
#> 
#> 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.230703252252833*composite_ATT_
#>   composite_SN_ ~~ 0.219569422798239*composite_SN_
#>   composite_PBC_ ~~ 0.269459429965901*composite_PBC_
#>   composite_INT_ ~~ 0.0783705643995773*composite_INT_
#>   composite_BEH_ ~~ 0.276556964349188*composite_BEH_
#>   
#> Generated Items:
#>   'data.frame':	1169 obs. of  5 variables:
#>     $ composite_ATT_: num  5.5 5 2 5.5 4.5 1 1 1 4.25 6.25 ...
#>     $ composite_SN_ : num  6.5 4.75 3.5 6.5 5.25 3 2.25 4 4.5 6 ...
#>     $ composite_PBC_: num  4 4.5 1.75 5.75 5.5 1 1 1 5 5.75 ...
#>     $ composite_INT_: num  4 4.5 1 5.25 5.25 1 1 1 5 5 ...
#>     $ composite_BEH_: num  1 3.75 1.25 2.75 5.25 1 1 1 2.5 5.5 ...

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 (version 1.0.11):
#> 
#>   Estimator                                         LMS
#>   Optimization method                        EMA-NLMINB
#>   Number of observations                           1169
#>   Number of iterations                               49
#>   Loglikelihood                                -7276.79
#>   Akaike (AIC)                                 14591.57
#>   Bayesian (BIC)                               14687.79
#>  
#> Numerical Integration:
#>   Points of integration (per dim)                    32
#>   Dimensions                                          1
#>   Total points of integration                        32
#>  
#> Fit Measures for Baseline Model (H0):
#>   Loglikelihood                                -9352.47
#>   Akaike (AIC)                                 18740.95
#>   Bayesian (BIC)                                18832.1
#>   Chi-square                                      34.76
#>   Degrees of Freedom (Chi-square)                     2
#>   P-value (Chi-square)                            0.000
#>   RMSEA                                           0.118
#>  
#> Comparative Fit to H0 (LRT test):
#>   Loglikelihood change                          2075.69
#>   Difference test (D)                           4151.38
#>   Degrees of freedom (D)                              1
#>   P-value (D)                                     0.000
#>  
#> R-Squared Interaction Model (H1):
#>   INT                                             0.865
#>   BEH                                             0.940
#> R-Squared Baseline Model (H0):
#>   INT                                             0.856
#>   BEH                                             0.869
#> R-Squared Change (H1 - H0):
#>   INT                                             0.009
#>   BEH                                             0.071
#> 
#> Parameter Estimates:
#>   Coefficients                           unstandardized
#>   Information                                  observed
#>   Standard errors                              standard
#>  
#> Latent Variables:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>    PBC =~        
#>      cmpst_PBC_      1.000                             
#>    ATT =~        
#>      cmpst_ATT_      1.000                             
#>    SN =~         
#>      compst_SN_      1.000                             
#>    INT =~        
#>      cmpst_INT_      1.000                             
#>    BEH =~        
#>      cmpst_BEH_      1.000                             
#> 
#> Regressions:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>    INT ~         
#>      PBC             1.054      0.053   19.825    0.000
#>      ATT             0.000      0.051   -0.008    0.993
#>      SN              0.026      0.030    0.871    0.384
#>    BEH ~         
#>      PBC             0.719      0.043   16.802    0.000
#>      INT             0.301      0.036    8.372    0.000
#>      PBC:INT         0.150      0.008   18.283    0.000
#> 
#> Intercepts:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     .cmpst_PBC_      3.956      0.031  128.919    0.000
#>     .cmpst_ATT_      3.926      0.038  104.339    0.000
#>     .compst_SN_      4.466      0.038  117.695    0.000
#>     .cmpst_INT_      3.851      0.038  100.233    0.000
#>     .cmpst_BEH_      2.660      0.051   52.364    0.000
#> 
#> Covariances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>    PBC ~~        
#>      ATT             3.516      0.091   38.798    0.000
#>      SN              2.296      0.086   26.562    0.000
#>    ATT ~~        
#>      SN              2.187      0.091   24.055    0.000
#> 
#> Variances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     .cmpst_PBC_      0.269                             
#>     .cmpst_ATT_      0.231                             
#>     .compst_SN_      0.220                             
#>     .cmpst_INT_      0.078                             
#>     .cmpst_BEH_      0.277                             
#>      PBC             3.905      0.094   41.382    0.000
#>      ATT             3.916      0.127   30.785    0.000
#>      SN              2.527      0.104   24.215    0.000
#>     .INT             0.695      0.044   15.773    0.000
#>     .BEH             0.328      0.032   10.347    0.000
#> 
# }