All bossanova.internal functions organized by what they do, not where they live. Functions are classified by verb-prefix naming convention (see Style Guide).
Summary¶
Builders¶
Construct complex objects — containers, matrices, grids, DataFrames.
| Function | Signature | Description | Module |
|---|---|---|---|
build_all_pairwise_matrix | (n_levels) -> np.ndarray | Build all pairwise contrasts between EMM levels | marginal |
build_bracket_contrast_matrix | (expr, levels) -> tuple[np.ndarray, list[str]] | Build contrast matrix and labels from bracket contrast expression | marginal |
build_cholesky_with_derivs | (theta_group, n_re, structure) -> tuple[np.ndarray, list[np.ndarray]] | Build Cholesky factor L and its derivatives w.r.t. theta | inference |
build_contrast_matrix | (contrast_type, levels, normalize) -> np.ndarray | Build a contrast matrix based on contrast type | marginal |
build_design_matrices | (spec, data) -> tuple[DesignResult, FormulaSpec] | Build X and y matrices from a parsed formula spec | formula |
build_emm_reference_grid | (data, bundle, focal_var) -> np.ndarray | Build reference grid X matrix for EMM computation | infer |
build_equation | (spec, bundle, formula_spec, explanations) -> MathDisplay | Build a structural LaTeX equation from model containers | rendering |
build_family | (family_name, link_name) -> Family | Create a Family object from family and link names | family |
build_helmert_matrix | (n_levels) -> np.ndarray | Build Helmert contrasts (each level vs mean of previous levels) | marginal |
build_lambda_sparse | (theta, n_groups_list, re_structure, metadata) -> sp.csc_matrix | Build sparse block-diagonal Lambda matrix from theta | solvers |
build_lambda_template | (n_groups_list, re_structure, metadata) -> LambdaTemplate | Build a Lambda template for efficient repeated updates | solvers |
build_mixed_post_fit_state | (fit, bundle, data, stacklevel) -> tuple[VaryingState | None, VaryingSpreadState | None] | Compute BLUPs, variance components, and emit convergence warnings | fit |
build_pairwise_matrix | (n_levels) -> np.ndarray | Build (n-1) linearly independent pairwise contrasts | marginal |
build_poly_matrix | (n_levels, degree) -> np.ndarray | Build orthogonal polynomial contrast matrix for EMMs | marginal |
build_predict_grid | (data, focal_var, response_col, grouping_factors, focal_values, n_points, varying_vars, at) -> pl.DataFrame | Build a Cartesian-product prediction grid | fit |
build_random_effects | (group_ids_list, n_groups_list, group_names, random_names, re_structure, X_re, re_structures_list, group_levels_list, term_permutation) -> RandomEffectsInfo | Build complete random effects specification | design |
build_random_effects_from_spec | (spec, data) -> RandomEffectsInfo | None | Build random effects design matrix from FormulaSpec | formula |
build_reference_design_matrix | (X_names, focal_var, levels, X_means, set_categoricals) -> np.ndarray | Build design matrix for reference grid points | design |
build_reference_grid | (bundle, focal_vars, at, covariate_means) -> pl.DataFrame | Construct reference grid for marginal effects evaluation | marginal |
build_reference_row | (X_names, focal_var, focal_level, X_means, set_categoricals) -> np.ndarray | Build a single row of the reference design matrix | design |
build_rng | (seed) -> RNG | Create RNG from seed (convenience function) | rng |
build_sequential_matrix | (n_levels) -> np.ndarray | Build sequential (successive differences) contrasts | marginal |
build_slope_reference_matrix | (X_names, focal_var, X_means, delta) -> tuple[np.ndarray, np.ndarray] | Build reference matrices for computing marginal slopes | design |
build_sum_to_zero_matrix | (n_levels) -> np.ndarray | Build sum-to-zero contrasts (deviation coding) | marginal |
build_transform | (name) -> StatefulTransform | Create a stateful transform instance by name | transforms |
build_treatment_matrix | (n_levels, ref_idx) -> np.ndarray | Build treatment (Dunnett-style) contrasts against a reference level | marginal |
build_z_crossed | (group_ids_list, n_groups_list, X_re_list, layouts) -> sp.csc_matrix | Build Z matrix for crossed random effects | design |
build_z_nested | (group_ids_list, n_groups_list, X_re_list) -> sp.csc_matrix | Build Z matrix for nested random effects | design |
build_z_simple | (group_ids, n_groups, X_re, layout) -> sp.csc_matrix | Build Z matrix for single grouping factor | design |
Computers¶
Pure numerical/statistical calculations.
| Function | Signature | Description | Module |
|---|---|---|---|
compute_agq_deviance | (theta, beta, X, Z, y, family, n_groups_list, re_structure, group_ids, nAGQ, metadata, prior_weights, pirls_max_iter, pirls_tol, eta_init, lambda_template, factor_cache) -> float | Compute AGQ deviance for Stage 2 optimization | solvers |
compute_aic | (loglik, k) -> float | Compute Akaike Information Criterion | inference |
compute_akaike_weights | (ic_values) -> np.ndarray | Compute Akaike weights from information criterion values | inference |
compute_batch_size | (n_items, bytes_per_item, max_mem, min_batch, max_batch) -> int | Compute optimal batch size for jax.lax.map | batching |
compute_bic | (loglik, k, n) -> float | Compute Bayesian Information Criterion | inference |
compute_bootstrap_params | (spec, bundle, n_boot, seed, n_jobs) -> np.ndarray | Generate bootstrap distribution of coefficient estimates | infer |
compute_bootstrap_pvalue | (observed, boot_samples, null, alternative) -> np.ndarray | Compute bootstrap p-values | infer |
compute_cell_info | (residuals, data, factor_columns) -> CellInfo | Compute cell-based variance information for Welch inference | inference |
compute_chi2_test | (L, coef, vcov) -> Chi2TestResult | Compute Wald chi-square test for L @ β = 0 | inference |
compute_ci | (estimate, se, critical, alternative) -> tuple[np.ndarray, np.ndarray] | Compute confidence interval bounds | inference |
compute_coefficient_inference | (coef, vcov, df, conf_level, null, alternative) -> InferenceResult | Compute inference statistics for regression coefficients | inference |
compute_compound_bracket_contrasts | (bundle, fit, focal_var, contrast_expr, data, spec, effect_scale, resolved) -> MeeState | Compute bracket contrasts for a compound focal variable | marginal |
compute_conditional_emm | (bundle, fit, focal_var, explore_formula, spec, varying_offsets, grouping_var, effect_scale, levels, at_overrides, set_categoricals) -> MeeState | Compute per-group conditional EMMs incorporating intercept BLUPs | marginal |
compute_conditional_slopes | (bundle, fit, focal_var, explore_formula, spec, varying_offsets, grouping_var, effect_scale) -> MeeState | Compute per-group conditional slopes incorporating BLUPs | marginal |
compute_contrast_variance | (L, vcov) -> np.ndarray | Compute variance-covariance of linear contrasts L @ β | inference |
compute_contrasts | (emm, contrast_matrix) -> np.ndarray | Apply contrast matrix to EMMs | marginal |
compute_cooks_distance | (residuals, hat, sigma, p) -> np.ndarray | Compute Cook’s distance for influence | inference |
compute_cr_vcov | (X, residuals, cluster_ids, XtX_inv, cr_type) -> NDArray[np.float64] | Compute cluster-robust covariance matrix for Gaussian mixed models | inference |
compute_cv_metrics | (spec, bundle, k, seed, holdout_group_ids) -> 'CVState' | Compute k-fold or leave-one-out cross-validation metrics | infer |
compute_deviance | (loglik) -> float | Compute deviance from log-likelihood | inference |
compute_diagnostics | (model_type, spec, bundle, fit, coef_for_predict, varying_spread, cv, has_intercept) -> pl.DataFrame | Compute model-level diagnostics as a single-row DataFrame | fit |
compute_emm | (bundle, fit, focal_var, explore_formula, levels, at_overrides, set_categoricals, spec, how, effect_scale) -> MeeState | Compute estimated marginal means for a categorical focal variable | marginal |
compute_f_pvalue | (f_stat, df1, df2) -> float | Compute p-value from F-statistic | inference |
compute_f_test | (L, coef, vcov, df_resid) -> FTestResult | Compute F-test for linear hypothesis L @ β = 0 | inference |
compute_glm_cr_vcov | (X, residuals, irls_weights, cluster_ids, XtWX_inv, cr_type) -> NDArray[np.float64] | Compute cluster-robust covariance matrix for non-Gaussian mixed models | inference |
compute_glm_hc_vcov | (X, residuals, irls_weights, XtWX_inv, hc_type) -> NDArray[np.float64] | Compute heteroscedasticity-consistent covariance matrix for GLM | inference |
compute_gradient_richardson | (func, x, d, eps, r, v, zero_tol) -> np.ndarray | Compute gradient using Richardson extrapolation | differentiation |
compute_hc_vcov | (X, residuals, XtX_inv, hc_type) -> NDArray[np.float64] | Compute heteroscedasticity-consistent covariance matrix | inference |
compute_hessian_numerical | (func, x, step_size) -> np.ndarray | Compute Hessian using central finite differences | differentiation |
compute_hessian_richardson | (func, x, d, eps, r, v, zero_tol) -> np.ndarray | Compute Hessian using Richardson extrapolation with genD method | differentiation |
compute_inverse_variance_weights | (data, y_col, group_col, valid_mask) -> WeightInfo | Compute inverse-variance weights from a factor column | weights |
compute_irls_quantities | (y, eta, family) -> tuple[np.ndarray, np.ndarray] | Compute IRLS working weights and working response | solvers |
compute_jackknife_coefs | (spec, bundle) -> np.ndarray | Compute leave-one-out jackknife coefficient estimates | infer |
compute_jacobian_numerical | (func, x, step_size) -> np.ndarray | Compute Jacobian using central finite differences | differentiation |
compute_jacobian_richardson | (func, x, d, eps, r, v, zero_tol) -> np.ndarray | Compute Jacobian using Richardson extrapolation | differentiation |
compute_joint_test | (fit, bundle, spec, terms, errors, data) -> JointTestState | Compute joint hypothesis tests for model terms | marginal |
compute_leverage | (X, weights, XtWX_inv) -> np.ndarray | Compute diagonal of hat matrix (leverage values) | inference |
compute_mc_iteration | (seed, dgp_fn, dgp_params, fit_fn) -> dict[str, Any] | None | Execute a single Monte Carlo iteration | simulation |
compute_mee_bootstrap | (spec, bundle, mee, data, conf_level, n_boot, ci_type, seed, null, alternative, save_resamples) -> 'tuple[MeeState, np.ndarray | None]' | Compute bootstrap inference for marginal effects | infer |
compute_mee_inference | (mee, vcov, df_resid, conf_level, null, alternative) -> MeeState | Compute delta method inference for marginal effects | marginal |
compute_mee_inference_fallback | (mee, bundle, fit, data, df_resid, conf_level, null, alternative) -> 'MeeState' | Compute inference for MEE without L_matrix (fallback path) | marginal |
compute_mee_permutation | (spec, bundle, fit, mee, data, conf_level, se_obs, n_perm, seed, null, alternative, save_resamples) -> 'tuple[MeeState, np.ndarray | None]' | Compute permutation-based inference for marginal effects | infer |
compute_mee_se | (mee, bundle, fit, data) -> np.ndarray | Compute standard errors for MEE estimates (means or slopes) | marginal |
compute_metadata | (bundle) -> pl.DataFrame | Compute model metadata as a single-row DataFrame | fit |
compute_mu_with_new_re | (bundle, fit, spec, rng) -> np.ndarray | Compute conditional mean with newly sampled random effects | simulation |
compute_mvt_critical | (conf_level, corr, df, tol) -> float | Compute multivariate-t critical value for simultaneous inference | inference |
compute_optimizer_diagnostics | (model_type, fit) -> pl.DataFrame | Compute optimizer convergence diagnostics as a single-row DataFrame | fit |
compute_params_asymptotic | (spec, bundle, fit, conf_level, errors, data, null, alternative) -> 'InferenceState' | Compute asymptotic (Wald) inference for model parameters | infer |
compute_params_bootstrap | (spec, bundle, fit, conf_level, n_boot, ci_type, seed, save_resamples, n_jobs, null, alternative) -> 'InferenceState' | Compute bootstrap inference for parameters | infer |
compute_params_bootstrap_mixed | (spec, bundle, fit, conf_level, n_boot, ci_type, seed, save_resamples, n_jobs, null, alternative) -> 'InferenceState' | Compute bootstrap inference for mixed model parameters | infer |
compute_params_cv_inference | (spec, bundle, data, conf_level, link_override, k, seed, holdout_group_ids) -> tuple['InferenceState', 'CVState'] | Compute CV-based parameter importance via ablation | infer |
compute_params_permutation | (spec, bundle, fit, conf_level, n_perm, seed, save_resamples, null, alternative) -> 'InferenceState' | Compute permutation-based inference for model parameters | infer |
compute_pls_invariants | (X, y) -> PLSInvariants | Pre-compute quantities that are constant during optimization | solvers |
compute_prediction_asymptotic | (pred, bundle, fit, spec, conf_level) -> 'PredictionState' | Compute asymptotic inference for predictions via delta method | infer |
compute_prediction_bootstrap | (spec, bundle, pred, conf_level, n_boot, ci_type, seed) -> 'PredictionState' | Compute bootstrap inference for predictions | infer |
compute_predictions_from_formula | (formula, data, spec, bundle, fit, formula_spec, pred_type, varying, allow_new_levels, n_points) -> 'PredictionState' | Parse a predict formula, build the grid, compute predictions, and attach grid... | fit |
compute_profile_inference | (spec, bundle, fit, conf_level, n_steps, verbose, threshold) -> 'ProfileState' | Compute profile likelihood CIs for variance components | infer |
compute_pvalue | (statistic, df, alternative) -> np.ndarray | Compute p-values from test statistics | inference |
compute_r_squared | (y, residuals, n, p, has_intercept) -> tuple[float, float] | Compute R-squared and adjusted R-squared from raw arrays | fit |
compute_satterthwaite_df | (vcov_beta, jacobian_vcov, hessian_deviance, min_df, max_df, tol) -> np.ndarray | Compute Satterthwaite degrees of freedom for each fixed effect | inference |
compute_satterthwaite_emm_df | (bundle, fit, spec, L) -> np.ndarray | Compute Satterthwaite denominator df for EMM contrast rows | infer |
compute_satterthwaite_summary_table | (beta, beta_names, vcov_beta, vcov_varpar, jac_list) -> dict[str, list] | Compute full coefficient table with Satterthwaite df and p-values | inference |
compute_satterthwaite_t_test | (beta, se, df, conf_level) -> dict[str, np.ndarray] | Compute t-statistics, p-values, and confidence intervals | inference |
compute_sd_jacobian | (theta, sigma, group_names, random_names, re_structure) -> tuple[np.ndarray, np.ndarray] | Compute SDs and Jacobian of SDs w.r.t. varpar = [theta, sigma] | inference |
compute_se_from_vcov | (vcov) -> np.ndarray | Compute standard errors from variance-covariance matrix | inference |
compute_sigma_se_wald | (model) -> float | Compute Wald standard error for sigma | inference |
compute_simulation_inference | (simulations, conf_level) -> 'SimulationInferenceState' | Compute inference for simulations | infer |
compute_slopes | (bundle, fit, focal_var, explore_formula, spec, effect_scale) -> MeeState | Compute marginal slope for a continuous focal variable | marginal |
compute_slopes_crossed | (bundle, fit, focal_var, resolved, data, spec, formula_spec, effect_scale, delta_frac) -> MeeState | Compute crossed slopes over focal variable x condition grid | marginal |
compute_slopes_finite_diff | (bundle, fit, focal_var, explore_formula, spec, formula_spec, data, how, effect_scale, delta_frac) -> MeeState | Compute marginal slopes via centered finite differences | marginal |
compute_sparse_cholesky | (A) -> SparseFactorization | Factor a sparse symmetric positive definite matrix | linalg |
compute_studentized_residuals | (residuals, hat, sigma) -> np.ndarray | Compute internally studentized (standardized) residuals | inference |
compute_t_critical | (conf_int, df, alternative) -> float | np.ndarray | Compute t-distribution critical value for confidence interval | inference |
compute_t_test | (L, coef, vcov, df) -> TTestResult | Compute t-test for a single contrast L @ β = 0 | inference |
compute_tukey_critical | (conf_level, k, df) -> float | Compute Tukey HSD critical value for pairwise comparisons | inference |
compute_varying_spread_state | (theta, sigma, re_meta) -> VaryingSpreadState | Compute VaryingSpreadState (variance components) from theta parameters | fit |
compute_varying_state | (theta, u, re_meta, data) -> VaryingState | Compute VaryingState (BLUPs) from fitted random effects parameters | fit |
compute_vcov_schur_sparse | (X, Z, Lambda, weights, sigma2) -> np.ndarray | Compute variance-covariance matrix of fixed effects via Schur complement | linalg |
compute_vif | (X, X_names) -> pl.DataFrame | Compute variance inflation factors | inference |
compute_wald_ci_varying | (theta, sigma, vcov_varpar, group_names, random_names, re_structure, conf_level) -> tuple[np.ndarray, np.ndarray] | Compute Wald CIs for variance components on SD scale | inference |
compute_wald_statistic | (contrast_values, contrast_vcov) -> float | Compute Wald statistic for testing L @ β = 0 | inference |
compute_welch_satterthwaite_df_per_coef | (X, cell_info) -> NDArray[np.float64] | Compute per-coefficient Welch-Satterthwaite degrees of freedom | inference |
compute_wilson_ci | (p_hat, n, level) -> tuple[float, float] | Wilson score confidence interval for a binomial proportion | simulation |
compute_z_critical | (conf_int, alternative) -> float | Compute z-distribution critical value for confidence interval | inference |
Fitters & Solvers¶
Solver entry points and linear algebra solver steps.
| Function | Signature | Description | Module |
|---|---|---|---|
fit_glm_irls | (spec, bundle, max_iter, tol) -> FitState | Fit generalized linear model using Iteratively Reweighted Least Squares | fit |
fit_glm_irls | (y, X, family, weights, max_iter, tol) -> dict | Fit GLM using IRLS algorithm | solvers |
fit_glmer_pirls | (spec, bundle, max_iter, max_outer_iter, tol, verbose, nAGQ, use_hessian) -> FitState | Fit generalized linear mixed model using Penalized IRLS | fit |
fit_glmm_pirls | (X, Z, y, family, n_groups_list, re_structure, metadata, theta_init, prior_weights, max_outer_iter, pirls_max_iter, pirls_tol, verbose, two_stage, lambda_template, nAGQ, group_ids) -> dict | Fit GLMM using PIRLS with outer optimization over theta | solvers |
fit_lmer_pls | (spec, bundle, max_iter, verbose) -> FitState | Fit linear mixed-effects model using Penalized Least Squares | fit |
fit_model | (spec, bundle, solver, max_iter, max_outer_iter, tol, verbose, nAGQ, use_hessian) -> FitState | Dispatch to appropriate fitter based on model specification | fit |
fit_ols_qr | (spec, bundle) -> FitState | Fit ordinary or weighted least squares using QR decomposition | fit |
solve_atol | (scale, cond, n, safety) -> float | Absolute tolerance for linear solve operations | tolerances |
solve_pls_sparse | (X, Z, Lambda, y, pls_invariants) -> dict | Solve Penalized Least Squares system using Schur complement | solvers |
solve_rtol | (cond, safety) -> float | Relative tolerance for linear solve operations | tolerances |
solve_weighted_pls_sparse | (X, Z, Lambda, z, weights, beta_fixed, ZL, ZL_dense, factor_S22, factor_S, pattern_template) -> dict | Solve weighted Penalized Least Squares for GLMM | solvers |
Parsers & Evaluators¶
String-to-structure conversion and formula AST evaluation.
| Function | Signature | Description | Module |
|---|---|---|---|
parse_conf_int | (conf_int) -> float | Parse flexible confidence interval input to float | inference |
parse_design_column_name | (name) -> DesignColumnInfo | Parse design matrix column name into components | design |
parse_explore_formula | (formula, model_terms) -> ExploreFormulaSpec | Parse an explore formula string | marginal |
parse_fit_kwargs | (spec, kwargs, nAGQ) -> tuple[ModelSpec, str | None, dict[str, object]] | Validate and extract fitting parameters from **kwargs | fit |
parse_formula | (formula, data, factors, custom_contrasts) -> FormulaSpec | Parse formula and detect categoricals from data | formula |
parse_predict_formula | (formula, data, response_col, grouping_factors, n_points) -> tuple[pl.DataFrame, list[str]] | Parse an explore-style formula and build a prediction grid | fit |
Dispatchers & Resolvers¶
Route to specialized implementations and resolve ambiguity.
| Function | Signature | Description | Module |
|---|---|---|---|
dispatch_infer | (how, conf_level, errors, null, alternative, last_op, spec, bundle, fit, data, link_override, mee, pred, simulations, varying_spread, is_mixed, n_boot, n_perm, ci_type, seed, n_jobs, save_resamples, k, n_steps, verbose, threshold, profile_auto, holdout_group_ids) -> InferResult | Dispatch inference to the correct backend based on method and last operation | infer |
dispatch_marginal_computation | (parsed, bundle, fit, data, spec, formula_spec, varying_offsets, effect_scale, varying, how, inverse_transforms, by) -> MeeState | Route a parsed explore formula to the appropriate marginal computation | marginal |
dispatch_mee_inference | (how, mee, spec, bundle, fit, data, conf_level, errors, null, alternative, n_boot, n_perm, ci_type, seed, save_resamples) -> 'tuple[MeeState, np.ndarray | None]' | Dispatch marginal effects inference to the appropriate method | infer |
dispatch_params_inference | (how, spec, bundle, fit, data, conf_level, errors, null, alternative, link_override, n_boot, n_perm, ci_type, seed, n_jobs, save_resamples, k) -> InferenceState | Dispatch parameter inference to the appropriate method | infer |
dispatch_prediction_inference | (how, pred, spec, bundle, fit, conf_level, n_boot, ci_type, seed, k, holdout_group_ids) -> tuple[PredictionState, CVState | None] | Dispatch prediction inference to the appropriate method | infer |
resolve_condition_values | (cond, data) -> list | None | Resolve a :class:Condition to concrete values or None | fit |
resolve_conditions | (conditions, bundle, data) -> ResolvedConditions | Classify each Condition into the appropriate typed bucket | marginal |
resolve_sigma | (sigma) -> float | Resolve optional sigma to a concrete float | family |
resolve_solver | (spec) -> str | Select the appropriate solver for a model configuration | fit |
Generators & Simulators¶
Synthetic data creation and multi-step workflows.
| Function | Signature | Description | Module |
|---|---|---|---|
generate_data_from_spec | (sim_spec, family, response_var) -> pl.DataFrame | Generate a synthetic dataset from a simulation specification | simulation |
generate_glm_data | (n, beta, family, link, sigma, x_type, distributions, seed) -> tuple[pl.DataFrame, dict] | Generate GLM data with known parameters | simulation |
generate_glmer_data | (n_obs, n_groups, beta, theta, family, re_structure, obs_per_group, distributions, seed) -> tuple[pl.DataFrame, dict] | Generate GLMM data with known parameters | simulation |
generate_group_kfold_splits | (group_ids, k, seed) -> list[tuple[np.ndarray, np.ndarray]] | Generate group-aware k-fold cross-validation indices | infer |
generate_kfold_splits | (n, k, seed) -> list[tuple[np.ndarray, np.ndarray]] | Generate k-fold cross-validation train/test indices | infer |
generate_lm_data | (n, beta, sigma, x_type, distributions, seed) -> tuple[pl.DataFrame, dict] | Generate linear model data with known parameters | simulation |
generate_lmer_data | (n_obs, n_groups, beta, theta, sigma, re_structure, obs_per_group, distributions, seed) -> tuple[pl.DataFrame, dict] | Generate linear mixed model data with known parameters | simulation |
run_monte_carlo | (dgp_fn, dgp_params, fit_fn, n_sims, seed, n_jobs, verbose) -> MonteCarloResult | Run a Monte Carlo simulation study | simulation |
run_power_analysis | (formula, family, response_var, power, n, seed, coef, sigma, var_specs) -> pl.DataFrame | Run simulation-based power analysis for a model formula | simulation |
run_power_study | (sweep_grid, dgp_fn, fit_fn, n_sims, seed, alpha, ci_level, n_jobs, verbose) -> pl.DataFrame | Run power analysis across a sweep grid | simulation |
simulate_responses_from_fit | (fit, bundle, spec, nsim, seed, varying) -> pl.DataFrame | Simulate new responses from a fitted model | simulation |
Accessors & Extractors¶
Retrieve configuration/data and pull pieces from structures.
| Function | Signature | Description | Module |
|---|---|---|---|
extract_base_term | (name) -> str | Extract base term name from column name | design |
extract_categorical_variables | (X_names) -> set[str] | Find all categorical base variable names from design matrix columns | design |
extract_ci_bound | (spline, zeta_target, lower_bound, upper_guess) -> float | Extract CI bound by finding where spline equals target zeta | inference |
extract_factors_from_formula | (formula, data) -> list[str] | Extract factor (categorical) column names from a model formula | inference |
extract_level_from_column | (name, focal_var) -> str | None | Extract level value for a specific focal variable from column name | design |
get_available_memory_gb | () -> float | Query available system memory in GB | batching |
get_backend | () -> BackendName | Get the current backend name | backend |
get_contrast_labels | (levels, contrast_type) -> list[str] | Generate human-readable labels for contrasts | marginal |
get_display_digits | () -> int | Get the number of significant figures for DataFrame display output | config |
get_ops | () -> 'ArrayOps' | Get array operations for the current backend | backend |
get_singular_tolerance | () -> float | Get the current singular tolerance for mixed models | config |
get_theta_lower_bounds | (n_theta, re_structure, metadata) -> list[float] | Get lower bounds for theta parameters | fit |
get_valid_rows | (X) -> tuple[NDArray[np.bool_], NDArray, int] | Identify valid (non-NA) rows in a design matrix | predict |
Transformers¶
Transform, convert, or reshape data.
| Function | Signature | Description | Module |
|---|---|---|---|
apply_bracket_contrasts | (mee_state, expr) -> MeeState | Apply bracket contrast expression to an EMM MeeState | marginal |
apply_bracket_contrasts_grouped | (mee_state, expr) -> MeeState | Apply bracket contrasts within each condition group of a crossed MeeState | marginal |
apply_contrasts | (mee_state, contrast_type, fit, degree, ref_idx, level_ordering) -> MeeState | Apply contrast matrix to marginal means/effects | marginal |
apply_contrasts_grouped | (mee_state, contrast_type, degree, ref_idx, level_ordering) -> MeeState | Apply contrasts within each condition group of a crossed MeeState | marginal |
apply_link | (link, mu) -> 'np.ndarray' | Apply link function by name: η = g(μ) | family |
apply_link_deriv | (link, mu) -> 'np.ndarray' | Apply link function derivative by name: dη/dμ | family |
apply_link_inverse | (link, eta) -> 'np.ndarray' | Apply inverse link function by name: μ = g⁻¹(η) | family |
apply_rhs_bracket_contrast | (mee_state, expr) -> MeeState | Apply a bracket contrast on a RHS condition column | marginal |
apply_sqrt_weights | (X, Z, y, weights) -> tuple[np.ndarray, sp.csc_matrix, np.ndarray, np.ndarray |... | Apply sqrt(weights) transformation to design matrices and response | solvers |
convert_coding_to_hypothesis | (coding_matrix) -> NDArray[np.float64] | Convert a coding matrix back to interpretable hypothesis contrasts | design |
convert_theta_ci_to_sd | (ci_theta, theta_opt, sigma_opt, group_names, random_names, re_structure) -> tuple[dict[str, tuple[float, float]], np.ndarray, np.ndar... | Convert theta-scale CIs to SD-scale CIs | inference |
expand_double_verts | (formula) -> tuple[str, dict] | Expand || syntax into separate uncorrelated random effects terms | formula |
expand_nested_syntax | (formula) -> tuple[str, dict] | Expand nested / syntax into separate crossed random effects terms | formula |
expand_sweep_grid | (base_n, base_coef, base_sigma, base_varying, power_config) -> list[dict[str, Any]] | Full factorial grid from base DGP + power sweep overrides | simulation |
to_markdown | (df, path, caption) -> str | Convert a Polars DataFrame to a markdown table, optionally saving to file | rendering |
Guards¶
Validation, predicates, and introspection.
| Function | Signature | Description | Module |
|---|---|---|---|
check_convergence | (fit, re_meta) -> list[ConvergenceMessage] | Run convergence diagnostics on a fitted mixed model | fit |
detect_rank_deficiency | (X, X_names) -> RankInfo | None | Detect rank deficiency in a design matrix via pivoted QR | linalg |
detect_weight_type | (data, col) -> bool | Check if a column is categorical (should use inverse-variance weights) | weights |
has_full_rank | (A) -> bool | Check if matrix has full column rank | tolerances |
is_singular | (theta, tol) -> bool | Check whether a mixed model fit is singular | config |
is_well_conditioned | (A, threshold) -> bool | Check if matrix is well-conditioned for stable computation | tolerances |
validate_fit_method | (spec, method_str) -> ModelSpec | Validate and apply a user-specified fitting method to a ModelSpec | fit |
Formatters & Comparators¶
Display string production and model comparison.
| Function | Signature | Description | Module |
|---|---|---|---|
compare_aic | (models) -> pl.DataFrame | Compare models by AIC with delta-AIC and Akaike weights | compare |
compare_bic | (models) -> pl.DataFrame | Compare models by BIC with delta-BIC and Schwarz weights | compare |
format_convergence_warnings | (messages) -> str | Format convergence messages for display as warning text | convergence |
format_pvalue_with_stars | (p_val) -> str | Format p-value with R-style significance codes | inference |
Math Primitives¶
Family, link, distribution, and coding functions (no verb prefix).
| Function | Signature | Description | Module |
|---|---|---|---|
adjust_pvalues | (pvalues, method) -> np.ndarray | Adjust p-values for multiple comparisons | inference |
algorithm_comparison_atol | (scale, cond, safety) -> float | Absolute tolerance for comparing different algorithms | tolerances |
algorithm_comparison_rtol | (cond, safety) -> float | Relative tolerance for comparing different algorithms | tolerances |
array_to_coding_matrix | (contrasts, n_levels, normalize) -> NDArray[np.float64] | Convert user-specified contrasts to a coding matrix for design matrices | design |
augment_data_with_diagnostics | (raw_data, fit, bundle) -> pl.DataFrame | Augment raw data with diagnostic columns after fit | fit |
augment_spread_with_profile_ci | (spread, profile, conf_level) -> 'VaryingSpreadState' | Augment variance components with profile likelihood confidence intervals | infer |
backend | (name) -> Iterator[None] | Context manager for temporary backend switching | backend |
beta | (a, b) -> Distribution | Beta distribution | distributions |
bias | (estimates, true_value) -> float | Compute bias: E[beta_hat] - beta_true | simulation |
binomial | (n, p) -> Distribution | Binomial distribution | distributions |
binomial_deviance | (y, mu) -> jnp.ndarray | Binomial unit deviance: d(y, μ) = 2[y log(y/μ) + (1-y) log((1-y)/(1-μ))] | family |
binomial_dispersion | (y, mu, df_resid) -> float | Dispersion parameter for binomial family | family |
binomial_initialize | (y, weights) -> jnp.ndarray | Initialize μ for binomial family | family |
binomial_loglik | (y, mu) -> jnp.ndarray | Binomial conditional log-likelihood (per observation) | family |
binomial_variance | (mu) -> jnp.ndarray | Binomial variance function: V(μ) = μ(1-μ) | family |
chi2 | (df) -> Distribution | Chi-squared distribution | distributions |
clear_ops_cache | () -> None | Clear the backend operations cache | backend |
cloglog_link | (mu) -> jnp.ndarray | Complementary log-log link function: η = log(-log(1-μ)) | family |
cloglog_link_deriv | (mu) -> jnp.ndarray | Cloglog link derivative: dη/dμ = 1/((1-μ) * (-log(1-μ))) | family |
cloglog_link_inverse | (eta) -> jnp.ndarray | Cloglog inverse link: μ = 1 - exp(-exp(η)) | family |
combine_resolved | (a, b) -> ResolvedConditions | Merge two ResolvedConditions, with b taking precedence on conflicts | marginal |
compose_contrast_matrix | (C, X_ref) -> np.ndarray | Compose contrast matrix with prediction matrix | marginal |
coverage | (ci_lower, ci_upper, true_value) -> float | Compute coverage probability | simulation |
dataframe_to_markdown | (df, caption) -> str | Convert a Polars DataFrame to a pipe-delimited markdown table | rendering |
decomposition_atol | (A, safety) -> float | Absolute tolerance for decomposition properties | tolerances |
delta_method_se | (X_pred, vcov) -> np.ndarray | Compute standard errors for predictions via delta method | inference |
diagnose_convergence | (theta, theta_lower, group_names, random_names, re_structure, sigma, converged, boundary_adjusted, restarted, optimizer_message, singular_tol, corr_tol) -> list[ConvergenceMessage] | Analyze model convergence state and generate diagnostic messages | convergence |
empirical_se | (estimates) -> float | Compute empirical standard error (SD of estimates) | simulation |
equation_to_markdown | (equation, explanations, include_explanations) -> str | Wrap a LaTeX equation in display math delimiters for Quarto | rendering |
execute_fit | (spec, bundle, data, raw_data, formula, custom_contrasts, weights_col, offset_col, missing, is_mixed, solver_override, fit_kwargs) -> FitResult | Execute the full fit lifecycle: bundle rebuild → fit → post-fit state → diagn... | fit |
execute_simulate | (spec, bundle, fit, data, formula, is_mixed, n, nsim, seed, coef, sigma, varying, power, var_specs) -> SimulateResult | Execute simulation: power analysis, post-fit sampling, or pre-fit generation | simulation |
exponential | (rate) -> Distribution | Exponential distribution (rate parameterization) | distributions |
f_dist | (df1, df2) -> Distribution | F distribution | distributions |
figure_to_html | (fig, dpi) -> str | Convert matplotlib figure to base64-encoded HTML img tag | distributions |
fill_valid | (result, valid_mask, values) -> NDArray | Fill valid positions in result array with computed values | predict |
fitted_atol | (X, y, cond, safety) -> float | Absolute tolerance for fitted value comparisons | tolerances |
gamma | (shape, rate, scale) -> Distribution | Gamma distribution | distributions |
gamma_deviance | (y, mu) -> jnp.ndarray | Gamma unit deviance: d(y, μ) = 2[-log(y/μ) + (y - μ)/μ] | family |
gamma_dispersion | (y, mu, df_resid) -> float | Estimate dispersion parameter for Gamma family | family |
gamma_initialize | (y, weights) -> jnp.ndarray | Initialize μ for Gamma family | family |
gamma_loglik | (y, mu) -> jnp.ndarray | Gamma conditional log-likelihood (per observation) | family |
gamma_variance | (mu) -> jnp.ndarray | Gamma variance function: V(μ) = μ² | family |
gaussian_deviance | (y, mu) -> jnp.ndarray | Gaussian unit deviance: d(y, μ) = (y - μ)² | family |
gaussian_dispersion | (y, mu, df_resid) -> float | Estimate dispersion parameter for Gaussian family | family |
gaussian_initialize | (y, weights) -> jnp.ndarray | Initialize μ for Gaussian family | family |
gaussian_loglik | (y, mu) -> jnp.ndarray | Gaussian conditional log-likelihood (per observation) | family |
gaussian_variance | (mu) -> jnp.ndarray | Gaussian variance function: V(μ) = 1 | family |
glm_score_atol | (X, y, cond, weights, iterative, safety) -> float | Absolute tolerance for GLM score equation checks | tolerances |
glmm_deviance | (y, mu, family, logdet, sqrL, prior_weights) -> float | Compute GLMM deviance via Laplace approximation | solvers |
glmm_deviance_objective | (theta, X, Z, y, family, n_groups_list, re_structure, metadata, prior_weights, pirls_max_iter, pirls_tol, verbose, lambda_template, factor_cache, pattern_template, pirls_result_cache) -> float | Compute GLMM deviance for outer optimization | solvers |
hat_matrix_atol | (X, cond, safety) -> float | Absolute tolerance for hat matrix property checks | tolerances |
helmert_coding | (levels) -> NDArray[np.float64] | Build Helmert contrast matrix | design |
helmert_coding_labels | (levels) -> list[str] | Get column labels for Helmert contrast | design |
identify_column_type | (name) -> Literal['intercept', 'continuous', 'categorical'] | Identify column type from name (simplified version) | design |
identity_link | (mu) -> jnp.ndarray | Identity link function: η = μ | family |
identity_link_deriv | (mu) -> jnp.ndarray | Identity link derivative: dη/dμ = 1 | family |
identity_link_inverse | (eta) -> jnp.ndarray | Identity inverse link: μ = η | family |
inference_atol | (coef, safety) -> float | Absolute tolerance for inference result comparisons | tolerances |
init_na_array | (n, dtype) -> NDArray | Create an array of NaN values | predict |
inverse_link | (mu) -> jnp.ndarray | Inverse link function: η = 1/μ | family |
inverse_link_deriv | (mu) -> jnp.ndarray | Inverse link derivative: dη/dμ = -1/μ² | family |
inverse_link_inverse | (eta) -> jnp.ndarray | Inverse link inverse: μ = 1/η | family |
lmm_deviance_sparse | (theta, X, Z, y, n_groups_list, re_structure, method, lambda_template, pls_invariants, metadata, sqrtwts) -> float | Compute LMM deviance for optimization | solvers |
lock_backend | () -> None | Lock the backend to prevent switching after model fitting | backend |
log_link | (mu) -> jnp.ndarray | Log link function: η = log(μ) | family |
log_link_deriv | (mu) -> jnp.ndarray | Log link derivative: dη/dμ = 1/μ | family |
log_link_inverse | (eta) -> jnp.ndarray | Log inverse link: μ = exp(η) | family |
logit_link | (mu) -> jnp.ndarray | Logit link function: η = log(μ/(1-μ)) | family |
logit_link_deriv | (mu) -> jnp.ndarray | Logit link derivative: dη/dμ = 1/(μ(1-μ)) | family |
logit_link_inverse | (eta) -> jnp.ndarray | Logit inverse link: μ = 1/(1 + exp(-η)) | family |
mean_se | (std_errors) -> float | Compute mean of standard errors across simulations | simulation |
normal | (mean, sd) -> Distribution | Normal (Gaussian) distribution | distributions |
optimize_theta | (objective, theta0, lower, upper, rhobeg, rhoend, maxfun, verbose) -> dict | Optimize theta using BOBYQA via NLOPT | solvers |
orthogonality_atol | (n, safety) -> float | Absolute tolerance for orthogonality checks | tolerances |
per_factor_re_info | (re_meta, group_names) -> tuple[str | list[str], list[str] | dict[str, list[str]]] | Split global RE metadata into per-factor structures and names | fit |
poisson | (mu) -> Distribution | Poisson distribution | distributions |
poisson_deviance | (y, mu) -> jnp.ndarray | Poisson unit deviance: d(y, μ) = 2[y log(y/μ) - (y - μ)] | family |
poisson_dispersion | (y, mu, df_resid) -> float | Dispersion parameter for Poisson family | family |
poisson_initialize | (y, weights) -> jnp.ndarray | Initialize μ for Poisson family | family |
poisson_loglik | (y, mu) -> jnp.ndarray | Poisson conditional log-likelihood (per observation) | family |
poisson_variance | (mu) -> jnp.ndarray | Poisson variance function: V(μ) = μ | family |
poly_coding | (levels) -> NDArray[np.float64] | Build orthogonal polynomial contrast matrix | design |
poly_coding_labels | (levels) -> list[str] | Get column labels for polynomial contrast | design |
probit_link | (mu) -> jnp.ndarray | Probit link function: η = Φ⁻¹(μ) | family |
probit_link_deriv | (mu) -> jnp.ndarray | Probit link derivative: dη/dμ = 1/φ(Φ⁻¹(μ)) | family |
probit_link_inverse | (eta) -> jnp.ndarray | Probit inverse link: μ = Φ(η) | family |
profile_likelihood | (model, conf_level, threshold, n_steps, verbose) -> dict | Compute profile likelihood confidence intervals for variance components | inference |
profile_theta_parameter | (param_idx, param_name, param_opt, theta_opt, dev_opt, deviance_fn, lower_bounds, n_steps, threshold, verbose) -> dict | Profile a single theta parameter bidirectionally from its MLE | inference |
qr_solve | (X, y) -> QRSolveResult | Solve least squares via pivoted QR decomposition | linalg |
qr_solve_jax | (X, y) -> QRSolveResult | Solve least squares via pivoted QR decomposition (returns backend arrays) | linalg |
rejection_rate | (p_values, alpha) -> float | Compute rejection rate (proportion of p-values < alpha) | simulation |
reset_backend | () -> None | Reset backend state (for testing only) | backend |
residual_atol | (X, y, cond, safety) -> float | Absolute tolerance for residual orthogonality checks | tolerances |
rmse | (estimates, true_value) -> float | Compute root mean squared error | simulation |
round_float_columns | (df, digits) -> pl.DataFrame | Round all Float64 columns to digits significant figures | rounding |
round_sigfigs | (x, n) -> np.ndarray | Round array values to n significant figures | rounding |
sample_response | (family, mu, sigma, rng) -> np.ndarray | Sample response values from a GLM family distribution | family |
satterthwaite_df_for_contrasts | (L, vcov_beta, vcov_varpar, jac_list, min_df, max_df) -> np.ndarray | Compute Satterthwaite degrees of freedom for arbitrary contrasts | inference |
sequential_coding | (levels) -> NDArray[np.float64] | Build sequential (successive differences) contrast matrix | design |
sequential_coding_labels | (levels) -> list[str] | Get column labels for sequential contrast | design |
set_backend | (name) -> None | Set the backend to use for computations | backend |
set_display_digits | (digits) -> None | Set the number of significant figures for DataFrame display output | config |
set_singular_tolerance | (tol) -> None | Set the global singular tolerance for mixed models | config |
sum_coding | (levels, omit) -> NDArray[np.float64] | Build sum (effects) contrast matrix | design |
sum_coding_labels | (levels, omit) -> list[str] | Get column labels for sum contrast | design |
svd_solve | (X, y, rcond) -> SVDSolveResult | Solve least squares via SVD (handles rank deficiency) | linalg |
svd_solve_jax | (X, y, rcond) -> SVDSolveResult | Solve least squares via SVD (returns backend arrays) | linalg |
t | (df, loc, scale) -> Distribution | Student’s t distribution (location-scale parameterization) | distributions |
t_dist | (df, mean, sd) -> Distribution | Student’s t distribution | distributions |
tdist_deviance | (y, mu) -> jnp.ndarray | Placeholder - use tdist(df=...) factory to get proper function | family |
tdist_dispersion | (y, mu, df_resid) -> float | Estimate dispersion (scale) parameter for Student-t family | family |
tdist_initialize | (y, weights) -> jnp.ndarray | Initialize μ for Student-t family | family |
tdist_loglik | (y, mu) -> jnp.ndarray | Placeholder - use tdist(df=...) factory to get proper function | family |
tdist_robust_weights | (y, mu, scale) -> jnp.ndarray | Placeholder - use tdist(df=...) factory to get proper function | family |
tdist_variance | (mu) -> jnp.ndarray | Student-t variance function: V(μ) = 1 | family |
theta_to_cholesky_block | (theta, dim) -> np.ndarray | Convert theta vector to lower-triangular Cholesky block | solvers |
theta_to_variance_components | (theta, sigma, group_names, random_names, re_structure) -> tuple[list[str], list[float]] | Convert theta parameters to named variance components | variance |
treatment_coding | (levels, reference) -> NDArray[np.float64] | Build treatment (dummy) contrast matrix | design |
treatment_coding_labels | (levels, reference) -> list[str] | Get column labels for treatment contrast | design |
uniform | (low, high) -> Distribution | Uniform distribution | distributions |
update_lambda_from_template | (template, theta) -> sp.csc_matrix | Update Lambda matrix from template using new theta values | solvers |
write_text | (text, path) -> None | Write text content to a file, creating parent directories | rendering |