[R-sig-Geo] krige error message: dimensions do not match

dagmar.mueller at gkss.de dagmar.mueller at gkss.de
Fri Mar 2 10:39:15 CET 2007


I think my question might be related to  karl.sommer's  ( error message 
rgdal: dimensions do not match, Date: Wed, 5 Jul 2006). 
Have you found out, why the error message 'dimensions do not match ...' 

I'm trying to write a simple cross validation function, which combines the 
functionality of xvalid (geoR) to use a subset of data for cross 
validation with the possibility of nested variogram models from vgm 

If I check for dimensions of the data.frames data.out and cv.dat, they 
have exactly the expected dimensions. Nevertheless krige() returns the 
error "Fehler: dimensions do not match: locations 373628 and data 163419". 

dim(dat): 186815    4
dim(cv.dat): 186814    4
dim(data.out): 1    4

There are no 'NA's or 'NaN's in the data.frame. 
Does anyone know, why the error occurs? I'm completly at a loss.. 

Yours sincerely, 
Dagmar Mueller 

This is the code (modified xvalid()-code): 
MyCV<-function (dat , model,locations.xvalid = "all",krig.nmax=100) {
   #some code...
    if (crossvalid) {
        cv.f <- function(ndata, ...) {
            data.out <- dat[ndata, ]
            cv.dat <- dat[-ndata, ]
        kr<-krige(res~1,loc=~Lon+Lat,data=cv.dat, newdata=data.out[,1:2], 
model=model, nmax=krig.nmax)
            res <- c(data.out, kr$var1.pred, kr$var1.var)
        res <- as.data.frame(t(apply(matrix(locations.xvalid), 1, cv.f)))
#some code...

More information about the R-sig-Geo mailing list