On 12/12/2013 08:20 PM, Jui-Han Chang wrote: > Hi all, > > I am trying to get covariance matrix for kriging predictions. I used krige0 > function in the gstat library with options fullCovariance=TRUE and > computeVar=TRUE. I got a covariance matrix but the values seem to be too > large. I converted the covariance matrix to correlation matrix and got > values larger than 1. Following are the codes to derive the matrices: > > library(gstat) > data(meuse) > coordinates(meuse) = ~x+y > data(meuse.grid) > gridded(meuse.grid) = ~x+y > > m <- vgm(.59, "Sph", 874, .04) > x <- krige0(log(zinc)~1, meuse, meuse.grid, model = > m,fullCovariance=TRUE,computeVar=TRUE) > > x$var[1:5,1:5] > > [,1] [,2] [,3] [,4] [,5] > 1 0.3108421 0.2794621 0.2883862 0.3019975 0.2528104 > 2 0.2794621 0.2414045 0.2546174 0.2727450 0.2074984 > 3 0.2883862 0.2546174 0.2631935 0.2769452 0.2263174 > 4 0.3019975 0.2727450 0.2769452 0.2863739 0.2499542 > 5 0.2528104 0.2074984 0.2263174 0.2499542 0.1648699 > > cov2cor(x$var[1:5,1:5]) > > [,1] [,2] [,3] [,4] [,5] > 1 1.000000 1.020188 1.008247 1.012201 1.116746 > 2 1.020188 1.000000 1.010131 1.037331 1.040091 > 3 1.008247 1.010131 1.000000 1.008764 1.086450 > 4 1.012201 1.037331 1.008764 1.000000 1.150331 > 5 1.116746 1.040091 1.086450 1.150331 1.000000 > > I am not sure what I am getting here now. Is this covariance matrix for > kriging predictions? If not does anyone know how to get a covariance > matrix? Any help will be appreciated.
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. -- Edzer Pebesma Institute for Geoinformatics (ifgi), University of Münster Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251 83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795
signature.asc
Description: OpenPGP digital signature
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo