
Build Implied Correlation Matrices for Observed Path Models
c_mat_ft.RdBuild Implied Correlation Matrices for Observed Path Models
Arguments
- model_input
Model input as a character string. Multiple models need to be on their own line. Regression syntax uses a lavaan-like
outcome ~ predictor1 + predictor2form.- R
A named correlation matrix, typically the pooled correlation matrix extracted from a fitted
marsobject.
Value
A list containing the directed-effects matrix, residual covariance matrix, implied correlation matrix, multiple-\(R^2\) values, number of free parameters, and model degrees of freedom.
Details
This helper builds the RAM-style matrices used by observed-variable path
models. Directed paths are stored in A_mat; residual variances and
exogenous covariances are stored in S_mat; and the implied
correlation matrix is computed as
\((I - A)^{-1} S (I - A)^{-T}\).
Examples
Br <- matrix(c(1.00000000, -0.09773331, -0.1755029, 0.3186775,
-0.09773331, 1.00000000, 0.5271873, -0.4175596,
-0.17550292, 0.5271872, 1.0000000, -0.4006848,
0.31867753, -0.41755963, -0.4006848, 1.0000000),
nrow = 4, byrow = TRUE)
colnames(Br) <- c("Performance", "Self_confidence", "Cognitive", "Somatic" )
rownames(Br) <- colnames(Br)
## Proposed path model
model <- "## Regression paths
Performance ~ Self_confidence + Cognitive + Somatic
Self_confidence ~ Cognitive + Somatic "
c_mat_ft(model, Br)
#> $model_input
#> [1] "## Regression paths\nPerformance ~ Self_confidence + Cognitive + Somatic\nSelf_confidence ~ Cognitive + Somatic "
#>
#> $A_mat
#> Performance Self_confidence Cognitive Somatic
#> Performance 0 0.08316153 -0.09261001 0.3162950
#> Self_confidence 0 0.00000000 0.42870532 -0.2457839
#> Cognitive 0 0.00000000 0.00000000 0.0000000
#> Somatic 0 0.00000000 0.00000000 0.0000000
#>
#> $S_mat
#> Performance Self_confidence Cognitive Somatic
#> Performance 0.8910782 0.0000000 0.0000000 0.0000000
#> Self_confidence 0.0000000 0.6713626 0.0000000 0.0000000
#> Cognitive 0.0000000 0.0000000 1.0000000 -0.4006848
#> Somatic 0.0000000 0.0000000 -0.4006848 1.0000000
#>
#> $F_mat
#> Performance Self_confidence Cognitive Somatic
#> Performance 1 0 0 0
#> Self_confidence 0 1 0 0
#> Cognitive 0 0 1 0
#> Somatic 0 0 0 1
#>
#> $C_mat
#> Performance Self_confidence Cognitive Somatic
#> Performance 1.00000000 -0.09773331 -0.1755029 0.3186775
#> Self_confidence -0.09773331 1.00000000 0.5271872 -0.4175596
#> Cognitive -0.17550292 0.52718720 1.0000000 -0.4006848
#> Somatic 0.31867753 -0.41755963 -0.4006848 1.0000000
#>
#> $Mul_R2
#> Performance Self_confidence
#> 0.1089218 0.3286374
#>
#> $num_freePar
#> [1] 8
#>
#> $df
#> [1] 2
#>