Draws of the linear predictor on the link scale (or, with
transform = TRUE, on the response scale).
Usage
# S3 method for class 'kb_fit'
posterior_linpred(
object,
transform = FALSE,
new_data = NULL,
...,
new_levels = c("average", "sample"),
representative_site = NULL
)Arguments
- object
A
kb_fitobject.- transform
A flag specifying whether to apply the inverse of the model's link function (see
kb_model_describe()).- 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
Site and year columns in new_data are handled as in posterior_epred();
with new_data = NULL the observed data is used, with its sites and years.
Examples
lp <- posterior_linpred(fit_weight_sim_nereo)
dim(lp)
#> [1] 1500 660