Description Usage Arguments Details Value Note Author(s) References See Also Examples
Function for constrained, covariance-matching constrained and universal (external drift kriging) point or block (of any shape) kriging in a global neighbourhood and for isotropic covariance models.
1 2 3 4 5 6 7 | CKrige( formula, data, locations, object, ...)
## S4 method for signature 'formula,data.frame,formula,preCKrigePolygons'
CKrige(formula, data, locations, object, method = 2, ex.out = F)
## S4 method for signature 'formula,data.frame,formula,preCKrigePoints'
CKrige(formula, data, locations, object, method = 2, ex.out = F)
|
formula |
formula of the linear regression model in the form |
data |
a data frame with the values of the covariates, the names of the
covariates used in the formula object must match the column
names of |
locations |
a |
object |
either an object of the class “ |
... |
two further arguments to control the spatial interpolation method and the output |
method |
numeric value to choose the kriging method |
ex.out |
logical value, if |
The CKrige
function depends always on a preCKrige
output object that contains the parameter of the isotropic covariance model as well
as the covariates of the prediction targets.
By default, CKrige
returns an object of
the class SpatialPointsDataFrame
or
SpatialPolygonsDataFrame
depending whether the input object for the object
argument is of the
class “preCKrigePoints
” or “preCKrigePolygons
”.
The data frame of the returned object contains the following columns independent of the selected kriging method:
prediction |
numeric vector with the kriging prediction of the chosen method |
prediction.se |
numeric vector with the root mean square error (kriging standard error) |
The data frame contains 3 additional columns with constrained kriging
parameters, if the argument method = 2
of the CKrige
function:
sqrt.P |
numeric vector with sqrt( Var[ target point or block ] - Var[ fitted values ] ) |
sqrt.Q |
numeric vector with sqrt( Var[ universal kriging predictor ] - Var[ fitted values ] ) |
K |
numeric vector with |
The data frame contains 3 additional columns with covariance-matching
constrained kriging parameters, if the argument
method = 3
of the CKrige
function:
P1.11 |
numeric vector, first element of the matrix P1 = ( Cov[target point or block] - Cov[fitted values] )^(1/2) |
Q1.11 |
numeric vector, first element of the matrix Q1 = ( Cov[universal kriging predictor] - Cov[fitted values] )^(1/2) |
K.11 |
numeric vector, first element of the matrix K = O1^-1P1[1,1] |
The CKrige
function returns a list with the following components if
the argument ex.out = T
and the argument method
is either 1
or 2
:
object |
either an object of the class |
krig.method |
numeric scalar, number of the chosen kriging method 1, 2 or 3. |
parameter |
list with 2 components. First component |
sk.weights |
if argument |
inv.Sigma |
matrix, inverse covariance matrix of the data |
residuals |
numeric vector with the Generalized Least Square residuals of the linear regression. |
The list of the extended output contains the additional component CMCK.par
if the argument method = 3
. The
CMCK.par
component is a list of lists with CMCK parameters, in particular P1
list of the P1 matrices,
Q1
list of the Q1 matrices and K
list of the K matrices.
print
and summary
methods for the different CKrige
output objects are available.
Christoph Hofer, christoph.hofer@alumni.ethz.ch
See main help page of the constrainedKriging package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ## Not run:
# load data
data(meuse,meuse.blocks)
# approximation of block variance
# pixel area = 75m x 75m
# exponential covariance function with measurement error = 0, nugget = 0.05,
# part. sill = 0.15 and range parameter = 192.5
preCK=preCKrige(newdata=meuse.blocks,model=
covmodel("exponential",0,0.05,0.15,192.5),pwidth=75,pheight=75)
# block prediction by constrained kriging on the log scale
CK=CKrige(formula=log(zinc)~sqrt(dist),data=meuse,
locations=~x+y,object=preCK,ex.out=TRUE)
# backtransformation to the original scale for the CK prediction
beta=CK$parameter$beta.coef
M=meuse.blocks@data$M
c1 <- 0.2
c2 <- beta[2]^2 * meuse.blocks@data$M
CK$object@data$Zn=exp(CK$object@data$prediction
+ 0.5*(0.2+beta[2]^2*M-unlist(preCK@covmat)))
# U: upper limits of the relative 95
# U multiplied by the predictions CK$object@data$Zn gives
# the upper limits of the 95
CK$object@data$U=exp(CK$object@data$prediction
+1.96*CK$object@data$prediction.se) /CK$object@data$Zn
# plots with spplot, generic function in the sp package
# the plot shows the constrained kriging predictions on
# the orginal scale
# function ck.colors(n) create a rainbow-like color vector
breaks <- seq(0, 1850, by = 185)
spplot(CK$object,zcol="Zn",at=breaks,col.regions=ck.colors(10),
colorkey=list(labels=list(at=breaks,labels=breaks)))
# plot of the factor to get the upper bound of the
97.5
breaks=seq(1,3.2,by=0.2)
spplot(CK$object,zcol="U",at=breaks,col.regions=ck.colors(11),
colorkey=list(labels=list(at=breaks,labels=breaks)))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.