[R-lang] Re: comparisons in lmer

Andy Fugard andyfugard@gmail.com
Tue Jan 18 00:08:13 PST 2011


On Mon, Jan 17, 2011 at 5:46 PM, Marina Sherkina-Lieber <
marina.cherkina@utoronto.ca> wrote:

> Thank you, Andy!
> What is the difference between lmer and glmer?
>

>From ?glmer

"The lmer and glmer functions are nearly interchangeable. If lmer is called
with a non-default family argument the call is replaced by a call to
glmerwith the current arguments. If
glmer is called with the default family, namely the
gaussian<http://127.0.0.1:21832/library/stats/html/family.html>family
with the identity link, then the call is replaced by a call to
lmer with the current arguments. (They are described as “nearly”
interchangeable because the REML argument only applies to calls to lmer and
the nAGQ argument only applies to calls to glmer.)"


> And it would help if you decipher parts of the command for the Tukey test.
>

There's a bunch of examples in ?glht which might be of assistance.  Copied
here (using aov but same syntax):

### multiple comparison procedures

  ### set up a one-way ANOVA
  amod <- aov(breaks ~ tension, data = warpbreaks)

  ### set up all-pair comparisons for factor `tension'
  ### using a symbolic description (`type' argument
  ### to `contrMat()')
  glht(amod, linfct = mcp(tension = "Tukey"))

  ### alternatively, describe differences symbolically
  glht(amod, linfct = mcp(tension = c("M - L = 0",
                                      "H - L = 0",
                                      "H - M = 0")))

  ### alternatively, define contrast matrix directly
  contr <- rbind("M - L" = c(-1, 1, 0),
                 "H - L" = c(-1, 0, 1),
                 "H - M" = c(0, -1, 1))
  glht(amod, linfct = mcp(tension = contr))


The same degrees of freedom problem for the t-tests which comes up in
Gaussian lmer models also applies (multiply...) when doing pairwise
comparisons...

Now, does anyone know how to do this with 95% HPD intervals... expanding
them as necessary...?

Andy




> Marina
>
>
> Quoting Andy Fugard <andyfugard@gmail.com>:
>
>  On Wed, Jan 12, 2011 at 6:06 PM, Maureen Gillespie <
>> gillespie.maureen@gmail.com> wrote:
>>
>>  What if you DO want to do a bunch of paired tests and your coding scheme
>>> isn't going to get at them all in one go? What is the best way of doing
>>> this? Run multiple models on subsets of the data, then adjust/correct for
>>> multiple comparisons?
>>>
>>
>>
>>
>> You could use Tukey's all-pairwise comparisons via glht in the multcomp
>> package.  For instance:
>>
>>
>>> require(languageR)
>>> require(multcomp)
>>>
>>>
>>> M1 = glmer(CaseMarking ~ WordOrder * AgeGroup +
>>>
>> +   AnimacyOfSubject + Text + (1|Speaker),
>> +   family = "binomial", data = warlpiri)
>>
>>> M1
>>>
>> Generalized linear mixed model fit by the Laplace approximation
>> Formula: CaseMarking ~ WordOrder * AgeGroup + AnimacyOfSubject + Text +
>> (1 | Speaker)
>>   Data: warlpiri
>>   AIC BIC logLik deviance
>>  296.2 327 -140.1    280.2
>> Random effects:
>>  Groups  Name        Variance Std.Dev.
>>  Speaker (Intercept) 0.46023  0.6784
>> Number of obs: 347, groups: Speaker, 27
>>
>> Fixed effects:
>>                                     Estimate Std. Error z value Pr(>|z|)
>>
>> (Intercept)                           -2.7731     0.4659  -5.952 2.65e-09
>> ***
>> WordOrdersubNotInitial                 0.2731     0.5025   0.543   0.5868
>>
>> AgeGroupchild                          1.2059     0.4726   2.552   0.0107
>> *
>>
>> AnimacyOfSubjectinanimate              0.6406     0.3822   1.676   0.0938
>> .
>>
>> Texttextb                              0.2887     0.4833   0.597   0.5503
>>
>> Texttextc                              0.7376     0.4237   1.741   0.0817
>> .
>>
>> WordOrdersubNotInitial:AgeGroupchild  -1.8233     0.7382  -2.470   0.0135
>> *
>>
>> ---
>> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>>
>> Correlation of Fixed Effects:
>>            (Intr) WrdONI AgGrpc AnmcOS Txttxtb Txttxtc
>> WrdOrdrsbNI -0.341
>> AgeGropchld -0.594  0.371
>> AnmcyOfSbjc -0.031 -0.052  0.041
>> Texttextb   -0.478 -0.040 -0.039 -0.137
>> Texttextc   -0.568 -0.033 -0.009 -0.311  0.606
>> WrdOrdNI:AG  0.249 -0.674 -0.434 -0.069  0.053   0.026
>>
>>>
>>> summary(glht(M1, linfct=mcp(Text="Tukey")))
>>>
>>
>>         Simultaneous Tests for General Linear Hypotheses
>>
>> Multiple Comparisons of Means: Tukey Contrasts
>>
>>
>> Fit: glmer(formula = CaseMarking ~ WordOrder * AgeGroup + AnimacyOfSubject
>> +
>>
>>    Text + (1 | Speaker), data = warlpiri, family = "binomial")
>>
>> Linear Hypotheses:
>>                   Estimate Std. Error z value Pr(>|z|)
>> textb - texta == 0   0.2887     0.4833   0.597    0.821
>> textc - texta == 0   0.7376     0.4237   1.741    0.188
>> textc - textb == 0   0.4490     0.4063   1.105    0.509
>> (Adjusted p values reported -- single-step method)
>>
>> Cheers,
>>
>> Andy
>>
>> --
>> Dr Andy Fugard
>> http://www.andyfugard.info
>>
>>
>
>
> --
> Marina Sherkina-Lieber
> Ph.D. candidate
> Dept. of Linguistics
> University of Toronto
>
>


-- 
Dr Andy Fugard
http://www.andyfugard.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucsd.edu/pipermail/ling-r-lang-l/attachments/20110118/5089386b/attachment.html 


More information about the ling-r-lang-L mailing list