[R] Simulate from a GAM model

Mark Lyman mark.lyman at gmail.com
Tue Jul 1 19:12:44 CEST 2008


Does anybody have any suggestions on how I might simulate from fitted GAM 
model? I am using the gam function in the mgcv package to fit a variable 
coefficient model like the following from the examples. I would like simulate 
based on the fitted model like the simulate function in the stats package does 
for lm models.

library(mgcv)
set.seed(10)
## simulate date from y = f(x2)*x1 + error
dat <- gamSim(3,n=400)
b<-gam(y ~ s(x2,by=x1),data=dat)


Thanks for any help you can give,
Mark Lyman



More information about the R-help mailing list