@@ -4114,6 +4114,100 @@ ggplot(
41144114 )
41154115```
41164116
4117+ # Diagnostics {#sec-diagnostics}
4118+
4119+ For troubleshooting warnings in SEM, follow the guidance here:
4120+ < https://isaactpetersen.github.io/Principles-Psychological-Assessment/factor-analysis-pca.html#sec-troubleshooting-factorAnalysis > .
4121+
4122+ Here is how to perform various concrete steps:
4123+
4124+ - Examine descriptive statistics for expected * N* s, not too much missingness, not too little variability, no implausible values, etc.:
4125+
4126+ ``` {r}
4127+ psych::describe(longitudinalMI)
4128+ ```
4129+
4130+ - Examine a correlation matrix for excessively low—or high—correlations:
4131+
4132+ ``` {r}
4133+ cor(longitudinalMI, use = "pairwise.complete.obs")
4134+
4135+ petersenlab::cor.table(longitudinalMI)
4136+ ```
4137+
4138+ - Examine histograms for outliers and oddly distributed variables:
4139+
4140+ ``` {r}
4141+ hist(longitudinalMI$JOBSAT11)
4142+ ```
4143+
4144+ - Examine whether the model converged:
4145+
4146+ ``` {r}
4147+ lavInspect(configuralInvariance_fit, "converged")
4148+ ```
4149+
4150+ - Examine degrees of freedom:
4151+
4152+ ``` {r}
4153+ fitMeasures(configuralInvariance_fit, "df")
4154+ ```
4155+
4156+ - Examine the model parameters for standardized loadings or covariances > 1, variances < 0, etc.:
4157+
4158+ ``` {r}
4159+ parameterEstimates(configuralInvariance_fit, standardized = TRUE)
4160+ ```
4161+
4162+ Examine the variance-covariance matrix of the model parameters:
4163+
4164+ ``` {r}
4165+ lavInspect(configuralInvariance_fit, "vcov")
4166+ cov2cor(lavInspect(configuralInvariance_fit, "vcov"))
4167+ ```
4168+
4169+ - Examine the model-implied variance-covariance matrix of the observed variables:
4170+
4171+ ``` {r}
4172+ lavInspect(configuralInvariance_fit, "sigma.hat")
4173+ cov2cor(lavInspect(configuralInvariance_fit, "sigma.hat"))
4174+ ```
4175+
4176+ - Examine the model-implied variance-covariance matrix of the latent variables (for redundancy):
4177+
4178+ ``` {r}
4179+ lavInspect(configuralInvariance_fit, "cov.lv")
4180+ cov2cor(lavInspect(configuralInvariance_fit, "cov.lv"))
4181+ ```
4182+
4183+ - Check eigenvalues for negative and near-zero values:
4184+
4185+ ``` {r}
4186+ eigen(lavInspect(configuralInvariance_fit, "vcov"))$values
4187+ eigen(lavInspect(configuralInvariance_fit, "sigma.hat"))$values
4188+ eigen(lavInspect(configuralInvariance_fit, "cov.lv"))$values
4189+ ```
4190+
4191+ - Examine residuals for large values (i.e., local misfit):
4192+
4193+ ``` {r}
4194+ residuals(configuralInvariance_fit, type = "raw")
4195+ residuals(configuralInvariance_fit, type = "cor")
4196+ residuals(configuralInvariance_fit, type = "standardized")
4197+ ```
4198+
4199+ - Examine modification indices:
4200+
4201+ ``` {r}
4202+ modindices(configuralInvariance_fit, sort = TRUE)
4203+ ```
4204+
4205+ - Examine fit indices:
4206+
4207+ ``` {r}
4208+ fitMeasures(configuralInvariance_fit)
4209+ ```
4210+
41174211# Session Info
41184212
41194213``` {r}
0 commit comments