It returns a tibble with the predictions from all the terms in a gam or bam model.

predict_gam(model, exclude_terms = NULL, length_out = 50, values = NULL)

Arguments

model

A gam or bam model object.

exclude_terms

Terms to be excluded from the prediction. Term names should be given as they appear in the model summary (for example, "s(x0,x1)").

length_out

An integer indicating how many values along the numeric predictors to use for predicting the outcome term (the default is 50).

values

User supplied values for specific terms as a named list. If the value is NULL, the first value of the term is selected (useful when excluding terms).

Value

A tibble with predictions from a gam or bam model.

Examples

if (FALSE) { library(mgcv) set.seed(10) data <- gamSim(4) model <- gam(y ~ fac + s(x2) + s(x2, by = fac) + s(x0), data = data) # get predictions p <- predict_gam(model) # get predictions excluding x0 (the coefficient of x0 is set to 0); # setting the value for the excluded term to NULL with the argument 'values' # reduces computation time p_2 <- predict_gam(model, exclude_terms = "s(x0)", values = list(x0 = NULL)) # get predictions with chosen values of x0 p_3 <- predict_gam(model, values = list(x0 = c(0.250599, 0.503313, 0.756028))) }