1. Home
2. ASReml-R 4 Commands
3. asr_variogram – Emperical variogram

# asr_variogram – Emperical variogram

###### Description

asr_varioGram calculates the empirical variogram from regular or irregular one or two dimensional data.

###### Usage
```asr_varioGram(x, y, z, composite = TRUE, model = c("empirical"),
metric = c("euclidean", "manhattan"), angle = 0, angle.tol = 180,
nlag = 20, maxdist = 0.5, xlag = NA, lag.tol = 0.5, grid = TRUE)```
###### Arguments
 `x` Numeric vector of x coordinates, may also be a matrix or data frame with 2 or 3 columns. If `ncol(x)` is 3, the columns are taken to be the x and y coordinates and the response (z), respectively. If `ncol(x)` is 2, the columns are taken to be the x coordinates and the response, respectively. In this case the y coordinates are generated as `rep(1,nrow(x))`. `y` Numeric vector of y coordinates. `z` The response vector. `composite` For data on a regular grid. If `TRUE`, the average of the variograms in quadrants (x,y) and (x,-y) is returned. Otherwise, both variograms are returned and identiﬁed as quadrants 1 and 4. `model` Can only be “`empirical`” at present. `metric` The distance between (x,y) points. Valid measures are “`euclidean`” or “`manhattan`“. `angle` A vector of directions. Angles are measured in degrees anticlockwise from the x axis. Default is 0. `angle.tol` The angle subtended by each direction. That is, an arc `angle+- angle.tol/2`. Default is 180 which gives an omnidirectional variogram. `nlag` The maximum number of lags; default is 20. `maxdist` The fraction of the maximum distance to include in the calculation. The default is half the maximum distance in the data. `xlag` The width of the lags. If missing, `xlag` is set to `maxdist/nlag`. `lag.tol` The distance tolerance. If missing, `lag.tol` is set to `xlag/2`. `grid` If `FALSE`, forces polar variograms if (x,y) speciﬁes a regular grid; default is `TRUE`.
###### Details

For one dimensional data the y coordinates need not be supplied and a vector of ones is generated. The function identiﬁes data on a complete regular array and in such cases only computes polar variograms If `grid = FALSE`. The data is assumed sorted with the x coordinates changing the fastest; the data is sorted internally if this is not the case.

###### Value
 A data frame including the following components: `x` The original x coordinates. `y` The original y coordinates. `gamma` The variogram estimate. `distance` The average distance for pairs in the lag. `np` The number of pairs in the lag. `angle` Direction if not a regular grid.

Webster W and Oliver MA (2001). Geostatistics for Environmental Scientists. John Wiley: West Sussex.