Description Usage Arguments Value Examples
View source: R/dev.expl.calcs.R
Calculates the deviation explained for individual covariates in a generalized additive model (gam) from the 'mgcv' package such that the calculated value isn't dependent on order of covariate removal. This is accomplished by calculating the deviation explained for all potential models built from the supplied covariates and response, then calculating the mean difference in deviance explained between models with and without each covariate. The sum of the deviation explained for each covariate may not equal the deviation explained for a model that includes all covariates due to rounding error. The runtime may be very long for models with many covariates.
1 | dev.expl.calcs(model.list.output, data, select, family)
|
model.list.output |
Object created from model.list function |
data |
The data to be used in the GAM model. Must be a data frame. |
select |
Logical indicating whether to use MGCV automatic smoothness selection. See: https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/gam.selection.html |
family |
An object of class "family". See: https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/family.mgcv.html |
A vector of numeric values representing the partial deviation explained for each covariate. Each value is determined by calculating the mean difference between all full and reduced models for each covariate.
1 2 3 4 5 6 7 8 9 | library(mgcv)
library(dev.expl.mgcv)
#adapted from mgcv documentation
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
b <- gam(y~1+x0+s(x0, k=4)+ti(x2, x3, k=4),data=dat)
model.list.output<-model.list(covariates = c("x0","s(x0, k=4)",
"ti(x2, x3, k=4)"), response="y~1")
dev.expl.calcs(model.list.output, dat, select = TRUE,family = gaussian())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.