Skip to contents

The general entry point for CFA syntax. It takes an instrument, and derives the constructs from its scales, or an sf_model() declaring constructs that cut across them, and it accepts correlated residuals and latent covariances.

Usage

cfa_lavaan_syntax(
  instrument = NULL,
  model = NULL,
  scales = NULL,
  ordered = FALSE,
  std_lv = TRUE,
  residual_covariances = NULL,
  latent_covariances = TRUE
)

Arguments

instrument

Optional sframe object used to derive constructs from scales when model is not supplied.

model

Optional sf_model() object.

scales

Optional scale IDs when deriving a model from an instrument.

ordered

Logical. Whether to add an ordered-item note.

std_lv

Logical. Whether to add a std.lv = TRUE note.

residual_covariances

Optional list of sf_covariance() objects for correlated residuals.

latent_covariances

Logical. Whether to include model-level latent covariances supplied in model.

Value

A lavaan syntax string.

Details

cfa_syntax() is the instrument-only convenience wrapper, kept for the scripts that call it. Start here when a model is declared, when residual covariances are needed, or when the constructs differ from the scales.

Each generator emits the language its engine reads, so they stay separate: this one and sem_lavaan_syntax() write lavaan, seminr_syntax() writes seminr, and efa_syntax() writes an exploratory plan.

Examples

demo <- sframe_demo_data()
syntax <- cfa_lavaan_syntax(demo$instrument,
                             scales = c("satisfaction", "behavioural_intention"))
cat(syntax)
#> # lavaan CFA syntax generated by surveyframe
#> # Model: Tourism Services Experience Demo CFA
#> # Recommended fitting option: std.lv = TRUE
#> # Fit with lavaan only when lavaan is installed.
#> 
#> # Tourist satisfaction (reflective)
#> satisfaction =~ sat_1 + sat_2
#> 
#> # Behavioural intention (reflective)
#> behavioural_intention =~ bi_1 + bi_2