Compiles a theory's constructs and propositions into a lavaan model
string: constructs with measurement indicators become a latent measurement
model (=~), and propositions become structural paths (~),
covariances (~~), or moderation comment lines. The output is
deterministic.
Arguments
- theory
A theory object (named list), e.g. from
tf_read().
Examples
theory <- tf_theory("demo-1", "A demonstration theory") |>
tf_add_construct("c_arousal", "Arousal", "Bodily activation.",
measurement = c("heart-rate variability",
"self-reported arousal")) |>
tf_add_construct("c_threat", "Perceived threat", "Appraised danger.",
measurement = c("threat appraisal questionnaire")) |>
tf_add_proposition("p1", "c_arousal", "c_threat", "increases")
cat(tf_compile_sem(theory))
#> # lavaan model generated by theoryforge for demo-1
#> # Measurement model
#> c_arousal =~ heart_rate_variability + self_reported_arousal
#> c_threat =~ threat_appraisal_questionnaire
#> # Structural model
#> c_threat ~ c_arousal