Learn R Programming

GeoModels (version 2.2.2)

GeoVariogram: Empirical semivariogram estimation

Description

Computes an empirical estimate of the semivariogram for spatial, spatio-temporal, and bivariate random fields.

Usage

GeoVariogram(data, coordx, coordy=NULL, coordz=NULL, coordt=NULL,
             coordx_dyn=NULL, cloud=FALSE, distance="Eucl",
             grid=FALSE, maxdist=NULL, neighb=NULL,
             maxtime=NULL, numbins=NULL,
             radius=1, type='variogram', bivariate=FALSE,
             subsample=1, subsample_t=1)

Value

Returns an object of class Variogram. An object of class Variogram is a list containing (at most) the following components:

bins

Spatial distance bins if cloud=FALSE. If cloud=TRUE, all spatial pairwise distances.

bint

Temporal distance bins if cloud=FALSE. If cloud=TRUE, all temporal pairwise distances.

cloud

Logical; TRUE if the variogram cloud is returned, FALSE otherwise.

centers

Centers of the spatial bins.

distance

Type of spatial distance.

lenbins

Number of pairs in each spatial bin.

lenbinst

Number of pairs in each spatio-temporal bin.

lenbint

Number of pairs in each temporal bin.

maxdist

Maximum spatial distance used in the estimation; NULL if not specified.

maxtime

Maximum temporal lag used in the estimation; NULL if not specified.

spacetime_dyn

Logical; TRUE if dynamic coordinates (coordx_dyn) are used.

variograms

Empirical spatial semivariogram.

variogramst

Empirical spatio-temporal semivariogram.

variogramt

Empirical temporal semivariogram.

type

Type of estimated semivariogram.

Arguments

data

A numeric vector of length \(d\) (a single spatial realisation), or an \(n \times d\) matrix (\(n\) iid spatial realisations), or a \(d \times d\) matrix (a single realisation on a regular grid), or a \(d \times d \times n\) array (\(n\) iid realisations on a regular grid), or a \(t \times d\) matrix (a single spatio-temporal realisation), or a \(t \times d \times n\) array (\(n\) iid spatio-temporal realisations), or a \(d \times d \times t\) array (a single spatio-temporal realisation on a regular grid), or a \(d \times d \times t \times n\) array (\(n\) iid spatio-temporal realisations on a regular grid). See GeoFit for details.

coordx

Spatial coordinates. Either a numeric vector giving the first coordinate, or a \(d \times 2\) (or \(d \times 3\)) matrix of coordinates. If distance refers to great-circle distances, coordinates must be provided in lon/lat format (decimal degrees) and the sphere radius is set by radius.

coordy

A numeric vector giving the second spatial coordinate. Optional, default is NULL.

coordz

A numeric vector giving the third spatial coordinate (if needed). Optional, default is NULL.

coordt

A numeric vector of temporal coordinates. If NULL (default), a purely spatial random field is assumed.

coordx_dyn

A list of \(m\) numeric matrices \(d_t \times 2\) providing time-varying spatial coordinates (dynamic locations). Optional, default is NULL.

cloud

Logical; if TRUE the semivariogram cloud is computed. If FALSE (default), a binned empirical semivariogram is returned.

distance

String specifying the spatial distance. Default is "Eucl" (Euclidean distance). See the Details section of GeoFit.

grid

Logical; if FALSE (default) data are interpreted as observations on irregularly spaced locations. If TRUE, data are interpreted as observations on a regular grid.

maxdist

Numeric; maximum spatial distance to be considered in semivariogram estimation. See Details.

neighb

Numeric; an optional positive integer indicating the order of neighborhood (useful for large datasets). See Details.

maxtime

Numeric; maximum temporal lag to be considered for spatio-temporal semivariograms. See Details.

numbins

Numeric; number of distance bins used to compute the binned semivariogram. See Details.

radius

Numeric; radius of the sphere when using great-circle distances. Default is 1.

type

String; type of semivariogram. Currently available: "variogram".

bivariate

