Skip to content

Documentation and bugfixes for 0.5.0#329

Merged
Maximilian-Stefan-Ernst merged 11 commits into
develfrom
documentation/0.5.0
Jun 20, 2026
Merged

Documentation and bugfixes for 0.5.0#329
Maximilian-Stefan-Ernst merged 11 commits into
develfrom
documentation/0.5.0

Conversation

@Maximilian-Stefan-Ernst

@Maximilian-Stefan-Ernst Maximilian-Stefan-Ernst commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Documentation update for the 0.5.0 API

Updates the docs to match the new model/type structure so they build and are accurate. The previous docs described the old "three parts" model and used the pre-0.5 API (SemLossFunction, RAM(specification = …), SemLoss(ml) wrappers, evaluate!(…, model, …)), which no longer exists.

Changes

  • Reworked the conceptual model: a Sem is a weighted sum of loss terms (AbstractLoss), and each SemLoss bundles its own observed + implied (concept.md, extending.md, sem.md, types.md).
  • Updated API usage throughout: RAM(spec) positional, SemML(observed, implied), Sem(loss_terms…), no SemLoss(...) wrapper (build_by_parts.md, meanstructure.md, outer_constructor.md).
  • Rewrote the custom-loss tutorial for the new evaluate! interface (no model arg; SemLoss holds observed/implied), and split the AbstractLoss vs SemLoss constructor guidance (loss.md).
  • Fixed @docs/@ref targets (CFI, em_mvn, LossTerm, FiniteDiffWrapper, AbstractSem/AbstractLoss) and small errors (fixed() not fix(), nparams not n_par, show output, file-tree paths, weighting schemes).
  • Corrected a few source docstrings referenced by the docs (FIML.jl, types.jl, EM.jl, empty.jl; added a FiniteDiffWrapper docstring).

Effect: make.jl builds cleanly (no errors/unresolved refs); docs reflect the 0.5.0 API and architecture.

Multigroup weighting & χ² correction

Aligns multigroup loss weighting and χ² with the Wishart convention (χ² = Σ_g (N_g−1)·F_g), matching lavaan's likelihood = "wishart" (ML) / GLS and the stored lavaan reference solutions. Previously a global (N−1) multiplier was applied to an N_g/N-weighted average of per-group fit functions, which was off-convention and inconsistent with the WLS correction.

Changes

  • New :nsamples_corrected weighting scheme, now the default for Sem (via multigroup_weights); plain :nsamples still available.
  • multigroup_correction_scale(SemML): 0 → −1 (ML now uses per-group N_g−1 weighting and N−G in RMSEA, like WLS; FIML stays 0).
  • χ² multiplier for SemML and SemWLS: (N−1) → (N−G); reduces to N−1 for a single group.

Effect: multigroup ML now matches lavaan wishart and WLS matches lavaan GLS (χ², RMSEA, estimates); FIML unchanged; single-group unchanged except ML RMSEA (n: N → N−1). All test/examples pass.

Files: Sem.jl (weighting), chi2.jl (χ² multipliers), collection.md (docs).

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor

@Maximilian-Stefan-Ernst Maximilian-Stefan-Ernst changed the title Documentation/0.5.0 Documentation and bugfixes for 0.5.0 Jun 18, 2026
@Maximilian-Stefan-Ernst

Copy link
Copy Markdown
Collaborator Author

@alyst this PR introduces some potentially breaking changes for you:

  1. the default multi-loss-term weights have changed - they don't just use the plain sample size N_g per group, but for ML and LS now N_g-1 - this is to match lavaans behaviour more closely. For all cases with sufficiently large samples (sth like more than 100), this should barely effect the parameter estimates at all.
  2. the chi-squard computation now uses a different scaling factor. This might have an observable effect on the fit statistics depending on it. This also resolves some minor discrepancies to lavaan.

@alyst

alyst commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
  1. the default multi-loss-term weights have changed - ... - this is to match lavaans behaviour more closely.

I think it should be fine as long as the constructor supports explicit SEM weights specification (Sem(..., id1 => loss1 => weight1, id2 => loss2 => weight2, ...).
In my case the weight of the individual SEM term might be defined by the importance/relevance of its data and/or the data quality, which is hard to provide as an a priori formula.

@github-actions

Copy link
Copy Markdown
Contributor

@Maximilian-Stefan-Ernst Maximilian-Stefan-Ernst merged commit e8bdc5e into devel Jun 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants