[R] Correlation structures in gls with repeated measurements

t03eh7 at abdn.ac.uk t03eh7 at abdn.ac.uk
Wed Jul 2 12:28:45 CEST 2008


Hi,

I am trying include a spatial correlation structure into a gls model but
keep getting the following error:

> ocean<-read.table("C:\\oceanography2.txt",header=TRUE)
> library(nlme)

> YEAR<-as.factor(ocean$YEAR)

>group<-groupedData(san_dens~temp_grad*pyc_grad*start_thermo|YEAR,data=ocean)

> model1<-gls(san_dens~temp_grad*pyc_grad*start_thermo,data=group)

> model2<-update(model1,corr=corSpher(form=~MIDLONGDEC+MIDLATDEC|YEAR))
Error in getCovariate.corSpatial(object, data = data) :
  Cannot have zero distances in "corSpatial"


The measurements have been repeated over 10 years so the coordinates are
repeated which I assume is the reason for this error. I thought grouping
by YEAR should remove this but it doesnt seem to work, or I am making a
mistake when I am trying to group it? I have noticed a couple of other
posts with the same problem but I have still not managed to solve this.

I would be really grateful if anyone has any ideas or has had this problem
before.


Thanks in advance,
Emma Hazard



More information about the R-help mailing list