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.

Containers Reference

UCSD Psychology

All container classes, builder functions, and validators from bossanova.internal.containers. See Container Overview for the pipeline diagram.

Container Classes

DataBundle

Validated model data (valid observations only)

FieldType
XNDArray[np.floating]
X_namestuple[str, ...]
Zsp.csc_matrix | None
contrast_typesdict[str, str]
factor_levelsdict[str, tuple[str, ...]]
has_random_effectsbool
nint
n_totalint
offsetNDArray[np.floating] | None
pint
rankint
rank_infoRankInfo | None
re_metadataREInfo | None
response_levelstuple[str, ...] | None
valid_maskNDArray[np.bool_]
weightsNDArray[np.floating] | None
yNDArray[np.floating]
y_namestr

REInfo

Random effects metadata

FieldType
X_reNDArray[np.float64] | list[NDArray[np.float64]] | None
group_ids_listlist[NDArray[np.intp]]
group_indicesdict[str, NDArray[np.intp]]
grouping_varstuple[str, ...]
metadatadict
n_groupsdict[str, int]
n_groups_listlist[int]
random_nameslist[str]
re_structurestr
term_namestuple[str, ...]

RankInfo

Rank deficiency information for a design matrix

FieldType
dropped_indicestuple[int, ...]
dropped_namestuple[str, ...]
is_deficientbool
kept_indicesNDArray[np.intp]
pint
rankint

MathDisplay

Display wrapper for model equation with IPython rich display

FieldType
equationstr
explanationstuple[str, ...]

TermInfo

Parsed information about a single model term

FieldType
base_varstr
explanationstr
latexstr
namestr
symbolstr
term_typestr

Condition

A conditioning specification in explore formula

FieldType
at_quantileint | None
at_rangeint | None
at_valuestuple | None
contrast_exprContrastExpr | None
varstr

ContrastExpr

Bracket contrast expression: Drug[A - B, C - D]

FieldType
itemstuple[ContrastItem, ...]
varstr

ContrastItem

A single contrast: left operand minus right operand

FieldType
leftContrastOperand
rightContrastOperand

ContrastOperand

One side of a bracket contrast item

FieldType
is_wildcardbool
levelstuple[str, ...]

ExploreFormulaError

Error in explore formula syntax

FieldType
formula``
position``

ExploreFormulaSpec

Parsed explore formula

FieldType
conditionstuple[Condition, ...]
contrast_degreeint | None
contrast_exprContrastExpr | None
contrast_level_orderingtuple[str, ...] | None
contrast_refstr | None
contrast_typestr | None
focal_at_quantileint | None
focal_at_rangeint | None
focal_at_valuestuple[float | str, ...] | None
focal_varstr
has_conditionsbool
has_contrastbool
has_contrast_exprbool
has_rhs_contrastsbool

FitState

Immutable fitting result

FieldType
XtWX_invNDArray[np.floating] | None
coefNDArray[np.floating]
convergedbool
deviancefloat | None
df_residfloat
dispersionfloat | None
fittedNDArray[np.floating]
irls_weightsNDArray[np.floating] | None
leverageNDArray[np.floating]
loglikfloat
n_iterint
null_deviancefloat | None
residualsNDArray[np.floating]
sigmafloat | None
thetaNDArray[np.floating] | None
uNDArray[np.floating] | None
vcovNDArray[np.floating]

FormulaSpec

Learned formula encoding — everything needed to replay on new data

FieldType
contrast_matricesdict[str, NDArray]
contrast_typesdict[str, str]
custom_contrastsdict[str, NDArray]
factorsdict[str, tuple[str, ...]]
formulastr
has_interceptbool
has_random_effectsbool
nested_metadatadict
re_termstuple
response_transformtuple[str, ...] | None
response_varstr | None
rhs_termstuple
transform_statedict[str, dict]
transformsdict[str, object]
uncorr_metadatadict

CVState

Cross-validation results for model evaluation

FieldType
accuracyfloat | None
aucfloat | None
deviancefloat | None
f1float | None
fold_assignmentsnp.ndarray | None
fold_metricsdict[str, np.ndarray]
kint
maefloat
oos_predictionsnp.ndarray | None
oos_residualsnp.ndarray | None
r_squaredfloat
rmsefloat
sensitivityfloat | None
specificityfloat | None

InferenceState

Inference results that augment params or estimates

FieldType
alternativestr
boot_samplesnp.ndarray | None
ci_lowernp.ndarray
ci_uppernp.ndarray
conf_levelfloat
dfnp.ndarray
methodstr
n_resamplesint | None
nullfloat
p_valuenp.ndarray
perm_samplesnp.ndarray | None
prenp.ndarray | None
pre_sdnp.ndarray | None
senp.ndarray
statisticnp.ndarray

JointTestState

Joint hypothesis test results for model terms

