On Monday 04 December 2006 15:04, Wadud, Zia wrote:> Hi
> I am an engineer and am running the package mgcv and specifically the
> command gamm (generalized additive mixed modelling), with random
> effects. i have a few queries:
> 1. When I run the command with 1000/2000 observations, it runs ok.
> However, I would like to see the results as in vis.gam command in the
> same package, with the 3-d visuals. It appears no such option is
> available for gamm in the manual. I was wondering if someone has used
> this before and obtained the plots similar to vis.gam, which I believe
> plots the predictions automatically. I have used 'te' command for
two
> way interaction of the smooth terms, plus some paramteric terms.
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)
> 2. I am not sure how the gamm results are saved, and if prediction is at
> all possible. The documentations talks about gam in detail, but not
> gamm.
- 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)
> 3. When I use my entire dataset (approx 58000 obs, and, well even with
> 10000 observations) I am running against memory all the time (it says
> cannot allocate a vector of size 'some number). I used it on a 3GB RAM
> machine and I am suspicious if it is something else.
- 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
> Many thanks in advance,
> Zia
>
>
> **********************************************************
> Zia Wadud
> PhD Student
> Centre for Transport Studies
> Department of Civil and Environmental Engineering
> Imperial College London
> London SW7 2AZ
> Tel +44 (0) 207 594 6055
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.
-- > Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603 www.maths.bath.ac.uk/~sw283