[R-sig-ME] compare GAMs with simple random effects

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Oct 11 13:29:48 CEST 2011


On Mon, 2011-10-10 at 23:53 +0200, Valerio Bartolino wrote:
> Dear list,
> I have a simple random effect that I would like to include in a GAM.
> I've seen that a simple random effect can be treated as a smooth in the
> library "mgcv" as follow s(x,bs="re").
> My questions are:

I'll have a go as I haven't seen a response yet...

> - In this way can I compare models with and without a random effect?

Yes, you should be able to compare the two models one with the re smooth
and one without. However, you'll have to be be very careful to ensure
you are really comparing like-with-like. gam() will be performing
smoothness selection for all terms in the model. There is no guarantee
that it will find the same smoothness to be optimal for the others terms
when the re smooth is and is not included in the model. If you just fit
the two models, you may well end up comparing the two models in terms of
the random effect term *and* different fixed effects, all at the same
time.

I guess you could fit the model with the re term, take the smoothness
complexity from each "fixed effect" term and tell gam() to use that and
not do smoothness selection (fx = TRUE IIRC), and fit the model without
the re smoother. That way the only difference between the two models is
the re smoother. You can use anova() on the two models, but do heed the
usual warnings about the interpretation of the p-value; you are testing
if the variance parameter for the random effect is equal to zero and as
you can't have negative variances, the test is on the boundary of the
allowed values and hence the p-value will be biased low.

You should also make sure you are fitting via method = "REML".

> - Can I decide to drop a random effect if it is not significant in the model
> summary?

Yes, but you might wish to include it anyway, especially if it
represents something inherent to the experiment or population you are
studying. Just because it might not be needed in your sample of data
doesn't mean the effect in the population is not there.

> - How can I interpret the EDF of the random effect in the model summary?

I don't know how you can, however you could use gam.vcomp() on your
model to compute the SD of the variance components for each smooth term
in the model and their confidence intervals. This should allow you to
get a handle on the random effects terms that is more familiar to lme()
and lmer() like outputs.

But do read ?gam.vcomp and ?smooth.construct.re.smooth.spec for some of
the details.

HTH

G

> Thank you in advance for any help or suggestions.
> 
> Valerio Bartolino
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-sig-mixed-models mailing list