[R] glm with nesting

Doran, Harold HDoran at air.org
Thu Oct 5 15:28:50 CEST 2006


It's not really possible to help without knowing what errors you received and maybe some reproducible code. I think I remember this, though. From what I recall, there was no distinction between box and chick, so you cannot estimate both variance components. 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> Jeffrey Stratford
> Sent: Thursday, October 05, 2006 9:27 AM
> To: p.dalgaard at biostat.ku.dk
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] glm with nesting
> 
> Peter and list,
> 
> Thanks for the response.  A did add box as a factor (box <- 
> factor(box)).  Julian should be linear - bluebird chicks are 
> bluer as the season progresses from March to August.  
> 
> I did try the following
> 
> rtot.lme <- lmer(rtot ~ sex +(purban|box:chick) + 
> (purban|box), data=bb,
> na.action=na.omit) # from H. Doran
> 
> and
> 
> rtot.lme2 <- lme(fixed=rtot ~ sex + purban + sexv:purban, 
> data = bb, random = ~1 |box) # from K. Jones <kingsfordjones at gmail.com
> 
> but these did not work (months ago and I don't remember 
> exactly why) and I have since seperated males and females and 
> added day of the year (julian).  But "|" does indicate 
> grouping not nested, correct?
> 
> Could someone suggest some coding that might work?
> 
> Thanks again,
> 
> Jeff
> 
> 
> >>> Peter Dalgaard <p.dalgaard at biostat.ku.dk> 10/05/06 7:14 AM >>>
> "Jeffrey Stratford" <stratja at auburn.edu> writes:
> 
> > I just had a manuscript returned with the biggest problem being the 
> > analysis.  Instead of using principal components in a 
> regression I've 
> > been asked to analyze a few variables separately. So that's 
> what I'm 
> > doing.
>  
> > I pulled a feather from young birds and we quantified 
> certain aspects 
> > of the color of those feathers.
> 
> > Since I often have more than one sample from a nest, I thought I 
> > should use a nested design.
> 
> Notwithstanding comments below, that quote could be aiming 
> for the fortunes package... 
> 
>  
> > Here's the code I've been using and I'd appreciate if someone could 
> > look it over and see if it was correct.
> > 
> > bb.glm1 <- glm(rtot ~ box/(julian +purbank), data=bbmale, 
> > family="gaussian", na.action=na.omit)
> > 
> > where rtot = total reflectance, box = nest box (i.e., birdhouse), 
> > julian = day of the year and purbank = the proportion of 
> urban cover 
> > in a 1 km buffer around the nest box.  I'm not interested 
> in the box effect
> > and I've seperated males and female chicks.   
> > 
> >  I've asked about nestedness before and I was given code 
> that included 
> > "|" to indicate nestedness but this indicates a grouping 
> does it not?  
> > I suspect that there is something wrong.  In the summary I get
> > 
> > Coefficients:
> >               Estimate Std. Error t value Pr(>|t|)    
> > (Intercept)  2.880e-01  3.224e-03  89.322   <2e-16 ***
> > box         -3.219e-05  6.792e-05  -0.474    0.636    
> > box:julian   7.093e-08  3.971e-07   0.179    0.859    
> > box:purbank -1.735e-05  1.502e-04  -0.115    0.908   
> 
> Several things look wrong here. 
> 
> Most importantly, you appear to have single-degree of freedom 
> effects (t tests) of things that appear not to be linear 
> effects: Certainly, you have more than two nest boxes, but 
> also day of year as a linear term looks suspicious to me. 
> Unless there is something I have missed completely, "box" 
> should be a factor variable, and you might also need 
> trigonometric terms for the julian effect (depending on what 
> sort of time spans we are talking about.)
> 
> Secondly, notation like box/julian suggests that julian only 
> makes sense within a nest box i.e. 1st of March in one box is 
> completely different from 1st of March in another box (the 
> notation is more commonly used to describe bird number within 
> nests and the like). And with purbank presumably constant for 
> measurements from the same box, the box:purbank term looks 
> strange indeed.
> 
> If you want to take account of a between-box variation in the 
> effect of covariates, you probably need to add them as 
> variance components, but this requires non-glm software, 
> either lme() or lmer(). However, instructing you on those is 
> outside the scope of this mailing list, and you may need to 
> find a local consultant.
> 
> > The other question I have is how do I test a null hypothesis - no 
> > explanatory variables?  [rtot ~ NULL?]
> > 
> > Many thanks,
> > 
> > Jeff
> > 
> > 
> > 
> > ****************************************
> > Jeffrey A. Stratford, Ph.D.
> > Postdoctoral Associate
> > 331 Funchess Hall
> > Department of Biological Sciences
> > Auburn University
> > Auburn, AL 36849
> > 334-329-9198
> > FAX 334-844-9234
> > http://www.auburn.edu/~stratja
> > 
> 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.
> > 
> 
> -- 
>    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark          Ph:  
> (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: 
> (+45) 35327907
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list