Re: [R] gamm

From: Simon Wood <sw283_at_maths.bath.ac.uk>
Date: Thu 20 Jul 2006 - 07:13:20 EST

Sorry for the delay replying: I was on holiday, but have foolishly come back.

> I am a bit confused about gamm in mgcv. Consulting Wood (2006) or
> Ruppert et al. (2003) hasn't taken away my confusion.
>
> In this code from the gamm help file:
>
> b2<-gamm(y~s(x0)+s(x1)+s(x2)+s(x3),family=poisson,random=list(fac=~1))
>
> Am I correct in assuming that we have a random intercept here....but
> that the amount of smoothing is also changing per level of the factor??
> Or is it only the intercept that is changing?
>
- the degree of smoothing is the same for each level of `fac' but there is a different intercept for each level of `fac': these intercepts are assumed Normally distributed. i.e. all `s()' terms apply to all data, they are not nested within groups.

> And where can I find some explanation on the magic output below?

mgcv::gamm is basically a wrapper that turns a GAMM into the sort of model that nlme::lme or MASS::glmmPQL expects to see.... `gamm' returns an object with two parts - the `lme' part is the object that was returned by glmmPQL or lme; the `gam' part is an object with most of the attributes of a `gam' object (all those that can be reconstructed from an lme/glmmPQL fitted model object).

So the `lme' object contains a bunch of opaque stuff that results from turning the original GAMM into something that lme/glmmPQL can work with... further detail below.

>
> summary(b2$lme)
> Random effects:

[Note that g.1 to g.4 below are dummy grouping factors, each having only one level - they force the smooths to apply to all the data, rather than being nested within, e.g. the levels of `fac'].

> Formula: ~Xr.1 - 1 | g.1
> Structure: pdIdnot
> Xr.11 Xr.12 Xr.13 Xr.14 Xr.15 Xr.16 Xr.17 Xr.18
> StdDev: 1.680679 1.680679 1.680679 1.680679 1.680679 1.680679 1.680679 1.680679
> Formula: ~Xr.2 - 1 | g.2 %in% g.1
> Structure: pdIdnot
> Xr.21 Xr.22 Xr.23 Xr.24 Xr.25 Xr.26 Xr.27 Xr.28
> StdDev: 1.57598 1.57598 1.57598 1.57598 1.57598 1.57598 1.57598 1.57598
> Formula: ~Xr.3 - 1 | g.3 %in% g.2 %in% g.1
> Structure: pdIdnot
> Xr.31 Xr.32 Xr.33 Xr.34 Xr.35 Xr.36 Xr.37 Xr.38
> StdDev: 20.06377 20.06377 20.06377 20.06377 20.06377 20.06377 20.06377 20.06377
> Formula: ~Xr.4 - 1 | g.4 %in% g.3 %in% g.2 %in% g.1
> Structure: pdIdnot
> Xr.41 Xr.42 Xr.43 Xr.44 Xr.45
> StdDev: 0.0001063304 0.0001063304 0.0001063304 0.0001063304 0.0001063304
> Xr.46 Xr.47 Xr.48
> StdDev: 0.0001063304 0.0001063304 0.0001063304

> Formula: ~1 | fac %in% g.4 %in% g.3 %in% g.2 %in% g.1
> (Intercept) Residual
> StdDev: 0.6621173 1.007227
> Variance function:
> Structure: fixed weights
> Formula: ~invwt

> Fixed effects: y.0 ~ X - 1
> Value Std.Error DF t-value p-value
> X(Intercept) 2.0870364 0.3337787 392 6.252755 0.0000
> Xs(x0)Fx1 -0.0000325 0.1028794 392 -0.000316 0.9997
> Xs(x1)Fx1 0.3831694 0.0957323 392 4.002509 0.0001
> Xs(x2)Fx1 1.4584330 0.3909237 392 3.730736 0.0002
> Xs(x3)Fx1 -0.0123951 0.0143162 392 -0.865809 0.3871
> Correlation:
>

Hope that's some use.

Simon

>- Simon Wood, Mathematical Sciences, University of Bath, Bath BA2 7AY
>- +44 (0)1225 386603 www.maths.bath.ac.uk/~sw283/



R-help@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. Received on Thu Jul 20 05:19:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 20 Jul 2006 - 06:16:27 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.