prediction
Prediction helpers for brms models.
This module wraps brms prediction utilities and returns typed result objects that
contain both an ArviZ InferenceData view and the underlying R result.
Notes
Executed inside the worker process that hosts the embedded R session.
Classes¶
Functions¶
posterior(model, **kwargs)
¶
Return posterior draws as idata.
Wrapper around R posterior::as_draws_df().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
FitResult
|
Fitted model. |
required |
**kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
PosteriorEpredResult
|
Result containing |
Examples:
posterior_epred(model, newdata=None, **kwargs)
¶
Compute expected posterior predictions (noise-free).
Wrapper around R brms::posterior_epred(). This returns draws of the
expected value (typically on the response scale), without observation noise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
FitResult
|
Fitted model. |
required |
newdata
|
DataFrame or None
|
New data for predictions. If |
None
|
**kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
PosteriorEpredResult
|
Result containing |
See Also
brms::posterior_epred : R documentation
Examples:
posterior_predict(model, newdata=None, **kwargs)
¶
Draw from the posterior predictive distribution (includes observation noise).
Wrapper around R brms::posterior_predict().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
FitResult
|
Fitted model. |
required |
newdata
|
DataFrame or None
|
New data for predictions. If |
None
|
**kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
PosteriorPredictResult
|
Result containing |
See Also
brms::posterior_predict : R documentation
Examples:
posterior_linpred(model, newdata=None, **kwargs)
¶
Draw from the linear predictor.
Wrapper around R brms::posterior_linpred(). This typically returns draws
on the link scale (before applying the inverse link), unless you pass
transform=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
FitResult
|
Fitted model. |
required |
newdata
|
DataFrame or None
|
New data for predictions. If |
None
|
**kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
PosteriorLinpredResult
|
Result containing |
See Also
brms::posterior_linpred : R documentation
Examples:
log_lik(model, newdata=None, **kwargs)
¶
Compute pointwise log-likelihood draws.
Wrapper around R brms::log_lik(). The result is useful for LOO/WAIC via ArviZ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
FitResult
|
Fitted model. |
required |
newdata
|
DataFrame or None
|
New data. If |
None
|
**kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
LogLikResult
|
Result containing |
See Also
brms::log_lik : R documentation
Examples: