This function converts gam objects into gamViz objects, for which mgcViz provides several plotting methods.

getViz(o, nsim = 0, post = FALSE, newdata, ...)

Arguments

o

an object of class gam.

nsim

the number of simulated vectors of responses. A positive integer.

post

if TRUE then posterior simulation is performed. That is, we simulate nsim vectors of regression coefficients from a Gaussian approximation to the posterior, and then we simulate a vector of response using each parameter vector. If FALSE, then nsim vectors of responses are simulated using parameters fixed at the posterior mode.

newdata

Optional new data frame used to perform the simulations. To be passed to predict.gam and, if post == TRUE, to postSim.

...

extra arguments to be passed to simulate.gam (if post==FALSE) or postSim (if post==TRUE). For instance, we could pass prior weights w and offset.

Value

An object of class gamViz.

Examples

library(mgcViz) set.seed(2) ## simulate some data... dat <- gamSim(1,n=1000,dist="normal",scale=2)
#> Gu & Wahba 4 term additive model
b <- gam(y~s(x0)+s(x1, x2)+s(x3), data=dat, method="REML") b <- getViz(b, nsim = 20) str(b$store$sim) # Simulated responses now stored here
#> num [1:20, 1:1000] 1.3 7 2.14 3.62 7.78 ...
plot(sm(b,1)) + l_fitLine() + l_ciLine() + l_rug() + l_points()