Ruben Roa Ureta
2008-Aug-15 15:33 UTC
[R] Strange error message from geoR´s likfit () lik. max. func.
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
Paulo Justiniano Ribeiro Jr
2008-Aug-16 02:05 UTC
[R] Strange error message from geoR´s likfit () lik. max. func.
Ruben it is a bug I will upload a new version of geoR. Meanwhile please download the version with the fix from the geoR web page at www.leg.ufpr.br/geoR Paulo Justiniano Ribeiro Jr LEG (Laboratorio de Estatistica e Geoinformacao) Universidade Federal do Parana Caixa Postal 19.081 CEP 81.531-990 Curitiba, PR - Brasil Tel: (+55) 41 3361 3573 Fax: (+55) 41 3361 3141 e-mail: paulojus AT ufpr br http://www.leg.ufpr.br/~paulojus On Fri, 15 Aug 2008, Ruben Roa Ureta wrote:> 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 > >