[R] nlme: correlation structure in gls and zero distance

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Sun Jul 2 15:36:23 CEST 2006



Joris De Wolf a écrit :
> Have you tried to define 'an' as a group? Like in
>
> gls(IKAfox~an,correlation=corExp(2071,form=~x+y|an,nugget=1.22),data=renliev) 
>
>
> A small data set might help to explain the problem.
>
> Joris
Thanks. Seems to work with a small artificial data set:


an<-as.factor(rep(2001:2004,each=10))
x<-rep(rnorm(10),times=4)
y<-rep(rnorm(10),times=4)
IKA<-rpois(40,2)
site<-as.factor(rep(letters[1:10],times=4))


library(nlme)

mod1<-gls(IKA~an-1,correlation=corExp(form=~x+y))

 >Error in getCovariate.corSpatial(object, data = data) :
        Cannot have zero distances in "corSpatial"


mod2<-gls(IKA~an-1,correlation=corExp(form=~x+y|an))

 > mod2
Generalized least squares fit by REML
  Model: IKA ~ an - 1
  Data: NULL
  Log-restricted-likelihood: -73.63998

Coefficients:
  an2001   an2002   an2003   an2004
1.987611 2.454520 2.429907 2.761011

Correlation Structure: Exponential spatial correlation
 Formula: ~x + y | an
 Parameter estimate(s):
    range
0.4304012
Degrees of freedom: 40 total; 36 residual
Residual standard error: 1.746205





>
> Joris
>
> Patrick Giraudoux wrote:
>> Dear listers,
>>
>> I am trying to model the distribution of  fox density over years  in 
>> the Doubs department. Measurements have been taken on 470 plots in 
>> March each year and georeferenced. Average density is supposed to be 
>> different each year.
>>
>> In a first approach, I would like to use a general model of this 
>> type, taking spatial correlation into account:
>>
>> gls(IKAfox~an,correlation=corExp(2071,form=~x+y,nugget=1.22),data=renliev) 
>>
>>
>> but I get
>>
>>  > 
>> gls(IKAfox~an,correlation=corExp(2071,form=~x+y,nugget=1.22),data=renliev) 
>>
>> Error in getCovariate.corSpatial(object, data = data) :
>>         Cannot have zero distances in "corSpatial"
>>
>> I understand that the 470 geographical coordinates are repeated three 
>> times (measurement are taken each of the three years at the same 
>> place) which obviously cannot be handled there.
>>
>> Does anybody know a way to work around that except jittering slightly 
>> the geographical coordinates?
>>
>> Thanks in advance,
>>
>> Patrick
>>
>> ______________________________________________
>> 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
>
>
> confidentiality notice:
> The information contained in this e-mail is confidential a...{{dropped}}



More information about the R-help mailing list