Logical; if FALSE (default) data are interpreted as univariate spatial/spatio-temporal realisations. If TRUE, data is interpreted as a realisation from a bivariate field and (cross-)semivariograms are computed.

subsample

Numeric in \((0,1]\). Proportion of spatial locations to be used to compute the semivariogram (useful for large datasets). Default is 1 (use all locations).

subsample_t

Numeric in \((0,1]\). Proportion of time points to be used in spatio-temporal settings (when coordt is provided). Default is 1 (use all time points).

Details

We report the definition of the semivariogram in the spatial case; extensions to spatio-temporal and bivariate settings are based on the same principles.

For a spatial random field \(Z(\cdot)\), the (classical) binned semivariogram estimator is defined as $$\hat{\gamma}(h) = \frac{1}{2 |N(h)|}\sum_{(x_i,x_j)\in N(h)} \{Z(x_i)-Z(x_j)\}^2,$$ where \(N(h)\) is the set of all sample pairs whose spatial distance falls within a tolerance region around lag \(h\) (equally spaced intervals are used when cloud=FALSE).

The numbins argument sets the number of spatial lag bins used when cloud=FALSE.

The maxdist argument sets the maximum spatial distance considered in the estimation.

The maxdist option can be combined with neighb to reduce the number of pairs when handling large datasets, by restricting computations to local neighborhoods.

The maxtime argument sets the maximum temporal lag considered for spatio-temporal semivariograms.

The subsample and subsample_t arguments provide additional control for large datasets by using only a proportion of spatial locations and/or time points.

References

Cressie, N. A. C. (1993) Statistics for Spatial Data. New York: Wiley.

Gaetan, C. and Guyon, X. (2010) Spatial Statistics and Modeling. Springer-Verlag, New York.

See Also

GeoFit

Examples

Run this code
library(GeoModels)

################################################################
### Example 1. Empirical semivariogram from a spatial Gaussian
### random field with Matérn correlation.
################################################################
set.seed(514)
x = runif(200, 0, 1)
y = runif(200, 0, 1)
coords = cbind(x,y)

corrmodel = "Matern"
mean = 0
sill = 1
nugget = 0
scale = 0.3/3
smooth = 0.5

data = GeoSim(coordx=coords, corrmodel=corrmodel,
              param=list(mean=mean, smooth=smooth, sill=sill,
                         nugget=nugget, scale=scale))$data

vario = GeoVariogram(coordx=coords, data=data, maxdist=0.6)
plot(vario, pch=20, ylim=c(0,1), ylab="Semivariogram", xlab="Distance")

################################################################
### Example 2. Empirical semivariogram for a spatio-temporal
### Gaussian random field with Gneiting correlation.
################################################################
set.seed(331)
x = runif(200, 0, 1)
y = runif(200, 0, 1)
coords = cbind(x,y)
times = seq(1,10,1)

data = GeoSim(coordx=coords, coordt=times, corrmodel="gneiting",
              param=list(mean=0, scale_s=0.08, scale_t=0.4, sill=1,
                         nugget=0, power_s=1, power_t=1, sep=0.5))$data

vario_st = GeoVariogram(data=data, coordx=coords, coordt=times,
                        maxtime=7, maxdist=0.5)
plot(vario_st, pch=20)

################################################################
### Example 3. Empirical (cross-)semivariograms for a bivariate
### Gaussian random field with Bi-Matérn covariance.
################################################################
set.seed(293)
x = runif(400, 0, 1)
y = runif(400, 0, 1)
coords = cbind(x,y)

param = list(mean_1=0, mean_2=0,
             scale_1=0.1/3, scale_2=0.15/3, scale_12=0.15/3,
             sill_1=1, sill_2=1,
             nugget_1=0, nugget_2=0,
             smooth_1=0.5, smooth_12=0.5, smooth_2=0.5,
             pcol=0.3)

data = GeoSim(coordx=coords, corrmodel="Bi_matern", param=param)$data
biv_vario = GeoVariogram(data, coordx=coords, bivariate=TRUE, maxdist=0.5)
plot(biv_vario, pch=20)

Run the code above in your browser using DataLab