[R-sig-eco] autocorrelation structure

Wen Li Li.Wen at environment.nsw.gov.au
Thu Nov 24 21:27:20 CET 2011


Hi again, Marc,

You may first test the seasonality of your data use the SeasonalMannkendall command in the Kendall Package. 

Cheers,
Li

-----Original Message-----
From: r-sig-ecology-bounces at r-project.org [mailto:r-sig-ecology-bounces at r-project.org] On Behalf Of Wen Li
Sent: Friday, 25 November 2011 7:11 AM
To: 'gavin.simpson at ucl.ac.uk'; Marc Taylor
Cc: r-sig-ecology at r-project.org
Subject: Re: [R-sig-eco] autocorrelation structure

Hi, Marc

You may try to transfer your data by seasonal differential if you have multi-year data. 

Cheer,
Li

-----Original Message-----
From: r-sig-ecology-bounces at r-project.org [mailto:r-sig-ecology-bounces at r-project.org] On Behalf Of Gavin Simpson
Sent: Friday, 25 November 2011 3:34 AM
To: Marc Taylor
Cc: r-sig-ecology at r-project.org
Subject: Re: [R-sig-eco] autocorrelation structure

On Thu, 2011-11-24 at 17:02 +0100, Marc Taylor wrote:
> Dear R-sig-ecology list,
> 
> 
> I am fitting a gamm model(package: mgcv)  in which I have a violation of
> independence with regard to temporal autocorrelation due to the fact that
> all of my variables have a cyclical seasonal pattern.

I would try to model this in the main effects rather than correct for it
in the covariance matrix.

If you have data measured throughout the year, over several years, then
add a cyclic spline term to your model. For example,

mod <- gamm(resp ~ s(year) + s(month, bs = "cc"), data = foo, ....)

will fit a cyclic cubic spline in month (say coded 1, 2, 3 numerically)
which means that the end points of the spline are match, up to 2nd
derivatives.

I have regularly used this for spot samples throughout years, where I
use the day of the year of the sample as my variable for the cyclic
term:

mod <- gamm(resp ~ s(year) + s(doy bs = "cc"), data = foo, ....)

You may want to specify the knots for the seasonal term to give coverage
over the real period of interest. For example, I had data on water
temperature over most days of the year but the people doing the sampling
didn't sample over Christmas and New Year, so I specifically set the
knot endpoints to be day of year 1 and 366 to be able to generate
predictions over the entire year (of course the fitted spline in the
period without data was subject to greater uncertainty but that was fine
for me).

HTH

G

>  I have largely
> corrected for this by including a AR-2 correlation structure in the
> following way:
> 
> >corstr <- corARMA(c(0.4, -0.1), p=2, q=0, form = ~ DATE)
> 
> I nevertheless continue to have some autocorrelation in the "significant"
> range at some of the larger time lags (i.e. year lags) as identified by:
> 
> >E <- resid(gamm.fit$lme, type="normalized")
> >acf(E)
> 
> 
> My guess is that an AR-2 structure can't produce a sin-like correlation
> structure, but when I try a higher AR structure(i.e. p=3), the fitting
> doesn't converge.
> 
> Is anyone familiar with such a problem? Does the fitting need to run for a
> longer period of time, or are there other options for me?
> 
> Many thanks for you help,
> Marc
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is intended for the addressee(s) named and may contain confidential and/or privileged information. 
If you are not the intended recipient, please notify the sender and then delete it immediately.
Any views expressed in this email are those of the individual sender except where the sender expressly and with authority states them to be the views of the Office of Environment and Heritage, NSW Department of Premier and Cabinet.

PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
This email is intended for the addressee(s) named and may contain confidential and/or privileged information. 
If you are not the intended recipient, please notify the sender and then delete it immediately.
Any views expressed in this email are those of the individual sender except where the sender expressly and with authority states them to be the views of the Office of Environment and Heritage, NSW Department of Premier and Cabinet.

PLEASE CONSIDER THE ENVIRONMENT BEFORE PRINTING THIS EMAIL



More information about the R-sig-ecology mailing list