Skip to content

covariance matrix for kriging predictions

4 messages · Jui-Han Chang, Edzer Pebesma, Benedikt Gräler

#
On 12/12/2013 08:20 PM, Jui-Han Chang wrote:
Thanks, this is clearly wrong. My feeling is that c0 in the computation
of the kriging predictions covariance matrix needs be specified
differently, not as a constant, however I haven't sorted out how, so far.
#
Dear Jui-Han,

I believe the following script does what you are looking after. The idea
is to start with the covariance matrix purely defined by the variogram
model (i.e. with the joint sill on the diagonal). Rescale this
covariance matrix first to correlations and then back to covariances
using the marginal variances obtained from the kriging predictor. I will
correct the krige0 function in gstat accordingly.

Let me know if this is what you have been looking for.

Best wishes,

 Ben

#--R-Script--#
# get some data
library(gstat)
library(sp)

data(meuse)
coordinates(meuse) = ~x+y
data(meuse.grid)
gridded(meuse.grid) = ~x+y

m <- vgm(0.59,"Sph", 897, 0.05)

# do the prediction to get the marginal kriging
# variance for each grid cell
pred <- krige(log(zinc)~1, meuse, meuse.grid, m)

# calculate the covariacne strucutre of the desired
# grid: 3103 x 3103 matrix
covMat <- variogramLine(m, dist_vector = spDists(meuse.grid,
meuse.grid), covariance = TRUE)

# rescale to correlation matrix
corMat <- cov2cor(covMat)

# scale back to the desired variances on the
# diagonal, just the same way backwards as cov2cor
# does it:
covMat <- corMat*matrix(sqrt(pred$var1.var) %x%
sqrt(pred$var1.var),3103,3103)
covMat[1:5,1:5]

# check for correlation
cov2cor(covMat[1:5,1:5])

# check prediction variance:
diag(covMat) - pred$var1.var

#--R-Script--#
On 12.12.2013 22:54, Edzer Pebesma wrote:

  
    
3 days later