[Gstat-info] Is it possible to extract kriging weights from within the R-package of gstat

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Jul 29 20:21:19 CEST 2008


There is a simple way to get them printed to screen, not to get them 
back in an R structure. There may be a non-simple way to get them. If 
you have time, here it is. Note that it is VERY inefficient.

The kriging predictor is a linear combination of the data, with weights 
the kriging weights. If you want weight k, just plug in zero 
observations for all but observation k, and unit value for observation 
k. Iterate k over the full neighbourhood, and there you go. It's just 
like the trick to get the BLUE estimates.

Try:

kriging.weights = function(x, formula, newdata, model) {
   weighti = function(x, i, formula,...) {
       ret =rep(0,nrow(x))
       ret[i]=1
       x[[1]]=ret
       krige(formula = formula,locations = x,...)
   }
   ret = sapply(1:nrow(x), weighti, x=x, newdata=newdata[1,], 
model=model,formula=formula)
   ret = t(sapply(ret, as.data.frame))
   unlist(ret[,3])
}
kriging.weights(meuse["zinc"], zinc~1, as(meuse.grid, 
"SpatialPoints")[1], model=vgm(1,"Exp",300))

-- 
Edzer

Sun Tsu wrote:
> (Sorry. Part of this message may have been posted already as I did not 
> use the correct mechanism for posting)
>
> My question:
>
> Is it possible to extract the kriging weights from within the 
> R-package of gstat? I do know that you can plot them with 
> setplotfile='file' option. I suppose, I could parse the output of the 
> gnuplot file, but would like to know if is possible via some magic 
> option.
>
> Any help would be appreciated. Thanks in advance.
>
> Best,
> Jae
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gstat-info mailing list
> Gstat-info at geo.uu.nl
> http://mailman.geo.uu.nl/mailman/listinfo/gstat-info
>   

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster, 
Weseler Straße 253, 48151 Münster, Germany.  Phone: +49 251 
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de/



More information about the Gstat-info mailing list