isSingular¶
Detect whether a fitted model is at or near the boundary of the parameter
space — i.e., whether any variance component has collapsed to zero.
Mirrors lme4::isSingular().
- isSingular(result, tol=0.0001)[source]¶
Return True if the model is at or near the boundary of the parameter space.
A model is singular when one or more variance components have collapsed to zero — the corresponding diagonal entry of the relative covariance factor Lambda_theta is less than tol. This matches the behaviour of
lme4::isSingular().- Parameters:
result – A fitted
CrossedLMEResult.tol – Tolerance for declaring a diagonal entry “effectively zero”. Defaults to
1e-4, matching lme4.
- Return type:
bool- Returns:
bool –
Trueif any variance component is at the boundary.- Parameters:
result (CrossedLMEResult)
tol (float)
Examples
>>> interlace.isSingular(result) False
Example¶
import interlace
result = interlace.fit("rt ~ condition", data=df, groups=["subject", "item"])
if interlace.isSingular(result):
print("Warning: one or more variance components are at the boundary.")
print(result.boundary_flags) # {'subject': False, 'item': True}
Notes¶
fit() automatically issues a ConvergenceWarning when isSingular() returns
True. You can silence the warning if you expect a boundary fit (e.g., in
simulations) and check it explicitly with this function instead.
See also¶
CrossedLMEResult —
CrossedLMEResult.boundary_flagsattributeVariance Inference Guide — interpreting singular fits