[R-sig-eco] R-sig-ecology Digest, Vol 22, Issue 3

Nicholas Lewin-Koh nikko at hailmail.net
Sun Jan 3 19:07:36 CET 2010


Hi,
To add to all the good advice you have gotten, I would second Scott's
advice about using a GAM. 
Two issues that come to mind are that the interpretation might be tricky
as population, I assume
geographical unit, is your "Experimental unit" and individual nests are
within the populations
so fluctuations in population size are going to be correlated with
nesting success. The second is that 
contrasts in GAM's are tricky. Here the model would be success ~ s(time,
by=population), so you have
a curve for each population, but your interest is in the difference of
nesting success. Simon 
in his mgcv package has a tricky way of doing those kinds of
comparisons, you need to get the lp
matrix from the predict function, and then simulate to get the
confidence intervals. There is an example in
in the documentation for predict. This may be a can of worms. If your
time series are not too wiggly
you may be able to get away with using Harrel's rms package, and use
restricted cubic splines in
a logistic regression model. The contrasts may be easier to get.

Hope this helps. Even simple models can get complicated.

Nicholas
  




> ------------------------------
> 
> Message: 5
> Date: Sun, 3 Jan 2010 20:07:25 +1100
> From: Scott Foster <scott.foster at csiro.au>
> Subject: Re: [R-sig-eco] Time series and GLS
> To: LisaB <lisabaril at hotmail.com>
> Cc: "r-sig-ecology at r-project.org" <r-sig-ecology at r-project.org>
> Message-ID: <4B405E4D.9080804 at csiro.au>
> Content-Type: text/plain; charset="utf-8"; format=flowed
> 
> Hi,
> 
> Just a few quick thoughts.
> 
> *) your success.gls model contains a linear effect for year.  Is this 
> really likely over the time period you mention?  I would highly doubt it 
> (but this is really just a guess).  If this is not the case then your 
> residuals are likely to show falsely high autocorrelation, not because 
> it is there but because the residuals come from an inappropriate mean
> model.
> *) With the previous point in mind: have you considered using GAM 
> models?  It seems like a perfect application as you can specify 
> different smooth functions for each of the populations and then see if 
> they really are all that different (through LRTs).
> *) The GLS function will assume normality (albeit correlated).  Is this 
> really all that believable?  In the GAM framework you could specify 
> binomial data, an assumption that is much more likely to make sense.  Of 
> course, your data may contain enough nests sampled and a favourable 
> probability of success, to make the normality assumption very plausible.
> *) The GAM model, when viewed as a random effects model, does specify a 
> correlation structure amongst the outcomes.  It may not be the most 
> appropriate correlation structure, nor even *an* appropriate structure 
> but it may be a suitable starting place.  Most analysts would consider 
> it a useful finishing place too (but you can extend the GAM model -- 
> Richard Morton has done some work in this line although I can't find the 
> reference right now). 
> 
> Be careful taking acf of residuals in GAM models -- the residuals from 
> the model conditional on the random effects may not tell much about the 
> correlation structure (need the marginal distribution for this).
> 
> I just notice that Kingsford Jones has sent through some more pointers.  
> They are excellent suggestions, especially the one about plotting up 
> your data -- visualisation is much more important than formal testing 
> (in my opinion).  I believe that the above points are complementary to 
> Kingsford's comments.
> 
> I hope that this helps,
> 
> Scott
> 
> PS  An excellent reference for GAMs is Simon Wood's Book (with 
> accompanying R package).
> 
> 
> LisaB wrote:
> > Thanks Kinsford.  I thought it would be appropriate.  As a follow up
> > question: My first thought is to set up the data file with three columns:
> > year, population (A,B), and nest success and then to input the following
> > formula: success.gls=gls(success~year*population).  This would allow me to
> > test for the effect of year for each population and then also test for
> > differences between the two populations.  My questions are 1) have I
> > specified the model right for those questions and 2) would the acf function
> > calculate the autocorrelation correctly even though my 'year' in the data
> > file is repeated twice (once for each value of nest success/population)? 
> > Thanks. Lisa (hope all is well with you)
> >
> >
> > Kingsford Jones wrote:
> >   
> >> The gls function in nlme fits a general linear model, so yes you can
> >> have categorical predictors (the advantage over the lm function is the
> >> error covariance matrix may have non-zero off-diagonals, such as with
> >> an autocorrelation structure, and non-constant diagonals).
> >>
> >> hth,
> >> Kingsford Jones
> >>
> >> On Fri, Jan 1, 2010 at 2:44 PM, LisaB <lisabaril at hotmail.com> wrote:
> >>     
> >>> Hello -
> >>>
> >>> I need to analyze some time series data in an ANOVA framework, but am
> >>> unsure
> >>> of how to go about it.  I have data on nest success (response) over a 22
> >>> year period for two populations.  For each year I have one value of nest
> >>> success per population.  I am interested in determining 1) whether there
> >>> are
> >>> differences in nest success over time between these two populations and
> >>> 2)
> >>> what are the trends for each population over time.  My thought is to use
> >>> GLS
> >>> and model temporal autocorrelation if the acf function indicates this is
> >>> an
> >>> issue, but since population is a categorical variable I'm unsure if this
> >>> is
> >>> appropriate.  Any advice would be much appreciated. Thank you. Lisa
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >>> http://n2.nabble.com/Time-series-and-GLS-tp4240700p4240700.html
> >>> Sent from the r-sig-ecology mailing list archive at Nabble.com.
> >>>
> >>> _______________________________________________
> >>> R-sig-ecology mailing list
> >>> R-sig-ecology at r-project.org
> >>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> >>>
> >>>       
> >> _______________________________________________
> >> R-sig-ecology mailing list
> >> R-sig-ecology at r-project.org
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> >>
> >>
> >>     
> >
> >   
> 
> -- 
> Scott Foster
> CSIRO Mathematical and Information Sciences
> GPO Box 1538
> Castray Esplanade
> Hobart 7001
> Tasmania 
> Australia
> 
> Phone:     (03) 6232 5178
> Fax:       (03) 6232 5000
> Email:     scott.foster at csiro.au
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> 
> 
> End of R-sig-ecology Digest, Vol 22, Issue 3
> ********************************************



More information about the R-sig-ecology mailing list