[R] Strange error message from geoR´s likfit () lik. max. func.
Ruben Roa Ureta
rroa at udec.cl
Fri Aug 15 17:33:48 CEST 2008
ComRades:
I am geeting the error message
Error in ldots[[which(MET)]] : attempt to select less than one element
when I try to fit the geostatistical model with the likfit() function of
geoR.
I have tried with old data for which likfit() successfully maximised the
likelihood in previous versions of geoR, and yet the current version
fails.
I have tried in Windows Vista and Windows XP (I haven't tried in Linux
systems) and the problem occurs in both systems.
Below I show the issue with simulated data.
Is it a geoR bug?
Does anybody know a solution?
Thanks in advance
Ruben
x <- rnorm(50,5,2) # eastings
y <- rnorm(50,25,3) # northings
z <- rnorm(50,350,35) # data
v <- c(rep(1,25),rep(2,25)) # two different areas
w <- data.frame(cbind(x,y,z,v)) # put all together
w1 <- subset(w,v == 1) # use data fron one area
w1.geo <- as.geodata(w1,coords.col=1:2,data.col=3) # create geodata object
summary(w1.geo) # everything looks normal
#Number of data points: 25
#
#Coordinates summary
# x y
#min 1.233673 15.82129
#max 8.464283 34.30390
#
#Distance summary
# min max
# 0.2962488 19.5670141
#
#Data summary
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 296.1 336.3 345.5 351.9 366.5 422.1
plot(w1.geo) # so far so good
plot(w1.geo,lambda=0.1) #ditto
w1.geo.vc<-variog(w1.geo,option="cloud",max.dist=summary(w1.geo)$distances.summary[2],lambda=lambda)
#variog: computing omnidirectional variogram
plot(w1.geo.vc)
w1.geo.lf<-likfit(w1.geo,cov.model="matern",ini.cov.pars=c(2,0.03),kappa=1,fix.kappa=FALSE,nugget=0.01,lambda=lambda,fix.lambda=FALSE,hessian=TRUE)
# here the error in likfit()
#Error in ldots[[which(MET)]] : attempt to select less than one element
sessionInfo()
#R version 2.6.2 (2008-02-08)
#i386-pc-mingw32
#
#locale:
#LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
#
#attached base packages:
#[1] stats graphics grDevices utils datasets methods base
#
#other attached packages:
#[1] geoR_1.6-21 sp_0.9-25
#
#loaded via a namespace (and not attached):
#[1] grid_2.6.2 lattice_0.17-4 tools_2.6.2
More information about the R-help
mailing list