Description Usage Arguments Details Value See Also Examples
Use predict in an lme4 style on gam/bam objects from mgcv.
1 2 3 4 5 6 7 8 9 10 |
model |
A gam class model from the |
newdata |
Data on which to predict on. Empty by default. |
re_form |
|
se |
Logical. Include standard errors or not. Default is FALSE. |
include |
Which random effects to include in prediction. See
|
exclude |
Which random effects to exclude in prediction. See
|
keep_prediction_data |
Keep the model frame or newdata that was used in the prediction in final output? Default is FALSE. |
... |
Other arguments for |
This is a wrapper for predict.gam. The goal is to
have similar functionality with predict function in lme4, which makes it
easy to drop all random effects or include specific ones. Some of this
functionality is not yet available for class bam.
A data frame of predictions and possibly standard errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | library(lme4)
library(mgcv)
lmer_model <- lmer(Reaction ~ Days + (Days || Subject), data = sleepstudy)
ga_model <- gam(Reaction ~ Days + s(Subject, bs = "re") + s(Days, Subject, bs = "re"),
data = sleepstudy,
method = "REML"
)
head(
data.frame(
lmer = predict(lmer_model),
gam = predict_gamm(ga_model)
)
)
head(
cbind(
lmer = predict(lmer_model, re.form = NA),
gam1 = predict_gamm(ga_model, re_form = NA),
gam2 = predict_gamm(ga_model,
exclude = c("s(Subject)", "s(Days,Subject)")
)
)
)
head(predict_gamm(ga_model, se = TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.