Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getViz

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

Visualisations for Generalized Additive Models

v0.1.6
GPL-3
Authors
Matteo Fasiolo [aut, cre], Raphael Nedellec [aut], Yannig Goude [ctb], Christian Capezza [ctb], Simon N. Wood [ctb]
Initial release
2020-03-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.