[R] Random effect in GAM (mgcv)

David Winsemius dwinsemius at comcast.net
Sun Mar 4 18:27:47 CET 2018


> On Mar 4, 2018, at 7:37 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
> 
> Statistics questions are largely off  topic on this list, although they do
> sometimes intersect R programming issues, which are on topic. However, I
> believe a statistics list like stats.stackexchange.com might be more
> suitable for your query.
> 
> Cheers,
> Bert

What Bert says is certainly true of rhelp, but is not the case for the R mixed models mailing list. I think you should repost your question there. You should first read their mailing list info and configure you mail client to send plain text. Your current posting is marred by the presence of extraneous symbols that are the plain-text translation of HTML formatting. Those doubles asterisks are surely not in your formula. Furthermore, I for one do not see how one could determine "correctness" of an answer without access to the data.

Best of luck;
David.
> 
> 
> 
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> On Sun, Mar 4, 2018 at 4:10 AM, Vaniscotte Amélie <vanamelie at gmail.com>
> wrote:
> 
>> 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
>> as well.
>> 
>> 
>> 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) *
>> 
>> *, family=betar(link="logit"),method="REML",data=data,select=FALSE)*
>> 
>> 
>> 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
>> questions ?*
>> 
>> 
>> *- 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,
>> 
>> 
>> 
>> Amélie
>> 
>> 
>>        [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law



More information about the R-help mailing list