Description Usage Arguments Value Examples
These functions are wrappers around the E_loo
function
(loo package) that provide compatibility for rstanarm models.
1 2 3 4 5 6 7 8 9 10 11 12 | ## S3 method for class 'stanreg'
loo_predict(object, type = c("mean", "var",
"quantile"), probs = 0.5, ..., psis_object = NULL)
## S3 method for class 'stanreg'
loo_linpred(object, type = c("mean", "var",
"quantile"), probs = 0.5, transform = FALSE, ...,
psis_object = NULL)
## S3 method for class 'stanreg'
loo_predictive_interval(object, prob = 0.9, ...,
psis_object = NULL)
|
type |
The type of expectation to compute. The options are
|
probs |
For computing quantiles, a vector of probabilities. |
... |
Currently unused. |
psis_object |
An object returned by |
transform |
Passed to |
prob |
For |
A list with elements value
and pareto_k
.
For loo_predict
and loo_linpred
the value component is a
vector with one element per observation.
For loo_predictive_interval
the value
component is a matrix
with one row per observation and two columns (like
predictive_interval
). loo_predictive_interval(..., prob
= p)
is equivalent to loo_predict(..., type = "quantile", probs =
c(a, 1-a))
with a = (1 - p)/2
, except it transposes the result and
adds informative column names.
See E_loo
and pareto-k-diagnostic
for
details on the pareto_k
diagnostic.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Not run:
if (!exists("example_model")) example(example_model)
# optionally, log-weights can be pre-computed and reused
psis_result <- loo::psis(log_ratios = -log_lik(example_model))
loo_probs <- loo_linpred(example_model, type = "mean", transform = TRUE, psis_object = psis_result)
str(loo_probs)
loo_pred_var <- loo_predict(example_model, type = "var", psis_object = psis_result)
str(loo_pred_var)
loo_pred_ints <- loo_predictive_interval(example_model, prob = 0.8, psis_object = psis_result)
str(loo_pred_ints)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.