Kri {CompRandFld}R Documentation

Spatial and spatio temporal simple and ordinary (tapered) kriging

Description

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.

Usage

Kri(data, coordx, coordy=NULL, coordt=NULL, corrmodel,distance="Eucl",
    grid=FALSE, loc, maxdist=NULL, maxtime=NULL, param, taper=NULL,
    tapsep=NULL, time=NULL, type="Standard",type_krig="Simple")

Arguments

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 d is the number of spatial sites) giving 2-dimensions of spatial coordinates or a numeric d-dimensional vector giving 1-dimension of spatial coordinates used for prediction.

coordy

A numeric vector giving 1-dimension of spatial coordinates used for prediction; coordy is interpreted only if coordx is a numeric vector or grid=TRUE otherwise it will be ignored. Optional argument, the default is NULL then coordx is expected to be numeric a (d x 2)-matrix.

coordt

A numeric vector giving 1-dimension of temporal coordinates used for prediction; the default is NULL then a spatial random field is expected.

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 Eucl, the euclidean distance. See the Section Details of FitComposite.

grid

Logical; if FALSE (the default) the data used for prediction are interpreted as spatial or spatial-temporal realisations on a set of non-equispaced spatial sites (irregular grid).

loc

A numeric (n x 2)-matrix (where n is the number of spatial sites) giving 2-dimensions of spatial coordinates to be predicted.

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 m is the number of temporal instants) giving the temporal instants to be predicted; the default is NULL then only spatial prediction is performed.

type

String; if standard then standard kriging is performed;if Tapering then kriging with covariance tapering is performed.

type_krig

String; the type of kriging. If Simple (the default) then simple kriging is performed. If ordinary then ordinary kriging is performed. (See the Section Details).

Details

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.

Value

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 type is Standard. An object of class spam if type is Tapering

data

The vector or matrix or array of data used for prediction

distance

String: the type of spatial distance;

grid

TRUE if the spatial data used for prediction are observed in a regular grid, otherwise FALSE;

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

TRUE if spatio-temporal kriging and FALSE if spatial kriging;

tapmod

String: the taper model if type is Tapering. Otherwise is NULL.

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;

Author(s)

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.

References

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.

See Also

Covmatrix

Examples


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="")
#}

[Package CompRandFld version 1.0.3-6 Index]