[R-sig-ME] contrast in glmer

Kay Cecil Cichini Kay.Cichini at uibk.ac.at
Wed Dec 21 10:17:33 CET 2011


Hi Magali,
Dear Mr. Bates,

with my work I had a similar problem. However, I utilized multiple  
comparisons (package multcomp) to get around this.

Magali, if you want to consider this approach, this stand-alone  
example may help:
http://thebiobucket.blogspot.com/2011/06/glmm-with-custom-multiple-comparisons.html

On my own behalf I'd be happy about expert comments on the above  
mentioned method.

Cheers,
Kay


Zitat von Douglas Bates <bates at stat.wisc.edu>:

> At the end of your query you mention that you didn't know of a place
> to send such queries other than to the package authors.  The best
> place to send such queries is the to R-SIG-Mixed-Models at R-project.org
> mailing list, which I am cc:ing on this reply.
>
> On Mon, Dec 19, 2011 at 10:14 AM, Magalì Matteodo
> <magali.matteodo at gmail.com> wrote:
>> Dear Mr Bates,
>> I'm a master student in the Lausanne University and I'm doing the data
>> analysis for my master thesis. I'm using the function glmer from package
>> lme4 in R. It's from some days that I'm trying to understand the contrast
>> option in the function but I don't come to a conclusion.
>>
>>
>> I'm working on a list of alpine plants found in different summits at
>> different altitudes; I would like to understand if the plant summit
>> colonization ability can be explained by the trait "Pollen_vector" and if
>> there is an interaction between the altitude and the biological trait.
>> The response variable is Colonization_event and it's a binary variable.
>>
>>> names(my.data)
>> [1] "Species_name"       "Colonization_event" "Summit_name"
>> "Summit_altitude"    "Pollen_vector"
>>
>>> attach(my.data)
>>
>>> levels(Pollen_vector)
>> [1] "F"  "in" "j"  "se" "wi"
>>
>>> library(lme4)
>>
>>> require(vegan)
>>> Summit_altitude_z= decostand(Summit_altitude, "standardize")
>>
>>> model_Int0<-glmer(Colonization_event~(Summit_altitude_z*Pollen_vector)
>> +(1|Summit_name)+(1|Species_name),data=my.data,family=binomial(link=logit),na.action=na.exclude)
>>> summary(model_Int0)
>>
>> Which is the contrast method used by default in glmer? Is that the treatment
>> contrast?
>
> Like most model-fitting methods in R that rely on a linear predictor,
> glmer outsources construction of the model matrix to the function
> model.matrix so the question really comes down to how model.matrix
> behaves.  It uses the default contrasts specified in the "contrasts"
> option.  The factory-fresh setting is
>
>> getOption("contrasts")
>         unordered           ordered
> "contr.treatment"      "contr.poly"
>
> If you want to change this for all factors you can reset that option.
> If you want to change it for only one factor then you can set the
> contrasts attribute on that particular factor (see ?contrasts for more
> explanation) or specify the name of the contrasts-generating function
> in a named lists given as the contrasts argument passed to glmer (see
> ?model.matrix for more details).  It might also help to run
>
> example(contrasts)
>
> and
>
> example(model.matrix)
>
>> I would like to use the Sum contrast, how I can specify it to R?
>> I tried to construct the model in this way:
>>
>>> model_Int0_s<-glmer(Colonization_event~(Summit_altitude_z*Pollen_vector)
>> +(1|Summit_name)+(1|Species_name),data=my.data,family=binomial(link=logit),na.action=na.exclude,contrast=contr.sum)
>> summary(model_Int0_s)
>>
>> and in this one:
>>> options(contrast=contr.sum)
>>> model_Int0<-glmer(Colonization_event~(Summit_altitude_z*Pollen_vector)
>> +(1|Summit_name)+(1|Species_name),data=my.data,family=binomial(link=logit),na.action=na.exclude,contrast=T)
>> summary(model_Int0)
>>
>> and the same repeated with contrast=contr.treatment and
>> contrast=contr.helmert, but the estimate values in the summary are always
>> the same. Why? How to fit the model with a particular contrast?
>>
>> I perfectly understand that is not the common practice to ask such things
>> right to the author but I didn't know what to do differently. I hope that
>> you can help me to come out of this stinker.
>>
>> Thanks,
>>
>> best regards,
>>
>> Magalì Matteodo
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>




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