Learn R Programming

RandomFields (version 1.0.15)

EmpiricalVariogram: Empirical (Semi-)Variogram

Description

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

Usage

EmpiricalVariogram(x, y=NULL, z=NULL, data, grid, bin, gridtriple=FALSE)

Arguments

x
vector of coordinates
y
vector of coordinates
z
vector of coordinates
data
vector or matrix of data
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

Value

  • The function returns list(centers,emp.vario) where centers are the central points of the bins and emp.vario gives the empirical variogram. Both 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==FALSE): 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 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)
  grid <- TRUE
  gridtriple <- FALSE   ## see help("GaussRF")
  model <- "wh"         ## whittlematern
  alpha <- 2
  mean <- 1
  variance <- 10
  nugget <- 5
  scale <- 2
  method <- "TBM3"
  bins <- seq(0, 5, 0.001)
  repetition <- 20 ## 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, variance, nugget, scale, alpha)
  f <- GaussRF(x=x, y=y, grid=grid, gridtriple=gridtriple,
                  model=model, param=param, meth=method,
                  n=repetition)
  binned <- EmpiricalVariogram(x=x, y=y, data=f,
                 grid=grid, 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