View source: R/psychometrics.R
| cfa_syntax | R Documentation |
Produces a character string of lavaan model syntax derived from the
scale structure in the instrument. The syntax can be passed directly to
lavaan::cfa(). Reverse-coded items are noted in a comment but are not
transformed in the syntax; recoding should be applied to the data before
fitting the model.
cfa_syntax(instrument, scales = NULL, std_lv = TRUE)
instrument |
An |
scales |
Character vector or NULL. A subset of scale IDs to include. When NULL, all scales are included. |
std_lv |
Logical. Whether to include the |
A character string of lavaan CFA model syntax.
efa_report(), reliability_report()
cs <- sf_choices("ag5", 1:5,
c("Strongly disagree", "Disagree", "Neutral",
"Agree", "Strongly agree"))
i1 <- sf_item("sat_1", "Item 1", type = "likert",
choice_set = "ag5", scale_id = "sat")
i2 <- sf_item("sat_2", "Item 2", type = "likert",
choice_set = "ag5", scale_id = "sat")
i3 <- sf_item("sat_3", "Item 3 (reverse)", type = "likert",
choice_set = "ag5", scale_id = "sat", reverse = TRUE)
scale <- sf_scale("sat", "Satisfaction",
items = c("sat_1", "sat_2", "sat_3"))
instr <- sf_instrument("Demo Survey", components = list(cs, i1, i2, i3, scale))
syntax <- cfa_syntax(instr)
cat(syntax)
## Not run:
# lavaan is not installed by default; install it before fitting.
demo <- sframe_demo_data()
scored <- score_scales(demo$responses, demo$instrument)
fit <- lavaan::cfa(syntax, data = scored, std.lv = TRUE)
summary(fit, fit.measures = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.