0

I may be doing something wrong here, but I find that if I simplify my data frame by removing irrelevant columns the autoKrige function in the automap library gives different results. I have reproduced this problem with the meuse data in the automap library.

library(automap)
data(meuse)
colnames(meuse)
 [1] "x"       "y"       "cadmium" "copper"  "lead"    "zinc"    "elev"   
 [8] "dist"    "om"      "ffreq"   "soil"    "lime"    "landuse" "dist.m" 

coordinates(meuse) =~ x+y
data(meuse.grid)
gridded(meuse.grid) =~ x+y
kriging_result_01 = autoKrige(zinc~1, meuse)
plot(kriging_result_01)

meuse <- NULL
data(meuse)
meuse <- meuse[, c(1,2,6)]

coordinates(meuse) =~ x+y
data(meuse.grid)
gridded(meuse.grid) =~ x+y
kriging_result_02 = autoKrige(zinc~1, meuse)
plot(kriging_result_02)

identical(kriging_result_01, kriging_result_02)
[1] FALSE

The plots are also different in their detail.

Is this the expected behaviour?

Thanks, Bill

  • I didn't search in details why, but I guess this is related to how the `new_data` object is calculated when it is not provided to `autoKrige`. Using `autoKrige(zinc~1, meuse, meuse.grid)` gives identical results. –  Oct 01 '14 at 05:19
  • If you look at `kriging_result_01$krige_output@grid` and `kriging_result_02$krige_output@grid`, you can see the calculated `new_data` objects are slightly different. –  Oct 01 '14 at 05:37

1 Answers1

0

The problem is not the removed columns, but the grid to apply the fitted model on. Using your example, you can see:

library(automap)
set.seed(42)

data(meuse)
coordinates(meuse) =~ x+y
data(meuse.grid)
gridded(meuse.grid) =~ x+y
kriging_result_01 = autoKrige(zinc~1, meuse)

meuse <- NULL
data(meuse)
meuse <- meuse[, c(1,2,6)]
coordinates(meuse) =~ x+y

kriging_result_02 = autoKrige(zinc~1, meuse)


kriging_result_01$krige_output@grid
                            x1           x2
cellcentre.offset 178635.12844 329744.86186
cellsize              32.93423     32.93423
cells.dim             84.00000    118.00000

and

kriging_result_02$krige_output@grid
                            x1           x2
cellcentre.offset 178614.42379 329741.35016
cellsize              32.93423     32.93423
cells.dim             85.00000    118.00000

As you can see, the grids are slightly different, with 4999 and 4996 grid points respectively.

If you use

kriging_result_01 = autoKrige(zinc~1, meuse, meuse.grid)
kriging_result_02 = autoKrige(zinc~1, meuse, meuse.grid)

kriging_result_01$krige_output@grid
                       x      y
cellcentre.offset 178460 329620
cellsize              40     40
cells.dim             78    104

kriging_result_02$krige_output@grid
                       x      y
cellcentre.offset 178460 329620
cellsize              40     40
cells.dim             78    104

The grids are similar.

  • @WilliamChivers if this answer solved your question, consider accepting it as a correct answer - by clicking the grey tick under its score. – Roman Luštrik Oct 01 '14 at 07:29