dev.expl.calcs: Calculates order-independent deviation explained values for...

Description Usage Arguments Value Examples

View source: R/dev.expl.calcs.R

Description

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.

Usage

1
dev.expl.calcs(model.list.output, data, select, family)

Arguments

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

Value

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.

Examples

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())

nskaff/dev.expl.mgcv documentation built on May 20, 2019, 2:09 p.m.