Thanks Gavin! Works great. I'm quite impressed how quickly this user list responds to questions.
One additional point of inquiry: I'm wondering if by using a range of values over each of the predictors I am creating some bias to the standard error (e.g. when the distribution of the predictor is skewed). If using some other distribution of values for predict(), do you have any suggestions how this might be accomplished [e.g. quantile(predictor) --> dbinom --> rbionom() ]? I have very little experience working with number generation outside of runif() and rnorm(). Thanks again for your help, Marc On Mon, Jul 25, 2011 at 12:40 PM, Gavin Simpson <gavin.simp...@ucl.ac.uk>wrote: > On Mon, 2011-07-25 at 12:14 +0200, Marc Taylor wrote: > > Dear r-sig-ecology list users, > > > > I have been using the mgcv package for fitting a GAM model to a large set > of > > spatial/temporal data with several predictors. Each variable contains > > > 1,000,000 values... > > I have been able to successfully fit a model using the bam() function for > > large data sets. It takes a while but the results seem to be favorable. > My > > setup looks something like this: > > > > require(mgcv) > > bs="cr";k=10 > > res <- bam(CHLA ~ s(SSS, bs = bs, k = k) + s(SST, bs = bs, k = k) + > > s(SIarea, > > bs = bs, k = k) + s(ZOOC, bs = bs, k = k) + s(DIN, bs = bs, > > k = k) + s(DSI, bs = bs, k = k) + s(DFE, bs = bs, k = k), data=DB) > > > > I was hoping someone might be able to suggest a way to extract the values > of > > plot.gam (smooth function and standard error). My reason for wanting to > do > > this is to be able to create a single graphic of several different gam > fits > > at a later time. The "res" object above becomes very large, and I would > like > > to avoid saving the entire object. > > I think you are going to have to keep `res` around. However, you don't > want to extract things from the object to produce plots (plotting 1M > observations is not going to be quick or pretty in R). It has to be > created anyway, so storing it for a while while you use it isn't a > problem. > > Instead, `predict()` from the fitted model for say 100-200 observations > over the range of each covariate. Use `type = "terms"` to get back the > individual contributions of the smooth terms to the fitted/predicted > values. using `se.fit = TRUE` will also return standard errors on those > terms, which you can use to build approximate 95% confidence intervals. > > HTH > > G > > > Many thanks for your help. > > > > Cheers, > > Marc > > > > [[alternative HTML version deleted]] > > > > _______________________________________________ > > R-sig-ecology mailing list > > R-sig-ecology@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology > > -- > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% > Dr. Gavin Simpson [t] +44 (0)20 7679 0522 > ECRC, UCL Geography, [f] +44 (0)20 7679 0565 > Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk > Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ > UK. WC1E 6BT. [w] http://www.freshwaters.org.uk > %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% > > [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology