Add fitted values from a GAM to a data frame
Add fitted values from a GAM to a data frame
## S3 method for class 'gam' add_fitted(data, model, value = ".value", type = "response", prefix = ".", ...)
data |
a data frame containing values for the variables used to fit the
model. Passed to |
model |
a fitted model for which a |
value |
character; the name of the variable in which model predictions will be stored. |
type |
character; the type of predictions to return. See
|
prefix |
character; string to prepend to names of predicted values when
|
... |
additional arguments passed to |
A data frame (tibble) formed from data
and predictions from
model
.
load_mgcv() df <- gamSim(eg = 1, verbose = FALSE) df <- df[, c("y","x0","x1","x2","x3")] m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = 'REML') ## add_fitted(df, m) ## with type = "terms" or "iterms" add_fitted(df, m, type = "terms")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.