Draws of the expected response.
Usage
# S3 method for class 'kb_fit'
posterior_epred(
object,
new_data = NULL,
...,
new_levels = c("average", "sample"),
representative_site = NULL
)Arguments
- object
A
kb_fitobject.- new_data
A data frame with the fit's predictor column (and optional
siteandyearcolumns), orNULLfor the observed data.yearmay be numeric or character:2022and"2022"match the same fitted year.- ...
These dots are for future extensions and must be empty.
- new_levels
A string giving how uncertainty is estimated for a site or year not in the data used to fit the model, or when
new_datahas nositeoryearcolumn. Sites and years in the model fit always use their own estimates. One of:"average"(the default): the typical site or year. The site and year effects are set to 0, their mean, so the interval does not include among-site or among-year variation. Use it to describe an average site or year."sample": a new effect for each new site or year, drawn from the estimated variation among sites or among years (the random-effect standard deviation). The point estimate is equivalent, but the interval is wider since it also includes that variation. Use it to get realistic uncertainty about a particular site or year that the model has no information on. The interval varies slightly between calls; useset.seed()to reproduce it.
- representative_site
A character vector of sites in the fit whose effects a new site adopts (averaged when several are named), or
NULL(the default) to follownew_levels.
Details
Each draw is the expected response, the mean of the fit's likelihood (see
kb_model_describe()), given that draw's parameters. For a cover
calibration with a presence part, it includes the probability that the plot
has plants present. For a Nereocystis weight fit, which is modelled on the
log scale, it is the mean weight, not the median.
For draws of new observations, which include residual variation, use
posterior_predict().
A site (and optionally year) column in new_data with levels in the fit
gives predictions for those levels. With new_data = NULL the observed data
is used, with its sites and years.
See also
kb_predict_weight(), which summarises these draws.
Other fit methods:
augment.kb_fit(),
coef.kb_fit(),
fitted.kb_fit(),
glance.kb_fit(),
kb_model_describe(),
kb_samples(),
kb_stancode(),
log_lik.kb_fit(),
posterior_linpred.kb_fit(),
posterior_predict.kb_fit(),
prior_summary.kb_fit(),
residuals.kb_fit(),
summary.kb_fit(),
tidy.kb_fit()
Examples
ep <- posterior_epred(fit_weight_sim_nereo)
dim(ep)
#> [1] 1500 660