Description Usage Arguments Details Value Author(s) References See Also Examples
The function computes simple or ordinary (tapered) kriging, in addition, for a set of unknown spatial location sites and temporal instants and a given space or space-time covariance model, it computes the Kriging variance.
1 2 3 |
data |
A d-dimensional vector (a single spatial realisation) or a (d x d)-matrix (a single spatial realisation on regular grid) or a (t x d)-matrix (a single spatial-temporal realisation) or an (d x d x t)-array (a single spatial-temporal realisation on regular grid) giving the data used for prediction. |
coordx |
A numeric (d x 2)-matrix (where
|
coordy |
A numeric vector giving 1-dimension of
spatial coordinates used for prediction; |
coordt |
A numeric vector giving 1-dimension of
temporal coordinates used for prediction; the default is |
corrmodel |
String; the name of a correlation model, for the description see the Section Details. |
distance |
String; the name of the spatial distance. The default
is |
grid |
Logical; if |
loc |
A numeric (n x 2)-matrix (where
|
maxdist |
Numeric; an optional positive value indicating the maximum spatial compact support in the case of covariance tapering kriging. |
maxtime |
Numeric; an optional positive value indicating the maximum temporal compact support in the case of covariance tapering kriging. |
param |
A list of parameter values required for the correlation model.See the Section Details. |
taper |
String; the name of the taper correlation function, see the Section Details. |
tapsep |
Numeric; an optional value indicating the separabe parameter in the space time quasi taper (see Details). |
time |
A numeric (m x 1) vector (where
|
type |
String; if |
type_krig |
String; the type of kriging. If |
For a spatial or spatio-temporal dataset, given a set of locations and
temporal istants and a correlation model
corrmodel
with some fixed parameters, the function computes
simple or ordinary kriging, for the specified spatial locations
loc
and temporal instants time
,
providing also the respective standard error.
For the choice of the spatial or spatio temporal correlation model see details in Covmatrix
function.
The parameter param
specifies the covariance parameters, see
CorrelationParam
and Covmatrix
for details.
The type_krig
parameter indicates the type of kriging. In the
case of simple kriging, the known mean can be specified by the parameter
mean
within list param
(See examples).
In addition, it is possible to perform kriging based on covariance
tapering for simple kriging (Furrer et. al, 2008).
In this case, space or space-time tapered function and spatial or spatio- temporal compact support
must be specified. For the choice of a space or space-time tapered function see Covmatrix
.
When performing kriging with covariance tapering,
sparse matrix algorithms are exploited using the package spam
.
Returns an object of class Kg
.
An object of class Kg
is a list containing
at most the following components:
coordx |
A d-dimensional vector of spatial coordinates used for prediction; |
coordy |
A d-dimensional vector of spatial coordinates used for prediction; |
coordt |
A t-dimensional vector of temporal coordinates used for prediction; |
corrmodel |
String: the correlation model; |
covmatrix |
The covariance matrix if |
data |
The vector or matrix or array of data used for prediction |
distance |
String: the type of spatial distance; |
grid |
|
loc |
A (n x 2)-matrix of spatial locations to be predicted. |
nozero |
In the case of tapered simple kriging the percentage of non zero values in the covariance matrix. Otherwise is NULL. |
numcoord |
Numeric:he number d of spatial coordinates used for prediction; |
numloc |
Numeric: the number n of spatial coordinates to be predicted; |
numtime |
Numeric: the number d of the temporal instants used for prediction; |
numt |
Numeric: the number m of the temporal instants to be predicted; |
param |
Numeric: The covariance parameters; |
pred |
A (n x m)-matrix of spatio or spatio temporal kriging prediction; |
spacetime |
|
tapmod |
String: the taper model if |
time |
A m-dimensional vector of temporal coordinates to be predicted; |
type |
String: the type of kriging (Standard or Tapering). |
type_krig |
String: the type of kriging (Simple or Ordinary). |
varpred |
A (n x m)-matrix of spatio or spatio temporal variance kriging prediction; |
Simone Padoan, simone.padoan@unibocconi.it, http://faculty.unibocconi.it/simonepadoan; Moreno Bevilacqua, moreno.bevilacqua@uv.cl, https://sites.google.com/a/uv.cl/moreno-bevilacqua/home.
Padoan, S. A. and Bevilacqua, M. (2015). Analysis of Random Fields Using CompRandFld. Journal of Statistical Software, 63(9), 1–27.
Gaetan, C. and Guyon, X. (2010) Spatial Statistics and Modelling. Spring Verlang, New York. Furrer R., Genton, M.G. and Nychka D. (2006). Covariance Tapering for Interpolation of Large Spatial Datasets. Journal of Computational and Graphical Statistics, 15-3, 502–523.
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | library(CompRandFld)
library(fields)
################################################################
############### Example of Spatial kriging ####################
################################################################
# Define the spatial-coordinates of the points:
x <- runif(50, 0, 1)
y <- runif(50, 0, 1)
# Set the model's parameters:
corrmodel <- "exponential"
mean<-0
sill<-1
nugget<-0
scale<-0.5
param<-list(mean=mean,sill=sill,nugget=nugget,scale=scale)
# spatial matrix location sites
coords<-cbind(x,y)
# Simulation of the spatial Gaussian random field:
set.seed(3132)
data <- RFsim(coordx=coords, corrmodel=corrmodel,
param=param)$data
start<-list(scale=scale,sill=sill)
fixed<-list(mean=mean,nugget=nugget)
# Maximum likelihood fitting :
fit <- FitComposite(data, coordx=coords, corrmodel=corrmodel,
likelihood='Full', type='Standard',
start=start,fixed=fixed)
# locations to predict
xx<-seq(0,1,0.02)
loc_to_pred<-as.matrix(expand.grid(xx,xx))
################################################################
###
### Example 1. Spatial simple kriging of n sites of a
### Gaussian random fields with exponential correlation.
###
###############################################################
pr<-Kri(loc=loc_to_pred,coordx=coords,corrmodel=corrmodel,
param= as.list(c(fit$param,fit$fixed)), data=data)
################################################################
###
### Example 2. Spatial tapered simple kriging of n sites of a
### Gaussian random fields with exponential correlation.
###
###############################################################
##pr_tap<-Kri(loc=loc_to_pred,coordx=coords,corrmodel=corrmodel,data=data,
## param= as.list(c(fit$param,fit$fixed)),type="Tapering",
## maxdist=0.15,taper="Wendland1")
##colour <- rainbow(100)
##par(mfrow=c(2,2))
# simple kriging map prediction
##image.plot(xx, xx, matrix(pr$pred,ncol=length(xx)),col=colour,
## xlab="",ylab="",main="Simple Kriging")
# simple kriging map prediction variance
##image.plot(xx, xx, matrix(pr$varpred,ncol=length(xx)),col=colour,
## xlab="",ylab="",main="Std error")
# simple tapered kriging map prediction
##image.plot(xx, xx, matrix(pr_tap$pred,ncol=length(xx)),col=colour,
## xlab="",ylab="",main="Simple Tapered Kriging")
# simple taperd kriging map prediction variance
##image.plot(xx, xx, matrix(pr_tap$varpred,ncol=length(xx)),col=colour,
## xlab="",ylab="",main="Std error")
################################################################
########### Examples of Spatio-temporal kriging ###############
################################################################
# Define the spatial-coordinates of the points:
x <- runif(15, 0, 1)
y <- runif(15, 0, 1)
coords<-cbind(x,y)
times<-1:7
# Define the times to predict
times_to_pred<-8:10
# Define model correlation and associated parameters
corrmodel<-"exp_exp"
param<-list(nugget=0,mean=1,scale_s=1,scale_t=2,sill=2)
# Simulation of the space time Gaussian random field:
set.seed(31)
data<-RFsim(coordx=coords,coordt=times,corrmodel=corrmodel,
param=param)$data
# Maximum likelihood fitting of the space time random field:
start <- list(scale_s=1,scale_t=2,sill=2)
fixed <- list(mean=1,nugget=0)
fit <- FitComposite(data, coordx=coords, coordt=times,
corrmodel=corrmodel, likelihood='Marginal',
type='Pairwise',start=start,fixed=fixed,
maxdist=0.5,maxtime=3)
################################################################
###
### Example 3. Spatio temporal simple kriging of n locations
### sites and m temporal instants for a Gaussian random fields
### with estimated double exponential correlation.
###
###############################################################
param<-as.list(c(fit$param,fit$fixed))
pr<-Kri(loc=loc_to_pred,time=times_to_pred,coordx=coords,coordt=times,
corrmodel=corrmodel, param=param,data=data)
par(mfrow=c(3,2))
colour <- rainbow(100)
for(i in 1:3){
image.plot(xx, xx, matrix(pr$pred[i,],ncol=length(xx)),col=colour,
main = paste("Kriging Time=" , i),ylab="")
image.plot(xx, xx, matrix(pr$varpred[i,],ncol=length(xx)),col=colour,
main = paste("Std error Time=" , i),ylab="")
}
################################################################
###
### Example 4. Spatio temporal tapered simple kriging of n locations
### sites and m temporal instants for a Gaussian random fields
### with estimated double exponential correlation.
###
###############################################################
#pr_tap<-Kri(loc=loc_to_pred,time=times_to_pred,coordx=coords,coordt=times,
# corrmodel=corrmodel, param=param,type="Tapering",maxdist=0.4,maxtime=4,
# taper="Wendland2_Wendland2",data=data)
#par(mfrow=c(3,2))
#for(i in 1:3){
#image.plot(xx, xx, matrix(pr_tap$pred[i,],ncol=length(xx)),col=colour,
# main = paste("Tapered Kriging Time=" , i),ylab="")
#image.plot(xx, xx, matrix(pr_tap$varpred[i,],ncol=length(xx)),col=colour,
# main = paste("Tapered Std error Time=" , i),ylab="")
#}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.