[R] glm with nesting

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Oct 5 14:14:21 CEST 2006


"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
> 
> ______________________________________________
> 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.
> 

-- 
   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



More information about the R-help mailing list