[R-sig-Geo] cross-validation

Marta Rufino mrufino at cripsul.ipimar.pt
Wed Feb 6 20:12:48 CET 2008


Hello,

yes, I know it is suppose to do it, but I could not find how, because it 
gives me an error... for example:

require(gstat); require(lattice)
data(meuse)
coordinates(meuse) = ~x + y
data(meuse.grid)
gridded(meuse.grid) = ~x + y

meuse.g <- gstat(id = "zn", formula = log(zinc) ~ 1, data = meuse)
meuse.g <- gstat(meuse.g, "cu", log(copper) ~ 1, meuse)

meuse.g <- gstat(meuse.g, model = vgm(1, "Sph", 900, 1), fill.all = T)
x <- variogram(meuse.g, cutoff = 1000)
meuse.fit = fit.lmc(x, meuse.g)
plot(x, model = meuse.fit)
z <- predict(meuse.fit, newdata = meuse.grid)
spplot(z) #map
gstat.cv(meuse.g) #does not work...
gstat.cv(meuse.g, remove.all=T) #either
gstat.cv(meuse.g, all.residuals=T) #either
gstat.cv(object=meuse.g, formula = log(zinc) ~ 1, data = meuse, model = 
vgm(1, "Sph", 900, 1), nmax=40, verbose=F) #either :-(

#                             
# Intrinsic Correlation found. Good.
# [using ordinary cokriging]

# "chfactor.c", line 130: singular matrix in function LDLfactor()
# Error in predict.gstat(object, newdata = data[sel, ], ...) :
#         LDLfactor

Maybe an example on the help file would be nice (eheheh).. I
What am I missing?


Thank you very much in advance,
Marta




More information about the R-sig-Geo mailing list