FieldType
df1np.ndarray
df2np.ndarray | None
p_valuenp.ndarray
ss_typestr
statisticnp.ndarray
termstuple[str, ...]
test_typestr

ResamplesState

Unified resampling results from bootstrap or permutation inference

FieldType
contextstr
methodstr
n_resamplesint
namestuple[str, ...]
observednp.ndarray
samplesnp.ndarray

MeeState

Marginal effects / estimated marginal means results

FieldType
L_matrixnp.ndarray | None
L_matrix_linknp.ndarray | None
ci_lowernp.ndarray | None
ci_uppernp.ndarray | None
conf_levelfloat | None
contrast_methodstr | None
dfnp.ndarray | None
effect_scalestr
estimatenp.ndarray
explore_formulastr
focal_varstr
grid'pl.DataFrame'
has_inferencebool
howstr
inference_methodstr | None
linkstr | None
n_contrast_levelsint | None
p_valuenp.ndarray | None
senp.ndarray | None
statisticnp.ndarray | None
typestr

ProfileState

Profile likelihood state for variance component CIs

FieldType
ci_lower_sdNDArray[np.floating]
ci_sddict[str, tuple[float, float]]
ci_thetadict[str, tuple[float, float]]
ci_upper_sdNDArray[np.floating]
conf_levelfloat
dev_optfloat
spline_forwarddict[str, Any]
spline_reversedict[str, Any]
table'pl.DataFrame'
thresholdfloat

VaryingSpreadState

Variance components for mixed models

FieldType
ci_lowerdict[str, float] | None
ci_methodstr | None
ci_upperdict[str, float] | None
components'pl.DataFrame'
conf_levelfloat | None
has_inferencebool
iccfloat | None
rhodict[str, float]
sigma2float
tau2dict[str, float]

VaryingState

Random effects (BLUPs) for mixed models

FieldType
conf_levelfloat | None
effectsdict[str, np.ndarray]
grid'pl.DataFrame'
grouping_varstr
has_inferencebool
n_groupsint
pi_lowerdict[str, np.ndarray] | None
pi_upperdict[str, np.ndarray] | None

PredictionConfig

Configuration that produced a PredictionState

FieldType
allow_new_levelsbool
formula_specAny
newdata'pl.DataFrame | None'
pred_typestr
training_data'pl.DataFrame | None'
varyingstr

PredictionState

Prediction results with optional intervals

FieldType
X_prednp.ndarray | None
ci_lowernp.ndarray | None
ci_uppernp.ndarray | None
conf_levelfloat | None
configPredictionConfig | None
cv_fittednp.ndarray | None
cv_foldnp.ndarray | None
cv_residualnp.ndarray | None
fittednp.ndarray
grid'pl.DataFrame | None'
has_cvbool
has_inferencebool
interval_typestr | None
linknp.ndarray | None
senp.ndarray | None

SimulationInferenceState

Simulation inference results for post-fit or power analysis simulations

FieldType
alphafloat
biasdict[str, float]
coveragedict[str, float]
n_simsint
powerdict[str, float]
rmsedict[str, float]
sim_meannp.ndarray | None
sim_quantilesdict[str, np.ndarray]
sim_sdnp.ndarray | None
sim_typestr
true_coefdict[str, float]

Distribution

Protocol for distribution objects that can generate random samples

ModelSpec

Immutable model configuration

FieldType
familystr
fixed_termstuple[str, ...]
formulastr
has_random_effectsbool
linkstr
methodstr
random_termstuple[str, ...]
response_varstr

SimulationSpec

Specification for data generation in simulation-first workflows

FieldType
coefdict[str, float]
distributionsdict[str, Distribution]
nint
re_specdict[str, VaryingSpec]
seedint | None
sigmafloat

VaryingSpec

Specification for random effect grouping in simulation

FieldType
correlationsdict[tuple[str, str], float]
nint
n_perint | None
sdfloat
slope_sdsdict[str, float]

Col

Namespace for all column name constants used across DataFrame outputs

