getViz: Converting gam objects to gamViz objects

View source: R/getViz.R

getVizR Documentation

Converting gam objects to gamViz objects

Description

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

Usage

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

plot(sm(b,1)) + l_fitLine() + l_ciLine() + l_rug() + l_points()
plot(sm(b,2)) + l_rug() + l_fitRaster() + l_fitContour()

mgcViz documentation built on Oct. 6, 2023, 5:09 p.m.

Related to getViz in mgcViz...