Title: | Evaluation of the Role of Control Variables in Structural Equation Models |
---|---|
Description: | Various opportunities to evaluate the effects of including one or more control variable(s) in structural equation models onto model-implied variances, covariances, and parameter estimates. The derivation of the methodology employed in this package can be obtained from Blötner (2023) <doi:10.31234/osf.io/dy79z>. |
Authors: | Christian Blötner [aut, cre] |
Maintainer: | Christian Blötner <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-11-29 08:41:52 UTC |
Source: | CRAN |
Comprehensive heads-on comparison of pertinent parameter estimates of two structural equation models that only differ in terms of the inclusion or exclusion of one or more control variable(s). Thereby, standardized loadings, path coefficients, and covariances as well as p-values are displayed. The models must have been fitted with the R package lavaan (Rosseel, 2012) <doi:10.18637/jss.v048.i02>. The derivation of the methodology employed in this package can be obtained from Blötner (2023) <doi:10.31234/osf.io/dy79z>.
compare.res(object_with, object_without)
compare.res(object_with, object_without)
object_with |
Fitted lavaan object involving the control variable(s). |
object_without |
Fitted lavaan object without the control variable(s). |
Results |
A list containing the parameter estimates of the structural equation models with and without the control variable(s) outlined below. |
lhs |
Left-hand side of the parameter estimate both models contain. |
op |
Operator ('=~' indicates a loading, '~' a prediction of the left-hand side object by the right-hand side object, and '~~' an undirected covariance. See the documentation of the lavaan package (Rosseel, 2012) for details.) |
rhs |
Right-hand side of the parameter estimate both models contain. |
label |
If there are labelled parameters in the lavaan syntax, the respective labels will be echoed in the output of the compare.res() function. |
est.std.with |
Standardized parameter estimate in the model with the control variable(s). |
p.with |
p-value of the standardized parameter estimate in the model with the control variable(s). |
est.std.wo |
Standardized parameter estimate in the model without the control variable(s). |
p.wo |
p-value of the standardized parameter estimate in the model without the control variable(s). |
r |
Bivariate correlation between the parameter estimates detected in both models as an index of profile similarity. |
Christian Blötner [email protected]
Blötner, C. (2023). latcontrol: Evaluation of the role of control variables in structural equation models. PsyArXiv. https://doi.org/10.31234/osf.io/dy79z
Rosseel, Y. (2012). lavaan: An R package for structural equation modeling. Journal of Statistical Software, 48(2), 1–36. https://doi.org/10.18637/jss.v048.i02
data <- data.frame(i1 = rnorm(100), i2 = rnorm(100), i3 = rnorm(100), i4 = rnorm(100), i5 = rnorm(100), i6 = rnorm(100), i7 = rnorm(100), i8 = rnorm(100), i9 = rnorm(100), i10 = rnorm(100), i11 = rnorm(100), i12 = rnorm(100)) m_with <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 CV =~ i9 + i10 + i11 + i12 DV ~ IV + CV IV ~ CV' m_without <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 DV ~ IV' fit_with <- sem(m_with, data = data) fit_without <- sem(m_without, data = data) compare.res(fit_with, fit_without)
data <- data.frame(i1 = rnorm(100), i2 = rnorm(100), i3 = rnorm(100), i4 = rnorm(100), i5 = rnorm(100), i6 = rnorm(100), i7 = rnorm(100), i8 = rnorm(100), i9 = rnorm(100), i10 = rnorm(100), i11 = rnorm(100), i12 = rnorm(100)) m_with <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 CV =~ i9 + i10 + i11 + i12 DV ~ IV + CV IV ~ CV' m_without <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 DV ~ IV' fit_with <- sem(m_with, data = data) fit_without <- sem(m_without, data = data) compare.res(fit_with, fit_without)
Computation of the differences between the variances and covariances of items implied by two structural equation models that only differ in terms of inclusion or exclusion of one or more control variable(s). Both models need to be fitted with the R package lavaan (Rosseel, 2012) <doi:10.18637/jss.v048.i02>. The derivation of the methodology employed in this package can be obtained from Blötner (2023) <doi:10.31234/osf.io/dy79z>.
object_with |
Fit object from the lavaan package with the control variable(s). |
object_without |
Fit object from the lavaan package without the control variable(s). |
type |
Optional. Specifies whether a single-level structural equation model or a multilevel structural equation model is entered (DEFAULT = "simple"). |
raw |
A matrix of unstandardized residuals. |
cor |
A matrix of correlation residuals. |
Christian Blötner [email protected]
Blötner, C. (2023). latcontrol: Evaluation of the role of control variables in structural equation models. PsyArXiv. https://doi.org/10.31234/osf.io/dy79z
Rosseel, Y. (2012). lavaan: An R package for structural equation modeling. Journal of Statistical Software, 48(2), 1–36. https://doi.org/10.18637/jss.v048.i02
data <- data.frame(i1 = rnorm(100), i2 = rnorm(100), i3 = rnorm(100), i4 = rnorm(100), i5 = rnorm(100), i6 = rnorm(100), i7 = rnorm(100), i8 = rnorm(100), i9 = rnorm(100), i10 = rnorm(100), i11 = rnorm(100), i12 = rnorm(100)) m_with <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 CV =~ i9 + i10 + i11 + i12 DV ~ IV + CV IV ~ CV' m_without <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 DV ~ IV' fit_with <- sem(m_with, data = data) fit_without <- sem(m_without, data = data) get_resid(fit_with, fit_without)
data <- data.frame(i1 = rnorm(100), i2 = rnorm(100), i3 = rnorm(100), i4 = rnorm(100), i5 = rnorm(100), i6 = rnorm(100), i7 = rnorm(100), i8 = rnorm(100), i9 = rnorm(100), i10 = rnorm(100), i11 = rnorm(100), i12 = rnorm(100)) m_with <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 CV =~ i9 + i10 + i11 + i12 DV ~ IV + CV IV ~ CV' m_without <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 DV ~ IV' fit_with <- sem(m_with, data = data) fit_without <- sem(m_without, data = data) get_resid(fit_with, fit_without)
Evaluation of the model-implied variance-covariance matrices of two structural equation models that only differ by the inclusion versus exclusion of one or more control variable(s). Both models need to be fitted with the R package lavaan (Rosseel, 2012) <doi:10.18637/jss.v048.i02>. The derivation of the methodology employed in this package can be obtained from Blötner (2023) <doi:10.31234/osf.io/dy79z>.
latcontrol(object_with, object_without, type = c("simple", "complex"))
latcontrol(object_with, object_without, type = c("simple", "complex"))
object_with |
Fit object from the 'lavaan' package (Rosseel, 2012 <doi:10.18637/jss.v048.i02>) with the control variable(s). |
object_without |
Fit object from the 'lavaan' package (Rosseel, 2012 <doi:10.18637/jss.v048.i02>) without the control variable(s). |
type |
Optional. Specifies whether a single-level structural equation model or a multilevel structural equation model is entered (DEFAULT = "simple"). |
The latcontrol function itself was derived from the discrepancy function from confirmatory factor analysis and structural equation models. In analogy to the latter latent model classes, the function provides a chi-square-based index of discrepancy, model degrees of freedom, a p-value, and derivatives of common descriptive model fit indices (i.e., Root Mean Square Error of Approximation and Square Root Mean Residual).
X2 |
Chi-square value, reflecting the difference between the two matrices. |
df |
Degrees of freedom of the Chi-square statistic. |
p_value |
Corresponding p-value of the Chi-square statistic with the stated degrees of freedom. |
rmsea |
Adapted version of the Root Mean Square Error of Approximation to evaluate whether the two matrices differ. |
srmr |
Adapted version of the Square Root Mean Residual to evaluate whether the two matrices differ. |
Christian Blötner [email protected]
Blötner, C. (2023). latcontrol: Evaluation of the role of control variables in structural equation models. PsyArXiv. https://doi.org/10.31234/osf.io/dy79z
Rosseel, Y. (2012). lavaan: An R package for structural equation modeling. Journal of Statistical Software, 48(2), 1–36. https://doi.org/10.18637/jss.v048.i02
data <- data.frame(i1 = rnorm(100), i2 = rnorm(100), i3 = rnorm(100), i4 = rnorm(100), i5 = rnorm(100), i6 = rnorm(100), i7 = rnorm(100), i8 = rnorm(100), i9 = rnorm(100), i10 = rnorm(100), i11 = rnorm(100), i12 = rnorm(100)) m_with <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 CV =~ i9 + i10 + i11 + i12 DV ~ IV + CV IV ~ CV' m_without <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 DV ~ IV' fit_with <- sem(m_with, data = data) fit_without <- sem(m_without, data = data) latcontrol(fit_with, fit_without)
data <- data.frame(i1 = rnorm(100), i2 = rnorm(100), i3 = rnorm(100), i4 = rnorm(100), i5 = rnorm(100), i6 = rnorm(100), i7 = rnorm(100), i8 = rnorm(100), i9 = rnorm(100), i10 = rnorm(100), i11 = rnorm(100), i12 = rnorm(100)) m_with <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 CV =~ i9 + i10 + i11 + i12 DV ~ IV + CV IV ~ CV' m_without <- 'IV =~ i1 + i2 + i3 + i4 DV =~ i5 + i6 + i7 + i8 DV ~ IV' fit_with <- sem(m_with, data = data) fit_without <- sem(m_without, data = data) latcontrol(fit_with, fit_without)