These are wrapper that fits a GAM model using mgcv::gam or mgcv::bam and
converts it to a gamViz
object using the getViz function.
It is essentially a shortcut.
bamV( formula, family = gaussian(), data = list(), method = "fREML", aGam = list(), aViz = list() ) gamV( formula, family = gaussian(), data = list(), method = "REML", aGam = list(), aViz = list() )
formula, family, data, method | |
---|---|
aGam | list of further arguments to be passed to mgcv::gam or mgcv::bam. |
aViz | list of arguments to be passed to getViz. |
An object of class "gamViz" which can, for instance, be plotted using plot.gamViz.
##### gam example # Simulate data library(mgcViz) set.seed(2) ## simulate some data... dat <- gamSim(1,n=1000,dist="normal",scale=2)#> Gu & Wahba 4 term additive model# Fit GAM and get gamViz object b <- gamV(y~s(x0)+s(x1, x2)+s(x3), data = dat, aGam = list(scale = 2), aViz = list("nsim" = 20)) # This is equivalent to doing # 1. Fit GAM # b <- gam(y~s(x0)+s(x1, x2)+s(x3), data=dat, method="REML", scale = 2) # 2. Convert to gamViz object # b <- getViz(b, nsim = 20) # Either way, we plot first and third effects by doing print(plot(b, select = c(1, 3)), pages = 1)##### bam example # Simulate data library(mgcViz) set.seed(2) ## simulate some data... dat <- gamSim(1,n=2000,dist="normal",scale=2)#> Gu & Wahba 4 term additive model