[R-sig-ME] ANOVA type lll ss table for GLMER?

Henrik Singmann henrik.singmann at psychologie.uni-freiburg.de
Thu May 15 12:49:24 CEST 2014



Am 14.05.2014 21:47, schrieb Ben Bolker:
> On 14-05-14 10:02 AM, Henrik Singmann wrote:
>> Dear Heather,
>>
>> you could try to use mixed from the afex package which will give you
>> Type III p-values for the effects via Chi^2 tests (or alternatively via
>> parametric bootstrap):
>>
>> require(afex)
>> (spden2 <- mixed(SpDens~(treat*samp)-1+(1|TRANSECT),family=poisson,
>> data=rm, nAGQ = 9, method = "LRT")
>>
>> Note however, that loading afex changes your overall contrasts, to reset
>> the default contrasts use:
>> options(contrasts=c('contr.treatment', 'contr.poly'))
>
>     But (despite the fact that I **really** don't like afex's default
> behaviour of changing the overall contrasts) -- you should definitely
> use contr.sum when computing a marginal ANOVA table (i.e. do NOT reset
> the contrasts until after you're done constructing your table), if you
> insist on doing that.


First, all afex functions (including mixed) are unaffected by global contrasts as long as the argument check.contrasts = TRUE (which is the default). In other words, mixed per default uses contr.sum independently of the global contrasts (more specifically, it sets it for all factors if not already contr.sum or if the global contrasts are not contr.sum).

Second, I give in. From the current development version on (version 0.10-110) afex *does not* change the global contrasts anymore. This should not affect any of the functions within afex (my tests confirm that). To make setting contrasts globally easy, I added the following convenience functions: set_sum_contrasts(), set_default_contrasts(), set_treatment_contrasts(), ...

Are you happy now, Ben? :)

You can install the the development version of afex from R-forge (may take a few hours):  install.packages("afex", repos="http://R-Forge.R-project.org")


>
>>
>> Furthermore, (g)lmer doesn't break the factors done by *all* levels. It
>> removes the first levels (usually). Hence the parameters cannot directly
>> be interpreted if this level is "significant".
>>
>> Hope this helps,
>> Henrik
>>
>> Am 14.05.2014 15:45, schrieb Heather Moylett:
>>>    Hello group,
>>>
>>> This is my first time posting, so I hope I have explained my needs
>>> clearly
>>> below.
>>>
>>> I am running a repeated measure analysis with a raw species count data
>>> set
>>> (SpDens). I have run different model types (zeroinfl, glm, glmer) and
>>> have
>>> identified glmer to have the best fit. The output generated by GLMER
>>> breaks
>>> my between groups (treat) and within groups (samp) factors down by
>>> levels.
>>> In addition to this, I would like to look at the effect of treat and samp
>>> overall, something similar to an ANOVA table (Type lll SS). When I use
>>> Anova(object) I receive an ANOVA table with an F val and no P-vals. I
>>> would
>>> prefer to stick with the z-stat and p-vals. I have seen this reported in
>>> other papers, so I know it can be done...just can't figure out how to
>>> do it!
>>>
>>> Components of the model:
>>> samp: 23 sampling dates is the repeated measure (within groups)
>>> treat: 4 levels (between groups)
>>> TRANSECT: experimental unit (subject), 4/treat and data collected from
>>> all
>>> 16 every sampling date
>>>
>>> When I run this code:
>>>
>>> RM <- read.csv("C:/Users/heatbell/Desktop/Walthour-Moss/STATS/CH
>>> 1/Final/R/RM.csv")
>>>
>>> View(RM)
>>>
>>> rm <- subset(RM, SAMPLE >= 2)
>>>
>>>
>>>
>>> rm<- within(rm, {
>>>
>>>     samp<-factor(SAMPLE)
>>>
>>>     yr<-factor(YEAR)
>>>
>>>     treat<-factor(TREAT)
>>>
>>> })
>>>
>>> summary(rm)
>>>
>>>
>>> summary(spden<-glmer(SpDens~(treat*samp)-1+(1|TRANSECT),family=poisson,
>>> data=rm, nAGQ = 9))
>>>
>>> Thank you for the help!
>>> Heather
>>>
>>
>

-- 
Dr. Henrik Singmann
Albert-Ludwigs-Universität Freiburg, Germany
http://www.psychologie.uni-freiburg.de/Members/singmann



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