[R] Random effect in GAM (mgcv)
vanamelie at gmail.com
Sun Mar 4 13:10:28 CET 2018
Dear R users,
I am using the *mgcv package* to model the ratio of hectares of damaged
culture by wild boar in french departments according to some
environmental covariates. I used a _Beta distribution_ for the response.
For each department, we estimated the damaged in 3 different culture
types (« Culture »). Our statistical individual are therefore the
department crossed by the culture type.
Also, the department are clustered into landscape types (« Cluster »).
Since I want to get the effect of the Culture type and the Landscape, I
keep those variables as fixed effects in the model.
Also, since we have 5 repetitions of the response and of some covariates
measurement in time per department and culture type, I put a random
effect on the Department per Culture type and the Year as fixed effect
The model takes the form :
*gam_tot <- gam (resp ~ Culture + Clust**er**:Culture + s(**Year**,k=4,
by=Culture) + s(**X1**, by=Culture) + s(**X2**, by=Culture) + s(Depts,
bs="re", by=Culture) *
Then, I estimated the part of the model explained deviance provided by
each covariate. For that, I run the model without the given covariate
(keeping smooth parameters constant between models), and compute the
difference in deviance between the Full model (with the given covariate)
and the penalized model (without the given covariate):
(Full model Deviance – Penalized model Deviance) / Full Model Deviance
From that, I get a _huge proportion of Deviance explained by the random
effect_ (Department) of about 30 %, while the others covariates
explained less than 1 %.
*At this point, I have few questions :*
*- Do you think my model formula is correct regarding my data and
*- Is my estimate of explained deviance correct ?*
*In that case, how can I explain such a huge discrepancy between **the
part of deviance explained by **random and fixed effects ? *
Thanks for your help,
[[alternative HTML version deleted]]
More information about the R-help