[R-sig-ME] [R] [lme4]Coef output with binomial lmer

Mark Difford mark_difford at yahoo.co.uk
Tue Aug 12 22:23:45 CEST 2008


Hi Harold,
I wasn't suggesting to the poster (or to you) that the model should be specified, in either lme or lmer, using the % construct. What I was doing was correcting an obvious (but not, I think, to the poster of the question) oversight in your posting, which gave the translation of his syntax (1|ass%in%pop%in%fam) as 1|ass/pop/fam. This is incorrect; correct is 1|fam/pop/ass.
BTW: specifying a nested model as ass %in% pop %in% fam is in fact correct formula syntax for a nested model in R (though I am not suggesting, and never have, that it be used to specify random effects structures in lme() [or in lmer(), where the symbolism is different]). If you doubt this, then set your mind at rest by please reading the relevant parts of Chapter 12 of An Introduction to R.
Regards, Mark.
 Mark Difford
Ph.D. candidate, Botany Department,
Nelson Mandela Metropolitan University,
Port Elizabeth, SA.



----- Original Message ----
From: "Doran, Harold" <HDoran at air.org>
To: Mark Difford <mark_difford at yahoo.co.uk>; r-help at r-project.org
Cc: r-sig-mixed-models at r-project.org
Sent: Sunday, 10 August, 2008 5:19:14 PM
Subject: RE: [R] [lme4]Coef output with binomial lmer

I don't think the %in% works at all. It's non-standard and I think an
incorrect model specification. Here is an example where we can see that
the transpose of the model matrix for the random effects is different
when we compare what would be the same model if it "worked". 

I don't think there is an extractor function so I pull out the slot
directly. There is some "danger" in this because extractor functions
should be used rather than directly accessing the slots, but I think it
works OK.

library(lme4)
data(egsingle, package='mlmRev')

fm1 <- lmer(math ~ 1 + (1|schoolid/childid), egsingle, control =
list(grad = 0, nit = 0, msV = 1))
fm2 <- lmer(math ~ 1 + (1|childid%in%schoolid), egsingle, control =
list(grad = 0, nit = 0, msV = 1))

z1 <- fm1 at Zt
z2 <- fm2 at Zt
identical(z1,z2)
[1] FALSE

fm1 is the correct specification as it properly denotes that children
are nested in schools. When we compare the model matrices, we can see
that they are not identical; hence the model specification is not the
same. I have no clue what %in% does and am not sure it even works with
lmer, but could be wrong. 

Note in this case

fm3 <- lmer(math ~ 1 + (1|schoolid) + (1|childid), egsingle, control =
list(grad = 0, nit = 0, msV = 1))
z3 <- fm3 at Zt
identical(z1,z3)
[1] TRUE

Is exactly the same as fm1 because the IDs are always nested.

Harold

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Mark Difford
> Sent: Saturday, August 09, 2008 8:32 AM
> To: r-help at r-project.org
> Subject: Re: [R] [lme4]Coef output with binomial lmer
> 
> 
> Hi Tom,
> 
> >> 1|ass%in%pop%in%fam
> 
> This is "non-standard," but as you have found, it works. The 
> correct translation is in fact
> 
> 1|fam/pop/ass
> 
> and not 1|ass/pop/fam as suggested by Harold Doran. Dropping 
> %, ass%in%pop%in%fam reads [means] as: nest ass in pop [= 
> pop/ass], and then nest this in fam == fam/pop/ass
> 
> HTH, Mark.
> 
> 
> T.C. Cameron wrote:
> > 
> > Dear R users
>> > I have built the following model
>> > m1<-lmer(y~harn+foodn+(1|ass%in%pop%in%fam),family = 
> "quasibinomial")
>> > where y<-cbind(alive,dead)
>> > where harn and foodn are categorical factors and the random 
> effect is 
> > a nested term to represent experimental structure e.g.  
> > Day/Block/Replicate ass= 5 level factor, pop= 2 populations per 
> > treatment factor in each assay, 7 reps per population
>> > The model can be family = quasibinomial or binomial
>> > My complete lack of understanding is in retrieving the coefficients 
> > for the fixed effects to back-transform the effects of my 
> factors on 
> > proportional survival
>> > I get the following output:
> >> coef(m1)
> > $`ass %in% pop %in% fam`
> >      (Intercept)      harn1    harn2  foodn2
> > FALSE  1.0322375 -0.1939521 0.0310434 0.810084
> > TRUE    0.5997679 -0.1939521 0.0310434 0.810084
>> > Where FALSE and TRUE refer to some attribute of the random effect
>> > My hunch is that it refers to the Coefficients with (=TRUE) and 
> > without
> > (=FALSE) the random effects?
>> > Any help appreciated
>> > 
> > 
> ..............................................................
> ..........
> > ............
> > Dr Tom C Cameron
> > Genetics, Ecology and Evolution
> > IICB, University of Leeds
> > Leeds, UK
> > Office: +44 (0)113 343 2837
> > Lab:    +44 (0)113 343 2854
> > Fax:    +44 (0)113 343 2835
> > 
> > 
> > Email: t.c.cameron at leeds.ac.uk
> > Webpage: click here
> > <http://www.fbs.leeds.ac.uk/staff/profile.php?tag=Cameron_TC>
> > 
>> > 
> >     [[alternative HTML version deleted]]
> > 
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> > 
> > 
> 
> --
> View this message in context: 
> http://www.nabble.com/-lme4-Coef-output-with-binomial-lmer-tp1
> 8894407p18904468.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


Send instant messages to your online friends http://uk.messenger.yahoo.com




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