Checks model IDs, construct IDs, indicators, structural path endpoints, duplicate paths, indirect paths, and engine/type compatibility.
Arguments
- model
An
sf_model()object or compatible list.- instrument
Optional
sframeobject. When supplied, model indicators must match instrument item IDs.- strict
Logical. When
TRUE, invalid models raise an error. WhenFALSE, problems are reported in the returned diagnostic without stopping.
Value
An sframe_validation object. The model is carried inside it and
can be recovered with sf_object().
Changed in 0.4.0
Earlier versions returned the model invisibly when strict = TRUE and a
bare unclassed list when strict = FALSE. Both paths now return an
sframe_validation object, visibly, so the diagnostic is readable at the
console. Code that read $valid and $problems keeps working.
Examples
demo <- sframe_demo_data()
m <- sf_model(
"cb1", type = "cb_sem",
constructs = list(
sf_construct("sq", items = c("sq_1", "sq_2", "sq_3")),
sf_construct("sat", items = c("sat_1", "sat_2"))
),
paths = list(sf_path("sq", "sat"))
)
diag <- validate_model(m, instrument = demo$instrument)
diag
#> <sframe validation>
#> Model: cb1 (cb_sem)
#> Status: valid
#> Checks: 10 run, 0 with problems