Hi all,

I'm trying to model some ecological data of an area to predict spatially some ecological response variable  in terms of x, y, and some covariates have been measured. The problem is that some of the covariates are discrete (ordinal) and do not really know how to make a cokriging with multiple covariates.

Bayesian cokriging or perhaps a transformation based on a mixed distance as the Gower?

Any idea? I add below a R code with some of the data, the covariates and the response variable.

How  can I do a Cross-validation with used data  to determine whether the estimated model fits well?

Thank you very much in advance.

Toni
Department of Statistics
University of Barcelona

###########################################################################################################
############################         kriging and cokriging  with multiple covariate      ##########################################
###########################################################################################################
###########################################################################################################
###########################################################################################################

data_example<-structure(list(x = c(430234, 429626, 413104, 456047, 475226, 422256, 446443, 456281, 433773, 404269),
y = c(4588887, 4579902, 4574398, 4621071, 4610062, 4587858, 4609701, 4617064, 4600892, 4575527, 4587229, 4620543),
var1 =c(1287, 131, 91, 21, 5, 311, 22, 57, 1252, 113),
var2 =c(39.26, 68.13, 36.42, 16.06, 46.75, 34.19, 56.87, 31.04, 35.19, 15.40),
var3 =c(3, 9, 1, 1, 2, 1, 10, 2, 11, 1),
var4 =c(1, 3, 1, 1, 1, 1, 3, 1, 1, 1),
var5 =c(0.41, 0.89, 0.77, 0.29, 0.93, 0.31, 0.94, 0.84, 0.80, 0.60),
var6 =c(4.02, 8.63, 6.08, 2.60, 8.64, 3.81, 7.65, 5.81, 4.31, 2.13),
var7 =c(1.07, 1.12, 1.08, 1.10, 1.07, 1.15, 1.08, 1.07, 1.08, 1.05)),
.Names = c("x", "y", "Cov1", "Cov2",  "Cov3", "Cov4", "Cov5", "Response", "Cov6" ), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"))


library(gstat)
data(data_example)
attach(data_example)

# Ordinary Kriging in gstat

# compute experimental variogram
v <- variogram(response~1, ~ x+y, data_example)
# estimated model
m <- vgm(1.4, "Sph", 12000, 0.5)
# fitted model
m.f <- fit.variogram(v, m)

new.locs <- data.frame(
x = c(430334, 429726, 413204, 456147, 475326, 422356, 446543, 456381, 433873, 404369, 422732),
 y = c(4588987, 4571002, 4574498, 4621171, 4610162, 4587958, 4609801, 4617164, 4600992, 4575627, 4587329))

kr <- krige(response~ 1, loc=~ x+y, data=data_example, newdata=new.locs, model=m.f)


library (lattice)
# visualize interpolation; note aspect option to get correct geometry
levelplot(var1.pred ~ x+y, kr)
# visualize prediction error
levelplot(var1.var ~ x+y, data=kr,col.regions=terrain.colors(40))


	[[alternative HTML version deleted]]