FieldType
AICstr
AIC_Rstr
BIASstr
BICstr
BIC_Rstr
CHI2str
CHISQstr
CI_INCREASE_FACTORstr
CI_LOWERstr
CI_METHODstr
CI_UPPERstr
COHENS_Dstr
COMPONENTstr
CONTRASTstr
CONVERGEDstr
COOKSDstr
CORRstr
COVERAGEstr
CV_DEVIANCEstr
CV_FITTEDstr
CV_FOLDstr
CV_Kstr
CV_MAEstr
CV_MAE_SDstr
CV_RESIDUALstr
CV_RMSEstr
CV_RMSE_SDstr
CV_RSQUAREDstr
CV_RSQUARED_SDstr
CV_SCOREstr
CV_SEstr
DELTA_AICstr
DELTA_BICstr
DEVIANCEstr
DEV_DIFFstr
DFstr
DF1str
DF2str
DF_MODELstr
DF_RESIDstr
DIFFstr
DIFF_SEstr
DISPERSIONstr
D_LOWERstr
D_UPPERstr
EFFECT1str
EFFECT2str
EMPIRICAL_SEstr
ESTIMATEstr
ETA_SQstr
FITTEDstr
FSTATISTICstr
FSTATISTIC_PVALUEstr
F_RATIOstr
F_STATstr
GROUPstr
HATstr
ICCstr
IS_SINGULARstr
LEVELstr
LINKstr
LOGLIKstr
MEAN_SEstr
MODELstr
Nstr
NGROUPSstr
NOBSstr
NOBS_MISSINGstr
NOBS_TOTALstr
NPARstr
NPARAMSstr
NULL_DEVIANCEstr
N_FAILEDstr
N_ITERstr
N_SIMSstr
N_THETAstr
OBSERVEDstr
ODDS_RATIOstr
OPTIMIZERstr
PI_LOWER_PREFIXstr
PI_UPPER_PREFIXstr
POWERstr
POWER_CI_LOWERstr
POWER_CI_UPPERstr
PREstr
PRE_Rstr
PRE_SDstr
PSEUDO_RSQUAREDstr
P_VALUEstr
RESAMPLEstr
RESIDstr
RHO_PREFIXstr
RHS_CONTRASTstr
RMSEstr
RSQUAREDstr
RSQUARED_ADJstr
RSQUARED_CONDITIONALstr
RSQUARED_MARGINALstr
RSSstr
R_SEMIstr
SEstr
SIGMAstr
SIGMA2str
SIM_MEANstr
SIM_Q025str
SIM_Q975str
SIM_SDstr
SSstr
STATISTICstr
STD_RESIDstr
TAU2_PREFIXstr
TERMstr
TERM_TYPEstr
TRUE_VALUEstr
T_STATstr
VALUEstr
VIFstr
WEIGHTstr

Builder Functions

FunctionSignatureDescriptionModule
build_cv_state(k, rmse, mae, r_squared, deviance, accuracy, sensitivity, specificity, f1, auc, fold_metrics, oos_predictions, oos_residuals, fold_assignments) -> CVStateBuild a CVState from cross-validation computationbuilders
build_effects_dataframe(mee, method) -> pl.DataFrameBuild the .effects DataFrame from marginal effects statebuilders
build_fit_state(coef, vcov, fitted, residuals, leverage, df_resid, loglik, converged, n_iter, sigma, dispersion, null_deviance, deviance, theta, u, irls_weights, XtWX_inv) -> FitStateBuild a FitState instance with validationbuilders
build_inference_state(se, statistic, df, p_value, ci_lower, ci_upper, conf_level, method, null, alternative, n_resamples, boot_samples, perm_samples, pre, pre_sd) -> InferenceStateBuild an InferenceState from computed inference valuesbuilders
build_joint_test_dataframe(state) -> pl.DataFrameBuild an ANOVA-style DataFrame from joint test resultsbuilders
build_joint_test_state(terms, df1, statistic, p_value, test_type, ss_type, df2) -> JointTestStateBuild a JointTestState from computed joint test valuesbuilders
build_mee_resamples(mee, samples, how) -> ResamplesState | NoneBuild ResamplesState from MEE inference if samples are availablebuilders
build_mee_state(grid, estimate, explore_formula, focal_var, mee_type, how, effect_scale, L_matrix, contrast_method, n_contrast_levels, link, L_matrix_link, boot_X_plus, boot_X_minus, boot_delta, se, df, statistic, p_value, ci_lower, ci_upper, conf_level) -> MeeStateBuild a MeeState from marginal effects computationbuilders
build_model_spec(formula, family, link, method, response_var, fixed_terms, random_terms, has_random_effects) -> ModelSpecBuild a ModelSpec from raw inputsbuilders
build_model_spec_from_formula(formula, family, link, method, structure) -> ModelSpecBuild ModelSpec from a pre-parsed formula structure and resolve defaultsbuilders
build_params_dataframe(bundle, fit, params_inference) -> pl.DataFrameBuild the .params DataFrame from fit statebuilders
build_params_resamples(inference, fit_coef, x_names, how) -> ResamplesState | NoneBuild ResamplesState from params inference if samples are availablebuilders
build_prediction_state(fitted, link, X_pred, config, se, ci_lower, ci_upper, interval_type, conf_level, grid) -> PredictionStateBuild a PredictionState from prediction computationbuilders
build_predictions_dataframe(pred) -> pl.DataFrameBuild the .predictions DataFrame from prediction statebuilders
build_resamples_dataframe(rs) -> pl.DataFrameBuild a long-format DataFrame of raw resampled valuesbuilders
build_resamples_state(samples, observed, names, method, n_resamples, context) -> ResamplesStateBuild a ResamplesState from resampling resultsbuilders
build_simulation_inference_state(sim_type, n_sims, sim_mean, sim_sd, sim_quantiles, power, coverage, bias, rmse, alpha, true_coef) -> SimulationInferenceStateBuild a SimulationInferenceState from computed valuesbuilders
build_simulation_spec(n, distributions, coef, sigma, re_spec, seed) -> SimulationSpecBuild a SimulationSpec for data generationbuilders
build_simulation_spec_from_formula(formula, n, distributions, coef, sigma, seed) -> SimulationSpecBuild SimulationSpec from formula with defaults for unspecified variablesbuilders
build_simulations_dataframe(simulations, sim_inference) -> pl.DataFrameBuild the .simulations DataFrame with optional inference columnsbuilders
build_varying_corr_dataframe(varying_spread) -> pl.DataFrameBuild the .varying_corr DataFrame from random effect correlationsbuilders
build_varying_offsets_dataframe(varying_offsets) -> pl.DataFrameBuild the .varying_offsets DataFrame from varying statebuilders
build_varying_params_dataframe(bundle, fit, varying_offsets) -> pl.DataFrameBuild the .varying_params DataFrame (population + offsets)builders
build_varying_spec(n, sd, slope_sds, correlations, n_per) -> VaryingSpecBuild a VaryingSpec for random effect structurebuilders
build_varying_spread_dataframe(varying_spread) -> pl.DataFrameBuild the .varying_spread DataFrame from variance componentsbuilders
build_varying_spread_state(components, sigma2, tau2, rho, icc, ci_lower, ci_upper, conf_level, ci_method) -> VaryingSpreadStateBuild a VaryingSpreadState from variance component estimatesbuilders
build_varying_state(grid, effects, grouping_var, n_groups, pi_lower, pi_upper, conf_level) -> VaryingStateBuild a VaryingState from computed BLUPsbuilders

