[R] Hierarchical glm with binomial family
Douglas Bates
bates at stat.wisc.edu
Wed May 27 18:17:35 CEST 2009
On Wed, May 27, 2009 at 9:17 AM, Ben Bolker <bolker at ufl.edu> wrote:
>
>
>
> Johan Stenberg-2 wrote:
>>
>> Dear members of the R help list,
>>
>> I want to do a hierarchical glm with binomial family but am unsure
>> about how to write the syntax which involves nesting.
>>
>> I want to test whether the risk of being attacked by Herbivores for
>> Meadowsweet plants is significantly dependent on the Distance to
>> heterospecific source plants.
>>
>> Dependent variable = Herbivory (yes/no)
>> Explanatory continuous variable = Distance to heterospecific source plant
>>
>> Distance should be nested within Subpopulation which in turn should be
>> nested within Population.
>> The number of replicates per subpopulation varies between 8 and 36.
>> The number of subpopulations per population varies between 4 and 9.
>>
>> I haven't figured out how to do nesting, but guessing that nesting is
>> denoted with brackets I guess the syntax should look something like
>> this (below). Could you please help me to correct this syntax so that
>> it becomes useful in R?
>>
>> model<-glm(Herbivory~Distance(Subpopulation(Population)), family=binomial)
>>
>>
>
> You probably need a GLMM (generalized linear mixed model), which is
> a little bit of a can of worms. If so, you will need the "glmer" function
> inside the "lmer" package.
I think you mean the lme4 package.
> I'm not entirely clear about your experimental design: I understand
> that subpopulations are nested within populations, but it's not clear
> whether covariates (distances to heterospecific plants) differ within
> subpopulations or populations.
>
> If they don't differ with subpopulations, I would (strongly) recommend
> aggregating the
> values within subpopulations and analyzing proportions as a regression
> analysis:
> see Murtaugh, Paul A. “SIMPLICITY AND COMPLEXITY IN ECOLOGICAL
> DATA ANALYSIS.” Ecology 88, no. 1 (2007): 56-62.
>
> If they do, then your design is
>
> model<-glmer(Herbivory~Distance+(1|Population/Subpopulation),
> family=binomial)
>
> See also:
>
> https://stat.ethz.ch/pipermail/r-sig-mixed-models/2009q2/002320.html
> https://stat.ethz.ch/pipermail/r-sig-mixed-models/2009q2/002335.html
> --
> View this message in context: http://www.nabble.com/Hierarchical-glm-with-binomial-family-tp23742335p23743418.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.
>
More information about the R-help
mailing list