knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
options(scipen = 999) knitr::opts_chunk$set(echo = TRUE) library(lavaan, quietly = T) library(semPlot, quietly = T) HS.model <- ' visual =~ x1 + x2 + x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9 ' fit <- cfa(HS.model, data = HolzingerSwineford1939) HS.model2 <- 'visual =~ x1 + x2 + x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9 visual ~ speed' fit2 <- cfa(HS.model2, data = HolzingerSwineford1939) HS.model3 <- 'visual =~ x1 + x2 + x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9 visual ~ speed speed ~ textual textual ~ visual' fit3 <- cfa(HS.model3, data = HolzingerSwineford1939)
knitr::include_graphics("pictures/exo_endo.png")
knitr::include_graphics("pictures/exo_endo.png")
Y ~ X +
$\epsilon$Endogenous ~ Exogenous + Residual
semPaths(fit, whatLabels = "std", edge.label.cex = 1)
semPaths(fit2, whatLabels = "std", edge.label.cex = 1)
knitr::include_graphics("pictures/full_sem.png")
semPaths(fit2, whatLabels = "std", edge.label.cex = 1)
semPaths(fit3, whatLabels = "std", edge.label.cex = 1)
Unstandardized estimates
regressions ~
latent variables =~
Covariances ~~
: the amount two variables vary together summary(fit2)
Standardized estimates: note there are several ways to "standardize" the solution, we will cover this more later
Regressions ~
: the $\beta$ coefficient, z-scored bLatent variables =~
: the correlation between a measured and latent variable, usually called loadings like EFACovariance ~~
: the correlation between two variables summary(fit2, standardized = T, rsquare = T)
Y ~ X +
$\epsilon$knitr::include_graphics("pictures/model_steps.png")
2x = 4
has one answer2x + y = 10
has many answerssemPaths(fit)
summary(fit)
summary(fit, standardized = T)
lavaan
gives you somewhat good warnings hessian matrix not definite
In this lecture you've learned:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.