Description Usage Arguments Value Note Author(s) Examples
View source: R/crossvalidate.r
In addition to supporting kriging and idw, it also supports thin plate splines (through Tps (fields)).
1 | crossvalidate(formula, data, func = "doTps", ...)
|
formula |
A formula to define the dependent and the independent variables, see the documentation of krige. |
data |
The input data, should be a spatial object which supports coordinates extracting through coordinates() |
func |
The function which should be used for cross-validation, possibilities are "krige", "idw", "doNearestNeighbor" and "doTps". |
... |
parameters that are passed on to 'func' |
The function returns a spatial object with the class of 'data'. The format in which the cross-validation results are presented is equal to that of krige.cv.
At this stage only leave-one-out cross-validation is supported. In addition, the formula supports only a limit syntax, i.e. log(zinc) or sqrt(dist) are not possible in the formula. Instead, create a new column in the object, e.g. meuse$log_zinc = log(meuse$zinc).
Paul Hiemstra, p.h.hiemstra@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library(automap)
library(sp)
library(gstat)
data(meuse)
coordinates(meuse) = ~x+y
data(meuse.grid)
gridded(meuse.grid) = ~x+y
regres_cv = crossvalidate(zinc~dist, meuse, func = "krige", debug.level = 0)
nearestneighbor_cv = crossvalidate(zinc~1, meuse, func = "doNearestNeighbor")
idw2_cv = crossvalidate(zinc~1, meuse, func = "idw", debug.level = 0)
idw4_cv = crossvalidate(zinc~1, meuse, func = "idw", debug.level = 0, idp = 4)
idw05_cv = crossvalidate(zinc~1, meuse, func = "idw", debug.level = 0, idp = 0.5)
ked_cv = crossvalidate(zinc~dist, meuse, func = "krige",
model = autofitVariogram(zinc~dist, meuse, model = "Ste")$var_model, debug.level = 0)
tps_cv = crossvalidate(zinc~1, meuse, func = "doTps", debug.level = 0)
tpsdist_cv = crossvalidate(zinc~dist, meuse, func = "doTps", debug.level = 0)
compare.cv(regres_cv, idw2_cv, idw4_cv, idw05_cv, tps_cv, tpsdist_cv, ked_cv)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.