Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Lavaan Cfa Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-lavaan-cfa-knowledge-patch)
---
name: lavaan-cfa-knowledge-patch
description: lavaan / CFA
version: null
license: MIT
metadata:
author: Nevaberry
---
# lavaan / CFA Compatibility
Use this skill when writing or updating lavaan / CFA model syntax,
estimation options, grouped or multilevel models, and diagnostic workflows.
The references contain the detailed guidance and examples for each topic.
## Reference index
| Reference | Topics |
| --- | --- |
| [Model syntax and estimation](references/model-syntax-and-estimation.md) | Installation, argument and option names, model composition, composites, correlation structures, estimators, missing data, optimizer and rotation controls |
| [Groups, multilevel models, and weights](references/groups-multilevel-and-weights.md) | Group starts and equality constraints, two-level estimation, random slopes, level-specific fit, sampling weights |
| [Inference, effects, and diagnostics](references/inference-effects-and-diagnostics.md) | Model tests, robust standard errors, fit indices, residuals, effects, SAM, defined parameters, prediction, inspection, unrestricted statistics |
## Deprecations and compatibility changes
### Argument, option, and selector spelling
Almost all user-facing formal arguments now use snake case, including
`sampling_weights`, `sample_cov`, and `int_ov_free`. Dotted argument names
still work and are deprecated. Option names also accept snake-case and
uppercase forms.
Elements of list-valued options such as `estimator_args`, `rotation_args`,
and `fm_args` use snake case, with dotted aliases accepted. Selectors such
as `lavInspect()`'s `what`, fit-measure names, `type`, and `method` accept
dots or underscores and either case.
### Defaults that affect existing fits
- The `open` syntax parser is now the default.
- With `correlation = TRUE`, ML replaces GLS as the default estimator.
- Two-level models fitted with `missing = "ml"` default to
`optim_method = "em"`.
- Sampling weights normalize within each group by default.
- When observed variances differ substantially, variables are rescaled
internally by default and the fitted solution is transformed back to
the original metric; `rescale_data` controls this behavior.
- If the first indicator is a poor marker, lavaan warns and retains it by
default. Set `bad_marker_switch = TRUE` to allow automatic switching.
- `mimic = "EQS"` and `mimic = "LISREL"` now set `fixed_x = FALSE`,
treating observed exogenous covariates as random.
### Robust standard errors and tests
WLSMV, ULSMV, and related estimators now use observed information for the
sandwich bread with ordered data. Mixed ordered and continuous data also
use observed derivatives for continuous variables. Set
`information_bread = "expected"` to reproduce the 0.7-2 standard errors.
`information_bread` chooses the bread information matrix independently of
the meat. `information_meat_hc` selects HC1, HC2, or HC3 small-sample
corrections for robust standard errors.
With `estimator = "ML"`, the model-based normal-theory residual test
`"browne.residual.nt.model"` is computed by default and shown alongside the
conventional chi-square test in the summary.
### Errors, warnings, and changed outputs
- With continuous data containing missing values, ML and GLS raise an error
when `missing = "pairwise"` is combined with robust standard errors or
robust test statistics.
- An asymmetric matrix supplied through `sample_cov` triggers a warning.
- Parameters drifting toward infinity are flagged as a convergence failure.
- `fitMeasures()` adds the Maydeu-Olivares et al. (2024) GFI. Retrieve the
previous GFI and AGFI with
`lavaan::fitMeasures(fit, c("gfi_lisrel", "agfi_lisrel"))`.
### Composite and rotation compatibility
Models using `<~` can drop the old `optim_gradient = "numerical"`
workaround. Composites support a robust mean structure, higher-order
factors, and multilevel models, and have a `composites_cov` option.
Gradient projection uses a Barzilai–Borwein step size by default. Select
the previous algorithm with `rotation_args = list(gpa_algorithm = "legacy")`.
## Model construction and estimation
### Compose measurement and restriction fragments
`cfa()` accepts a character vector as `model`; combine separate model
fragments with `c()` to reuse a measurement model across specifications.
For group-specific starting values, put the vector inside `start()` in
group order, as in `start(c(1.2, 0.6))*x5`.
In `group.equal`, `"residuals"` constrains observed residual variances;
`"residual.covariances"` constrains observed residual covariances;
`"lv.covariances"` constrains latent (residual) covariances.
### Choose additional estimators
- `estimator = "IV"` provides MIIV-2SLS; `|~` declares external instruments.
Choose `iv_method = "LIML"` or `iv_method = "FULLER"` for those methods;
the default remains `"2SLS"`. See `?estimator_iv` for specifications.
- With complete data, `estimator = "MLMVS"` uses the Satterthwaite
adjustment and `estimator = "MLMV"` uses a scaled and shifted test
statistic. Both return robust standard errors.
- `estimator = "MLF"` uses first-order derivatives for standard errors,
reports the conventional ML test statistic, and supports complete and
incomplete data.
- `estimator = "WLSMVS"` is a robust DWLS variant; `estimator = "ULSM"`
and `"ULSMVS"` are robust ULS variants. Robust WLS variants use the
diagonal weight matrix for estimation and the full weight matrix for
standard-error and test-statistic corrections.
### Missing data, correlation structures, and covariances
The `aux` argument supplies auxiliary variables for missing-data estimation.
Single-level continuous models with `conditional_x = TRUE` support
`missing = "ml"`, `"two.stage"`, and `"robust.two.stage"`, including
standard errors and the appropriate Gamma (NACOV) matrix.
Pass variable names to `correlation` for a partial correlation structure;
this also works with `fixed_x = TRUE`. Correlation models support
`conditional_x = TRUE`, mean structures, `missing = "ml"`, and composites;
`lavPredict()` uses the fitted model's metric.
Set `auto_cov_x = TRUE` to freely estimate covariances between latent and
observed exogenous variables. Its default is `FALSE`.
### Two-level models and sampling weights
Two-level models support WLS and DWLS, including WLSMV for categorical
data, with exogenous covariates through `fixed_x` and `conditional_x`.
The `rv()` modifier specifies random slopes for continuous two-level
models; see the groups reference for estimation and prediction support.
Use `sampling_weights_type` to distinguish design from frequency weights.
Least-squares estimators use a weighted Gamma (NACOV) matrix. Sampling
weights also work with `missing = "two.stage"` and `"robust.two.stage"`.
### Configuration and moderated parameters
Pass a list directly as `estimator`, `rotation`, or `bootstrap` in place
of its separate `*.args` argument. With `optim_method = "gn"`, pass
optimizer controls in `gn_args`.
For different EFA-block rotation targets, pass a named list of target
matrices in `rotation_args$target` and match the names to the blocks.
Use `:~` to define a parameter as a function of observed variables wrapped
in `data()`; lavaan parses the specification and an external backend
estimates the model.
## Inference and diagnostic quick reference
### Model comparisons, fit, and residuals
Use `lavTestNET()` to test model nesting and equivalence. `lavTestLRT()`
checks nesting with `check_nested = TRUE` and warns when models were fitted
to different data. With a robust estimator, `lavTestScore()` and
`lavTestWald()` also report scaled, adjusted, and robust statistics.
Select a Hayakawa test with `test = "mean.var.adjusted.corrected"` or
`test = "scaled.shifted.corrected"`; see `?lavTest` and `?lavTestLRT`.
Multilevel summaries show level-specific fit measures based on partially
saturated models; retrieve them with `lavaan::fitMeasures(fit, level = 1)`.
The `fit_by_level` option controls this behavior.
`lavaan::lavResiduals(fit, output = "text")` shows the largest residuals.
The function provides individual-residual standard errors and z-tests,
supports conditional-x and multilevel models, and accepts a supplied
saturated model through `h1`.
### Effects and defined parameters
`lavEffects()` estimates total, indirect, and direct effects with
delta-method, Monte Carlo, or bootstrap standard errors. For `:=`
parameters, `se_def = "mc"` supplies Monte Carlo standard errors and
confidence intervals; `se_delta_second_order` enables the second-order
delta method.
### SAM inference and diagnostics
`sam()` supports cluster-robust standard errors for single-level clustered
data, and local standard errors and a corrected structural test for
two-level models. `sam_method = "global"` gains the Yuan–Chan rescaled test.
`se = "twostep.huber.white"` is experimental. `se = "local"` also works
with `estimator = "PML"`; the structural sandwich uses observed information
for its bread. Pass SAM fits to `fitMeasures()`, `lavResiduals()`, or
`modindices()`. See the inference reference for conditional covariates,
latent interactions, truncation controls, and structural tests.
### Prediction and inspection
`lavPredict()` can return standard errors for categorical factor scores and
accepts `newdata` for two-level models. `lavPredict(fit, transform = TRUE)`
also works for categorical fits and fits using `missing = "ml"`.
The `mdist` diagnostics in `lavPredict()` and `lavInspect()` support
categorical and ordered data.
`lavaan::lavInspect(fit, what = "list")` returns the parameter table,
equivalent to `parTable(fit)`. `lavH1()` computes unrestricted sample
statistics with optional standard errors; `output = "lavMoments"` provides
input for refitting from summary statistics alone, including two-stage
and least-squares estimation.