Skip to contents

A thin wrapper on kb_predict_weight(): predict weight at the supplied new_data rows (or the observed data when new_data = NULL). For allometric curves to visualise, use kb_predict_weight_by().

Usage

# S3 method for class 'kb_fit_weight'
predict(
  object,
  new_data = NULL,
  ...,
  new_levels = c("sample", "average"),
  representative_site = NULL,
  conf_level = 0.95,
  estimate = stats::median,
  sig_fig = 3
)

Arguments

object

A kb_fit_weight object.

new_data

A data frame with a diameter column (and optional site / year columns), or NULL to predict at the observed data.

...

Unused.

new_levels

A string, one of "sample" or "average", controlling how random effects that are not conditioned on are treated (factors absent from the prediction, and any new level not seen in the fit). "sample" draws a new random effect from Normal(0, sd), widening the interval to include between-group variation; "average" holds the random effects at zero, giving the typical group. Known levels are always conditioned on. "sample" draws fresh randomness on each call, so set a seed with set.seed() for a reproducible interval.

representative_site

A character vector of site levels present in the fit, or NULL (the default). When supplied, a new or absent site takes its site main effects (intercept and slope) from the named reference site (the per-draw average when several are named), instead of the new_levels treatment; the site:year interaction still follows new_levels.

conf_level

A number between 0 and 1 giving the compatibility-interval level.

estimate

A function that reduces a numeric vector of posterior draws to a scalar point estimate (e.g. median or mean).

sig_fig

A whole number of significant figures for summary output.

Value

A kb_predictions object.

Examples

predict(fit_weight_sim_nereo, data.frame(diameter = c(20, 40)))
#> <kb_predictions> predictor: diameter | response: weight
#> # A tibble: 2 × 4
#>   diameter estimate  lower  upper
#>      <dbl>    <dbl>  <dbl>  <dbl>
#> 1       20   0.0423 0.0201 0.0999
#> 2       40   0.225  0.118  0.445