[R] likelihood ratio test between glmer and glm
Davnah Urbach
Davnah.Urbach at dartmouth.edu
Mon Mar 15 03:43:01 CET 2010
>
Thanks for this answer but does that mean that working with the deviances is better? Or how else could I evaluate the importance of my random terms?
Many thanks,
Davnah
> On Mar 14, 2010, at 8:12 PM, hadley wickham wrote:
>
>>> Based on a discussion found on the R mailing list but dating back to 2008, I have compared the log-likelihoods of the glm model and of the glmer model as follows:
>>>
>>> lrt <- function (obj1, obj2){
>>> L0 <- logLik(obj1)
>>> L1 <- logLik(obj2)
>>> L01 <- as.vector(- 2 * (L0 - L1))
>>> df <- attr(L1, "df") - attr(L0, "df")
>>> list(L01 = L01, df = df, "p-value" = pchisq(L01, df, lower.tail = FALSE)) }
>>>
>>> gm0 <- glm(cbind(female,male)~date,family = binomial, data = liz3)
>>> gm1 <- glmer(cbind(female,male)~date+(1|dam),family=binomial,data= liz3)
>>>
>>> lrt(gm0, gm1)
>>
>> It is _very_ dangerous to do this as the likelihoods are unlikely to
>> be comparable/compatible.
>>
>> Hadley
>>
>>
>> --
>> Assistant Professor / Dobelman Family Junior Chair
>> Department of Statistics / Rice University
>> http://had.co.nz/
>
> Davnah Urbach
> Post-doctoral researcher
> Dartmouth College
> Department of Biological Sciences
> 401 Gilman Hall
> Hanover, NH 03755 (USA)
> lab/office: (603) 646-9916
> Davnah.Urbach at dartmouth.edu
>
Davnah Urbach
Post-doctoral researcher
Dartmouth College
Department of Biological Sciences
401 Gilman Hall
Hanover, NH 03755 (USA)
lab/office: (603) 646-9916
Davnah.Urbach at dartmouth.edu
Davnah Urbach
Post-doctoral researcher
Dartmouth College
Department of Biological Sciences
401 Gilman Hall
Hanover, NH 03755 (USA)
lab/office: (603) 646-9916
Davnah.Urbach at dartmouth.edu
More information about the R-help
mailing list