[R-sig-ME] contrasts in glmer
Ben Bolker
bbolker at gmail.com
Mon Dec 19 01:01:39 CET 2011
On 11-12-19 08:49 AM, Magalì Matteodo wrote:
> Dear Mr Bolker,
> 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.
This question would be more appropriate for
r-sig-mixed-models at r-project.org, or r-sig-ecology at r-project.org, or
even r-help at r-project.org . Your question is not glmer-specific; I
found the answer by following the clues in the documentation, which lead
to ?lm and
thence to ?model.matrix.default:
contrasts.arg: A list, whose entries are values (numeric matrices or
character strings naming functions) to be used as replacement
values for the ‘contrasts’ replacement function and whose
names are the names of columns of ‘data’ containing
‘factor’s.
Thus, you would need
contrasts=list(Pollen_vector=contr.sum))
Alternatively, see ?options and search for "contrast"
> ,
>
> 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? 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
>
More information about the R-sig-mixed-models
mailing list