Validators

FunctionSignatureDescription
is_choice_str(choices) -> ...Build a validator for a string constrained to a fixed set of choices
is_conf_level(instance, attribute, value) -> NoneValidate that a value is a normalized confidence level in (0, 1)
is_ndarray(instance, attribute, value) -> NoneValidate that a value is a numpy ndarray
is_nonnegative_int(instance, attribute, value) -> NoneValidate that a value is a non-negative integer
is_optional_conf_level(instance, attribute, value) -> NoneValidate that a value is a normalized confidence level or None
is_optional_int(instance, attribute, value) -> NoneValidate that a value is an int or None
is_optional_ndarray(instance, attribute, value) -> NoneValidate that a value is a numpy ndarray or None
is_optional_positive_int(instance, attribute, value) -> NoneValidate that a value is a positive integer or None
is_optional_sparse_csc(instance, attribute, value) -> NoneValidate that a value is a scipy.sparse.csc_matrix or None
is_optional_str(instance, attribute, value) -> NoneValidate that a value is a string or None
is_optional_str_key_dict(instance, attribute, value) -> NoneValidate that a value is a dict with string keys or None
is_optional_tuple_of_str(instance, attribute, value) -> NoneValidate that a value is a tuple of strings or None
is_positive_int(instance, attribute, value) -> NoneValidate that a value is a positive integer
is_tuple_of_str(instance, attribute, value) -> NoneValidate that a value is a tuple of strings
normalize_conf_level(conf_level) -> floatNormalize conf_level to a float in (0, 1)
normalize_optional_conf_level(conf_level) -> float | NoneNormalize an optional confidence level
validate_correlations(instance, attribute, value) -> NoneValidate correlation values are in [-1, 1]
validate_sigma(instance, attribute, value) -> NoneValidate sigma is non-negative
validate_slope_sds(instance, attribute, value) -> NoneValidate slope SDs are non-negative

Schemas & Constants

ConstantDescription
AugmentedDataCols
ComparisonAic
ComparisonBic
ComparisonCv
ComparisonDevianceChi2
ComparisonDevianceF
ComparisonFTest
ComparisonLrt
DiagnosticsCvCols
DiagnosticsGaussian
DiagnosticsGlm
DiagnosticsLmer
DiagnosticsPredCvCols
EffectsAsympCols
EffectsBaseCols
EffectsBootCols
EffectsPermCols
MetadataBase
MetadataMixed
ParamsAsymp
ParamsBase
ParamsBoot
ParamsCv
ParamsPerm
PowerSummaryCols
PredictionsAsymp
PredictionsBase
PredictionsCv
ResamplesRawSchema
SimulationsInferCols
VaryingCorrSchema
VaryingOffsetsBaseCols
VaryingOffsetsInferSuffix
VaryingParamsBaseCols
VaryingSpreadBase
VaryingSpreadInfer
VifSchema