Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Global configuration for bossanova.

This module provides package-wide configuration settings that can be modified at runtime. Currently manages singular tolerance for mixed models.

Functions:

NameDescription
get_display_digitsGet the number of significant figures for DataFrame display output.
get_singular_toleranceGet the current singular tolerance for mixed models.
is_singularCheck whether a mixed model fit is singular.
set_display_digitsSet the number of significant figures for DataFrame display output.
set_singular_toleranceSet the global singular tolerance for mixed models.

Functions

get_display_digits

get_display_digits() -> int

Get the number of significant figures for DataFrame display output.

Controls how many significant figures are shown in user-facing DataFrames returned by model properties (.params, .effects, .diagnostics, etc.) and compare(). Matches R’s signif() convention.

Returns:

TypeDescription
intCurrent display digits setting (default 4).

Examples:

from bossanova import get_display_digits
get_display_digits()
# 4

get_singular_tolerance

get_singular_tolerance() -> float

Get the current singular tolerance for mixed models.

The singular tolerance is used by isSingular() to determine if a mixed model fit is singular (has variance components at or near zero).

Returns:

TypeDescription
floatThe current singular tolerance threshold.

Examples:

from bossanova import get_singular_tolerance
get_singular_tolerance()
# 0.0001

is_singular

is_singular(theta: np.ndarray | None, tol: float | None = None) -> bool

Check whether a mixed model fit is singular.

A fit is singular when any theta parameter (variance component on the relative scale) is at or near zero, indicating a variance component on the boundary of the parameter space.

Parameters:

NameTypeDescriptionDefault
thetandarray | NoneRelative variance parameters from REML/ML optimization. None indicates no random effects (returns False).required
tolfloat | NoneTolerance threshold. If None, uses the global singular tolerance from get_singular_tolerance().None

Returns:

TypeDescription
boolTrue if any element of theta has absolute value below the tolerance.

Examples:

from config import is_singular
import numpy as np
is_singular(np.array([0.5, 1e-6]))  # True (1e-6 < 1e-4)
is_singular(np.array([0.5, 0.3]))   # False
is_singular(None)                    # False

set_display_digits

set_display_digits(digits: int) -> None

Set the number of significant figures for DataFrame display output.

Controls how many significant figures are shown in user-facing DataFrames returned by model properties (.params, .effects, .diagnostics, etc.) and compare(). Matches R’s signif() convention.

The summary() method has its own digits parameter and is unaffected by this setting.

Parameters:

NameTypeDescriptionDefault
digitsintNumber of significant figures. Must be >= 1.required

Examples:

from bossanova import set_display_digits
set_display_digits(6)  # Show 6 significant figures

set_singular_tolerance

set_singular_tolerance(tol: float) -> None

Set the global singular tolerance for mixed models.

The singular tolerance is used by isSingular() to determine if a mixed model fit is singular. Values below this threshold are considered effectively zero.

Parameters:

NameTypeDescriptionDefault
tolfloatNew tolerance threshold. Must be positive.required

Examples:

from bossanova import set_singular_tolerance
set_singular_tolerance(1e-6)  # More strict threshold