brms results
Result types for brmspy functions.
Classes¶
PriorSpec
dataclass
¶
Python representation of a brms prior specification.
This dataclass provides a typed interface to brms::prior_string() arguments,
allowing Python developers to specify priors with IDE autocomplete and type
checking. Use the prior() factory function to create
instances.
Attributes:
| Name | Type | Description |
|---|---|---|
prior |
str
|
Prior distribution as string (e.g., |
class_ |
(str, optional)
|
Parameter class: |
coef |
(str, optional)
|
Specific coefficient name for class-level priors. |
group |
(str, optional)
|
Grouping variable for hierarchical effects. |
dpar |
(str, optional)
|
Distributional parameter (e.g., |
resp |
(str, optional)
|
Response variable for multivariate models. |
nlpar |
(str, optional)
|
Non-linear parameter name. |
lb |
(float, optional)
|
Lower bound for truncated priors. |
ub |
(float, optional)
|
Upper bound for truncated priors. |
See Also
prior : Factory function to create PriorSpec instances.
brms::prior_string : R documentation
Examples:
Create prior specifications (prefer using prior()):
from brmspy.types import PriorSpec
# Fixed effect prior
p1 = PriorSpec(prior="normal(0, 1)", class_="b")
# Group-level SD prior
p2 = PriorSpec(prior="exponential(2)", class_="sd", group="patient")
# Coefficient-specific prior with bounds
p3 = PriorSpec(prior="normal(0, 1)", class_="b", coef="age", lb=0)
IDConstantData
¶
Bases: InferenceData
Typed .constant_data extension to idata
IDPredictionsConstantData
¶
Bases: InferenceData
Typed .predictions_constant_data extension to idata
IDObservedData
¶
IDPosterior
¶
IDPosteriorPredictive
¶
IDPredictions
¶
IDLogLikelihoodInsample
¶
IDLogLikelihoodOutsample
¶
IDBrm
¶
Bases: IDConstantData
Typed arviz.InferenceData for fitted brms models.
Extends arviz.InferenceData with type hints for IDE autocomplete. In brmspy,
the fitted model result typically exposes an .idata attribute of this type.
Attributes:
| Name | Type | Description |
|---|---|---|
posterior |
Dataset
|
Posterior samples of model parameters. |
posterior_predictive |
Dataset
|
Posterior predictive samples (with observation noise). |
log_likelihood |
Dataset
|
Log-likelihood values for each observation. |
observed_data |
Dataset
|
Original observed response data. |
coords |
dict
|
Coordinate mappings for dimensions (inherited from |
dims |
dict
|
Dimension specifications for variables (inherited from |
See Also
brmspy.brms.brm : Creates fitted model results (alias: brmspy.brms.fit).
arviz.InferenceData : Base class documentation.
Examples:
from brmspy import brms
model = brms.brm("y ~ x", data=df, chains=4)
# Type checking and autocomplete
assert isinstance(model.idata, IDFit)
print(model.idata.posterior)
RListVectorExtension
dataclass
¶
Generic result container with R objects.
Attributes:
| Name | Type | Description |
|---|---|---|
r |
ListVector
|
R object from brms |
IDResult
dataclass
¶
Bases: Generic[T_idata], RListVectorExtension
Generic result container with arviz and R objects.
Attributes:
| Name | Type | Description |
|---|---|---|
idata |
InferenceData
|
arviz InferenceData object |
r |
ListVector
|
R object from brms |
SummaryResult
dataclass
¶
Bases: RListVectorExtension
Parsed summary output for a fitted model.
This is a convenience container that holds both:
- structured Python data (mostly pandas DataFrames)
- the underlying R object reference in
.r(as a worker-side handle)
Attributes:
| Name | Type | Description |
|---|---|---|
formula |
str
|
Model formula string as reported by brms. |
data_name |
str
|
Data name as reported by brms (may be an internal label). |
nobs |
int
|
Number of observations. |
prior |
DataFrame
|
Prior summary table. |
fixed |
DataFrame
|
Fixed effects summary table. |
random |
dict[str, DataFrame] or None
|
Random effects summary tables (if present). |
LooResult
dataclass
¶
Bases: RListVectorExtension
Parsed brms::loo() result.
Attributes:
| Name | Type | Description |
|---|---|---|
estimates, pointwise, diagnostics |
DataFrame
|
LOO tables. |
psis_object |
Any or None
|
PSIS object (if present). May be an R-handle wrapper depending on conversion. |
elpd_loo, p_loo, looic |
float
|
Key scalar metrics. |
se_elpd_loo, se_p_loo, se_looic |
float
|
Standard errors for the corresponding scalars. |
LooCompareResult
dataclass
¶
Bases: RListVectorExtension
Result of comparing models by a LOO-style criterion.
Attributes:
| Name | Type | Description |
|---|---|---|
table |
DataFrame
|
Comparison table. |
criterion |
str
|
Criterion name (e.g. |