Skip to contents

Function that takes a lavaan model with standardized parameters and returns a list with model characteristics

Usage

sim_standardized_matrices(m, max_iterations = 100, composite_threshold = NULL)

Arguments

m

Structural model represented by lavaan syntax

max_iterations

Maximum number of iterations before the algorithm fails

composite_threshold

Loadings with absolute values less than this threshold will not be counted as composite indicators

Value

list of path and covariance coefficients

Details

This function supports the `~` operator for regressions, the `~~` for covariances (but not variances), and the `=~` latent variable loadings. It does not support intercepts (e.g,. `y ~ 1`), thresholds, scaling factors, formative factors, or equality constraints.

Examples

library(simstandard)
# lavaan model
m = "Latent_1 =~ 0.8 * Ob_1 + 0.7 * Ob_2 + 0.4 * Ob_3"

sim_standardized_matrices(m)
#> $RAM_matrices
#> $RAM_matrices$A
#>          Ob_1 Ob_2 Ob_3 Latent_1
#> Ob_1        0    0    0      0.8
#> Ob_2        0    0    0      0.7
#> Ob_3        0    0    0      0.4
#> Latent_1    0    0    0      0.0
#> 
#> $RAM_matrices$S
#>          Ob_1 Ob_2 Ob_3 Latent_1
#> Ob_1     0.36 0.00 0.00        0
#> Ob_2     0.00 0.51 0.00        0
#> Ob_3     0.00 0.00 0.84        0
#> Latent_1 0.00 0.00 0.00        1
#> 
#> $RAM_matrices$filter_matrix
#>          Ob_1 Ob_2 Ob_3 Latent_1
#> Ob_1        1    0    0        0
#> Ob_2        0    1    0        0
#> Ob_3        0    0    1        0
#> Latent_1    0    0    0        0
#> 
#> $RAM_matrices$iA
#>          Ob_1 Ob_2 Ob_3 Latent_1
#> Ob_1        1    0    0      0.8
#> Ob_2        0    1    0      0.7
#> Ob_3        0    0    1      0.4
#> Latent_1    0    0    0      1.0
#> 
#> 
#> $Correlations
#> $Correlations$R
#>          Ob_1 Ob_2 Ob_3 Latent_1
#> Ob_1     1.00 0.56 0.32      0.8
#> Ob_2     0.56 1.00 0.28      0.7
#> Ob_3     0.32 0.28 1.00      0.4
#> Latent_1 0.80 0.70 0.40      1.0
#> 
#> $Correlations$R_all
#>                             Ob_1         Ob_2         Ob_3  Latent_1     e_Ob_1
#> Ob_1                1.000000e+00 5.600000e-01 3.200000e-01 0.8000000  0.6000000
#> Ob_2                5.600000e-01 1.000000e+00 2.800000e-01 0.7000000  0.0000000
#> Ob_3                3.200000e-01 2.800000e-01 1.000000e+00 0.4000000  0.0000000
#> Latent_1            8.000000e-01 7.000000e-01 4.000000e-01 1.0000000  0.0000000
#> e_Ob_1              6.000000e-01 0.000000e+00 0.000000e+00 0.0000000  1.0000000
#> e_Ob_2              0.000000e+00 7.141428e-01 0.000000e+00 0.0000000  0.0000000
#> e_Ob_3              0.000000e+00 0.000000e+00 9.165151e-01 0.0000000  0.0000000
#> Latent_1_FS         9.265537e-01 8.107345e-01 4.632768e-01 0.8634146  0.3930367
#> e_Ob_1_FS           8.108637e-01 8.545002e-17 0.000000e+00 0.4586159  0.7399517
#> e_Ob_2_FS          -8.130540e-17 8.216327e-01 1.596661e-17 0.2870247 -0.3826996
#> e_Ob_3_FS           3.202639e-17 6.033007e-17 9.395729e-01 0.1138741 -0.1518321
#> Latent_1_Composite  8.150834e-01 7.977412e-01 6.936880e-01 0.8237545  0.2601330
#>                        e_Ob_2     e_Ob_3 Latent_1_FS     e_Ob_1_FS
#> Ob_1                0.0000000  0.0000000   0.9265537  8.108637e-01
#> Ob_2                0.7141428  0.0000000   0.8107345  8.545002e-17
#> Ob_3                0.0000000  0.9165151   0.4632768  0.000000e+00
#> Latent_1            0.0000000  0.0000000   0.8634146  4.586159e-01
#> e_Ob_1              0.0000000  0.0000000   0.3930367  7.399517e-01
#> e_Ob_2              1.0000000  0.0000000   0.2889398 -4.495335e-01
#> e_Ob_3              0.0000000  1.0000000   0.1286515 -2.001564e-01
#> Latent_1_FS         0.2889398  0.1286515   1.0000000  5.311653e-01
#> e_Ob_1_FS          -0.4495335 -0.2001564   0.5311653  1.000000e+00
#> e_Ob_2_FS           0.8691753 -0.1252679   0.3324298 -5.171954e-01
#> e_Ob_3_FS          -0.1116189  0.9754593   0.1318881 -2.051919e-01
#> Latent_1_Composite  0.3096202  0.3973597   0.9540659  3.515540e-01
#>                        e_Ob_2_FS     e_Ob_3_FS Latent_1_Composite
#> Ob_1               -8.130540e-17  3.202639e-17          0.8150834
#> Ob_2                8.216327e-01  6.033007e-17          0.7977412
#> Ob_3                1.596661e-17  9.395729e-01          0.6936880
#> Latent_1            2.870247e-01  1.138741e-01          0.8237545
#> e_Ob_1             -3.826996e-01 -1.518321e-01          0.2601330
#> e_Ob_2              8.691753e-01 -1.116189e-01          0.3096202
#> e_Ob_3             -1.252679e-01  9.754593e-01          0.3973597
#> Latent_1_FS         3.324298e-01  1.318881e-01          0.9540659
#> e_Ob_1_FS          -5.171954e-01 -2.051919e-01          0.3515540
#> e_Ob_2_FS           1.000000e+00 -1.284194e-01          0.3562229
#> e_Ob_3_FS          -1.284194e-01  1.000000e+00          0.4073565
#> Latent_1_Composite  3.562229e-01  4.073565e-01          1.0000000
#> 
#> 
#> $Coefficients
#> $Coefficients$factor_score
#>      Latent_1_FS  e_Ob_1_FS  e_Ob_2_FS  e_Ob_3_FS
#> Ob_1   0.5655894  0.9125475 -0.5543885 -0.2468434
#> Ob_2   0.3493346 -0.4657795  1.0578637 -0.1524621
#> Ob_3   0.1211977 -0.1615970 -0.1187975  1.0381944
#> 
#> $Coefficients$factor_score_validity
#> Latent_1_FS   e_Ob_1_FS   e_Ob_2_FS   e_Ob_3_FS 
#>   0.8634146   0.7399517   0.8691753   0.9754593 
#> 
#> $Coefficients$factor_score_se
#> Latent_1_FS   e_Ob_1_FS   e_Ob_2_FS   e_Ob_3_FS 
#>   0.5044950   0.6726600   0.4945040   0.2201797 
#> 
#> $Coefficients$composite_score
#>      Latent_1_Composite
#> Ob_1           0.433555
#> Ob_2           0.433555
#> Ob_3           0.433555
#> 
#> $Coefficients$composite_score_validity
#> Latent_1_Composite 
#>          0.8237545 
#> 
#> 
#> $lavaan_models
#> $lavaan_models$model_without_variances
#> [1] "Latent_1 =~ 0.8 * Ob_1 + 0.7 * Ob_2 + 0.4 * Ob_3"
#> 
#> $lavaan_models$model_with_variances
#> [1] "Latent_1 =~ 0.8 * Ob_1 + 0.7 * Ob_2 + 0.4 * Ob_3\n# Variances\nOb_1 ~~ 0.36 * Ob_1\nOb_2 ~~ 0.51 * Ob_2\nOb_3 ~~ 0.84 * Ob_3\nLatent_1 ~~ 1 * Latent_1"
#> 
#> $lavaan_models$model_free
#> [1] "Latent_1 =~ Ob_1 + Ob_2 + Ob_3"
#> 
#> 
#> $v_names
#> $v_names$v_observed
#> [1] "Ob_1" "Ob_2" "Ob_3"
#> 
#> $v_names$v_latent
#> [1] "Latent_1"
#> 
#> $v_names$v_latent_exogenous
#> [1] "Latent_1"
#> 
#> $v_names$v_latent_endogenous
#> character(0)
#> 
#> $v_names$v_observed_exogenous
#> character(0)
#> 
#> $v_names$v_observed_endogenous
#> [1] "Ob_1" "Ob_2" "Ob_3"
#> 
#> $v_names$v_observed_indicator
#> [1] "Ob_1" "Ob_2" "Ob_3"
#> 
#> $v_names$v_disturbance
#> character(0)
#> 
#> $v_names$v_error
#> [1] "e_Ob_1" "e_Ob_2" "e_Ob_3"
#> 
#> $v_names$v_residual
#> [1] "e_Ob_1" "e_Ob_2" "e_Ob_3"
#> 
#> $v_names$v_factor_score
#> [1] "Latent_1_FS"
#> 
#> $v_names$v_factor_score_disturbance
#> character(0)
#> 
#> $v_names$v_factor_score_error
#> [1] "e_Ob_1_FS" "e_Ob_2_FS" "e_Ob_3_FS"
#> 
#> $v_names$v_composite_score
#> [1] "Latent_1_Composite"
#> 
#> 
#> $iterations
#> [1] 2
#> 
#> attr(,"class")
#> [1] "simstandard" "list"