[R-sig-Geo] ossfim with Universal Kriging?

Alí Santacruz amsantac at hotmail.com
Sat Jul 8 20:32:19 CEST 2006


Dear list members:

I am trying to make a cost/benefit analysis in a sampling network for 
organic matter soil content data. The best model fitted was exponential 
(universal kriging, first order trend).

So I need to know if it is possible to use ossfim function with universal 
kriging.

I tried to modify the ossfim function but I get an error:

>ossfim.UK<-function (spacings = 1:5, block.sizes = 1:5, model, nmax = 25,
+     debug = 0)
+ {
+     n = floor(sqrt(nmax)) + 1
+     x = 0:(n - 1) + 0.5
+     x = sort(c(-x, x))
+     ret = matrix(NA, length(spacings) * length(block.sizes),
+         3)
+     r = 1
+     for (sp in spacings) {
+         for (bl in block.sizes) {
+             data.grid = data.frame(expand.grid(x * sp, x * sp),
+                 z = rep(1, length(x)^2))
+             names(data.grid) = c("x", "y", "z")
+             gridded(data.grid) = c("x", "y")
+             x0 = SpatialPoints(matrix(0, 1, 2))
## Next I modify the formula in krige using the coordinates names of my data
## to use universal kriging:
+             kr = krige(z ~ e+n, data.grid, x0, block = c(bl, bl),
+                 model = model, nmax = nmax, set = list(debug = debug))
+             ret[r, ] = c(sp, bl, sqrt(kr[["var1.var"]][1]))
+             r = r + 1
+         }
+     }
+     ret = data.frame(ret)
+     names(ret) = c("spacing", "block.size", "kriging.se")
+     ret
+ }
>err.grid <- ossfim.UK(seq(10,60,10),block.sizes=0,m.f.exp.t1)
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ (found for 'e')

Is it possible what I want to do? Does it have sense?

I appreciate any help or comment.

Sincerely,

Alí M. Santacruz
M.Sc. Geomatics, Student
National University of Colombia
Bogotá D.C.




More information about the R-sig-Geo mailing list