Skip to contents

From an MGCV model, create a dataframe (tibble) of values to predict across, including all combinations of categorical predictors in the model, and incrementing across the plot_by variable, and using median values of other numeric predictors. Used by predict_gam() – see there for more details

Usage

create_prediction_df(
  model,
  plot_by = "doy",
  across_increment = 1,
  quant_trimming = 0.01,
  verbose = TRUE
)

Arguments

model

A GAM model object from mgcv, or a named list of fitted mgcv models

plot_by

A single string specifying the variable to plot across. Defaults to "doy".

across_increment

A numeric value specifying the increment for the plot_by variable. Defaults to 1.

quant_trimming

A numeric value between 0 and 1 defining quantile-based trimming – this provides a buffer between the outmost observations and the outmost plot predictions. Defaults to 0.01; increase if plot predictions at the edges are misleading.

verbose

Provide context? Logical, defaults to TRUE

Value

tibble of variables relevant for the provided model, with all relevant combinations of variable values.