2
$\begingroup$

I'm not sure this question is better suited for Cross Validated or Stack Overflow, please don't hesitate to tell me if I ask it on the wrong forum. I'd appreciate some help interpreting what shows the result of plot.gam on a GAM object with random effects, obtained with gamm4. I'll try to give a reproductible example.

I'll take an invented example : we have several species of rabbits in several forests (ecologist spotted). We'd juste like to visualize what is the evolution of rabbit size in time, averaged on all forests and on all species. In other words, we'd like to see if there is a global pattern in the evolution of size, independently of location or species.

Let's generate a dataset :

size=rnorm(324)
year=rep(rep(c(1991:2008),6),3)
forest=rep((rep(letters[1:6],18)),3)
species=c(rep(LETTERS[24],18),rep(LETTERS[25],18),rep(LETTERS[26],18))
data=data.frame(forest,species,year,size)
data$forest=data$forest[order(data$forest)]

We get a data set with sizes for 3 species (X,Y,Z), between 1991 and 2008, in six forests (A,B,C,D,E,F).

library(gamm4)
mod=gamm4(size~s(year),random=~(1|forest)+(1|species),data=data)
plot.gam(mod$gam)

We get this graph from plot.gam :

Result from plot.gam

Intuitively, I'd like to say that this plot plot represents the "average" evolution of rabbit size in time, when we remove forest and species effect. Though, I'm totally new to GAM and GAMM. So my question is : is it really what this is about ? Or am I wrong to use this approach ? I was wondering so because here, my goal is more to visualize the data than to make inferences, so I'm not sure if this is a good idea to use this method.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.