Skip to content

package mgcv, command gamm

2 messages · Wadud, Zia, Simon Wood

#
On Monday 04 December 2006 15:04, Wadud, Zia wrote:
here's a working example....
 library(mgcv)
      ## simple examples using gamm as alternative to gam
      set.seed(0)
      n <- 400
      sig <- 2
      x0 <- runif(n, 0, 1)
      x1 <- runif(n, 0, 1)
      x2 <- runif(n, 0, 1)
      x3 <- runif(n, 0, 1)
      f <- 2 * sin(pi * x0)
      f <- f + exp(2 * x1) - 3.75887
      f <- f+0.2*x2^11*(10*(1-x2))^6+10*(10*x2)^3*(1-x2)^10-1.396
      e <- rnorm(n, 0, sig)
      y <- f + e
      b <- gamm(y~s(x0)+s(x1)+s(x2)+s(x3))
   vis.gam(b$gam)
- There are 2 parts to a gamm fitted model object, an `lme' fitted model 
object, and a `gam' fitted model object. They refer to the same model, of 
course, but simply refer to it in different ways. You can do prediction with 
either part, but it's easiest with the `gam' part, e.g. following the 
previous example...

predict(b$gam)
- This will run out of memory if you are using the default "tp" basis for any 
terms --- if that is the case then either change basis to "cr" or use the 
`knots' argument as detailed at the end of the ?gam examples.

- I would need to know more about the model structure to make any further 
suggestions here.... 

best,
Simon