RandomFields (version 2.0.71)

EmpiricalVariogram: Empirical (Semi-)Variogram

Description

EmpiricalVariogram calculates the empirical (semi-)variogram of a random field realisation

Usage

EmpiricalVariogram(x, y=NULL, z=NULL, T=NULL, data, grid, bin,
                   gridtriple=FALSE, phi, theta, deltaT)

Arguments

x
vector of x-coordinates, or matrix
y
vector of y-coordinates
z
vector of z-coordinates
T
vector of time components; here T is given in grid format, see GaussRF.
data
vector or matrix of data; if data has a multiple number of components as expected by the definition of the coordinates then it is assumed that the data stem from repeated, independent measurements at the given locations; the empir
grid
logical; if TRUE then x, y, and z define a grid; otherwise x, y, and z are interpreted as points
bin
vector of ascending values giving the bin boundaries
gridtriple
logical. Only relevant if grid=TRUE. If gridtriple=TRUE then x, y, and z are of the form c(start,end,step); if gridtriple=FALSE then x,
phi
vector of two components. First component gives the angle for the first line of midpoints of an angular variogram. The second component gives the number of directions (on the half circle). The spatial dimension must be at least 2.
theta
vector of two components. First component gives the angle for the first line of midpoints of an angular variogram (angle is zero for the xy-plane). The second component gives the number of directions (on the half circle). The spatial dime
deltaT
vector of two components. First component gives the largest temporal distance; the second component the grid length, that must be a multiple of T[3].

Value

  • The function returns a list:
  • centerscentral points of the bins
  • emp.varioempirical variogram; vector or matrix or array, depending on the anisotropy definitions. The sequence is distances, phi, theta, Tbins. If phi, theta, or Tbins below are not given, the respective dimensions are missing.
  • sdsd of the variogram cloud within each bin
  • n.binnumber of points within a bin
  • phivector of angles in xy plane
  • thetavector of angles in the third dimensions
  • Tbinsvector of temporal distances
  • The first four elements are vectors of length (length(bin)-1).

Details

Comments on specific parameters:
  • data: the number of values must match the number of points (given byx,y,z,grid, andgridtriple). That is, it must equal the number of points or be a multiple of it. In case the number of data equals$n$times the number of points, the data are interpreted as$n$independent realisations for the given set of points.
  • (grid=FALSE): the vectorsx,y, andz, are interpreted as vectors of coordinates
  • (grid=TRUE) && (gridtriple=FALSE): the vectors \ code{x},y, andzare increasing sequences with identical lags for each sequence. A corresponding grid is created (as given byexpand.grid).
  • (grid=TRUE) && (gridtriple=TRUE): the vectorsx,y, andzare triples of the form (start,end,step) defining a grid (as given byexpand.grid(seq(x$start,x$end,x$step), seq(y$start,y$end,y$step), seq(z$start,z$end,z$step)))
  • The bins are left open, right closed intervals, i.e.,$(b_i,b_{i+1}]$for$i=1,\ldots,$length(bin)$-1$. Hence, to include zero,bin[1]must be negative.

See Also

GaussRF, fitvario, and RandomFields

Examples

Run this code
#############################################################
  ## this example checks whether a certain simulation method ##
  ## works well for a specified covariance model and         ##
  ## a configuration of points                               ##
  #############################################################
  x <- seq(0, 10, 0.5)
  y <- seq(0, 10, 0.5)
  gridtriple <- FALSE      ## see help("GaussRF")
  model <- "whittle"       ## whittlematern
  bins <- seq(0, 5, 0.001)
  realisations <- 5 ## by far too small to get reliable results!!
                   ## It should be of order 500, but then it will
                   ## take some time to do the simulations
  param <- c(mean=1, variance=10, nugget=5, scale=2, alpha=2)
  f <- GaussRF(x=x, y=y, grid=TRUE, gridtriple=gridtriple,
               model=model, param=param, method="TBM3",
               n=realisations)
  binned <- EmpiricalVariogram(x=x, y=y, data=f, grid=TRUE,
                               gridtriple=gridtriple, bin=bins)
  truevariogram  <- Variogram(binned$c, model, param)
  matplot(binned$c, cbind(truevariogram,binned$e), pch=c("*","e"))
  ##black curve gives the theoretical values

Run the code above in your browser using DataLab