# NOT RUN {
## These run longer than 5 seconds
## CFA model
require(lavaan)
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9'
output1 <- cfa(HS.model, data = HolzingerSwineford1939, std.lv = TRUE)
semTable(output1, fit = "rmsea",
standardized = TRUE, type = "latex")
## Basic SEM model
regmodel <- "x1 ~ x2 + x3
x1 ~1"
output1a <- sem(regmodel, data = HolzingerSwineford1939, std.lv = TRUE)
semTable(output1a, fit = "rmsea", type = "html")
#### Example with file output
##semTable(output1, file = "exampleTable.html", fit = "rmsea",
##standardized = TRUE, params = c("loadings", "latentvariances"),
##type = "html")
model <- "factor =~ .7*y1 + .7*y2 + .7*y3 + .7*y4
y1 | -1*t1 + 1*t2
y2 | -.5*t1 + 1*t2
y3 | -.2*t1 + 1*t2
y4 | -1*t1 + 1*t2
"
dat <- simulateData(model, sample.nobs = 300)
testmodel <- "ExampleFactor =~ y1 + y2 + y3 + y4"
output2 <- cfa(testmodel, data = dat, ordered = colnames(dat),
std.lv = FALSE)
semTable(output2,
params = c("loadings", "thresholds", "residuals"),
fit = c("tli", "chi-square"),
names_fit = c("TLI", "chi-square"), type = "html")
## Example with file output
## semTable(output, file = "catTable.tex",
## params = c("loadings", "thresholds", "residuals"),
## fit = c("tli", "chi-square"),
## names_fit = c("TLI", "chi-square"), type = "latex")
# }
Run the code above in your browser using DataLab