##### gam example
# Simulate data
library(mgcViz)
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=1000,dist="normal",scale=2)
# 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)
# Fit using bam() and get gamViz object
b <- bamV(y~s(x0)+s(x1, x2)+s(x3), data = dat,
aGam = list(discrete = TRUE), aViz = list("nsim" = 0))
# Either way, we plot first and third effects by doing
print(plot(b, select = c(2)), pages = 1)
Run the code above in your browser using DataLab