asreml.variogram | R Documentation

## Empirical variogram from gridded or irregular data

### Description

Calculates the empirical variogram from regular or irregular two dimensional data.

### Usage

    asreml.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 corrdinates 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` | 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 identified as quadrants 1 and 4.
`model` | can only be "empirical" at present
`metric` | 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) specifies a regular grid.

### Details

For one dimensional data the y coordinates need not be supplied and a vector of ones is generated. The function identifies 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.

### Author(s)

David Butler

### References

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

### See Also

`variogram.asreml`

### Examples

    data(barley,package="asreml3")
    ba.asr <- asreml(yield ~ Variety, rcov = ~ ar1(Row):ar1(Column),
                     data=barley)
    vv <- asreml.variogram(cbind(barley$Row,barley$Column,resid(ba.asr)))