allFit

Refit a model with all available optimizers and compare convergence. Useful for diagnosing whether results are optimizer-sensitive and for identifying which optimizer gives the best (lowest) log-likelihood.

allFit

allFit(formula, data, groups=None, method='REML', random=None, theta0=None)[source]

Refit a model with all available optimizers and compare convergence.

Parameters:
  • formula – Fixed-effects formula, e.g. "y ~ x1 + x2".

  • data – DataFrame (pandas, polars, or any narwhals-compatible frame).

  • groups – Column name (or list of column names) for the grouping / random-effect factors.

  • method – Estimation method — "REML" (default) or "ML".

  • random – Additional random-effects structure forwarded to interlace.fit() (e.g. a list of random-slope specs).

  • theta0 – Optional starting values for the variance-component parameter vector. When None, each optimizer uses its own default starting point.

Return type:

AllFitResult

Returns:

AllFitResult – Contains per-optimizer results, convergence flags, pairwise diffs, and a possible_issue flag.

Parameters:
  • formula (str)

  • data (Any)

  • groups (str | list[str] | None)

  • method (str)

  • random (list[str] | None)

  • theta0 (Any)

Examples

>>> af = interlace.allFit("y ~ x", df, groups="g")
>>> af.possible_issue
False

AllFitResult

class AllFitResult(results, converged, possible_issue, _llf_diffs=<factory>, _theta_diffs=<factory>)[source]

Result of an allFit() call.

Parameters:
  • results (dict[str, Any])

  • converged (dict[str, bool])

  • possible_issue (bool)

  • _llf_diffs (dict[str, float])

  • _theta_diffs (dict[str, float])

results

Dict mapping optimizer name → CrossedLMEResult.

converged

Dict mapping optimizer name → bool (optimizer-reported convergence).

possible_issue

True when the max pairwise LLF difference exceeds 0.001 or any pairwise theta relative difference exceeds 1 %.

_llf_diffs

Dict of pairwise LLF differences (for diagnostics / summary).

_theta_diffs

Dict of pairwise max-relative theta differences (for diagnostics).

Examples

>>> af = interlace.allFit("y ~ x", df, groups="g")
>>> af.converged
>>> print(af.summary())
results: dict[str, Any]
converged: dict[str, bool]
possible_issue: bool
summary()[source]

Return a human-readable table of per-optimizer fit statistics.

Return type:

str

Example

import interlace

result = interlace.fit("rt ~ condition", data=df, groups=["subject", "item"])

fits = interlace.allFit(result)
print(fits.summary())
# optimizer   llf        converged  possible_issue
# lbfgsb      -1234.56   True       False
# bobyqa      -1234.56   True       False

# Access individual fits
bobyqa_fit = fits.results["bobyqa"]
print(bobyqa_fit.fe_params)

See also