Learn R Programming

geoR (version 1.2-5)

variog: Compute Empirical Variograms

Description

Computes sample (empirical) variograms with options for the classical or robust estimator. Output can be returned as a binned variogram, a variogram cloud or a smoothed variogram. Data transformation (Box-Cox) is allowed. Trends fitted by ordinary least squares can be removed. In this case variograms are computed using the residuals.

Usage

variog(geodata, coords=geodata$coords, data=geodata$data, 
       uvec = "default", trend = "cte", lambda = 1, 
       option = c("bin", "cloud", "smooth"), 
       estimator.type = c("classical", "modulus"), 
       nugget.tolerance = 0, max.dist = NULL, pairs.min = 2, 
       bin.cloud = FALSE, direction = "omnidirectional",
       tolerance = pi/8, unit.angle = c("radians", "degrees"),
       messages.screen = TRUE, ...)

Arguments

geodata
a list containing element coords as described next. Typically an object of the class "geodata" - a geoR data-set. If not provided the arguments coords must be provided instead.
coords
an $n \times 2$ matrix containing coordinates of the $n$ data locations in each row. Defaults to geodata$coords, if provided.
data
a vector or matrix with data values. If a matrix is provided, each column is regarded as one variable or realization. Defaults to geodata$data, if provided.
uvec
a vector with values defining the variogram binning. Only used when option = "bin". See DETAILS below for more details on how to speficy the bins.
trend
specifies the mean part of the model. See documentation of trend.spatial for further details. Defaults to "cte".
lambda
values of the Box-Cox transformation parameter. Defaults to $1$ (no transformation). If another value is provided the variogram is computed after transforming the data. A case of particular interest is $\lambda = 0$ which corresponds
option
defines the output type: the options "bin" returns values of binned variogram, "cloud" returns the variogram cloud and "smooth" returns the kernel smoothed variogram. Defaults to "bin".
estimator.type
"classical" computes the classical method of moments estimator. "modulus" returns the variogram estimator suggested by Hawkins and Cressie (see Cressie, 1993, pg 75). Defaults to "classical".
nugget.tolerance
a numeric value. Points which are separated by a distance less than this value are considered co-located. Defaults to zero.
max.dist
a numerical value defining the maximum distance for the variogram. Pairs of locations separated for distance larger than this value are ignored for the variogram calculation. Defaults to the maximum distance among the pairs of data locatio
pairs.min
a integer number defining the minimum numbers of pairs for the bins. For option = "bin", bins with number of pairs smaller than this value are ignored. Defaults to NULL.
bin.cloud
logical. If TRUE and option = "bin" the cloud values for each class are included in the output. Defaults to FALSE.
direction
a numerical value for the directional (azimuth) angle. This used to specify directional variograms. Default defines the omnidirectional variogram. The value must be in the interval $[0, 180]$ degrees.
tolerance
numerical value for the tolerance angle, when computing directional variograms. The value must be in the interval $[0, 90]$ degrees. Defaults to $\pi/8$.
unit.angle
defines the unit for the specification of angles in the two previous arguments. Options are "degrees" and "radians".
messages.screen
logical. Indicates whether status messages should be printed on the screen (or output device) while the function is running.
...
arguments to be passed to the function ksmooth, if option = "smooth".

Value

  • An object of the class variogram which is a list with the following components:
  • ua vector with distances.
  • va vector with estimated variogram values at distances given in u.
  • nnumber of pairs in each bin, if option = "bin".
  • sdstandard deviation of the values in each bin.
  • bins.limlimits defining the interval spanned by each bin.
  • ind.bina logical vector indicating whether the number of pairs in each bin is greater or equal to the value in the argument pairs.min.
  • var.markvariance of the data.
  • output.typeechoes the option argument.
  • estimator.typeechoes the type of estimator used.
  • n.datanumber of data.
  • lambdavalue of the transformation parameter.
  • trendtrend specification.
  • nugget.tolerancevalue of the nugget tolerance argument.
  • directiondirection for which the variogram was computed.
  • tolerancetolerance angle for directional variogram.
  • uveclags provided in the function call.
  • callthe function call.

Details

Variograms are widely used in geostatistical analysis for exploratory purposes, to estimate covariance parameters and/or to compare theoretical and fitted models against sample variograms.

Estimators

The two estimators currently implemented are:

  • classical(method of moments) estimator:$$\gamma(h) = \frac{1}{N_h} \sum_{i=1}^{N_h}[Y(x_{(i+h)}) - Y(x_i)]^2$$
  • Hawkins and Cressie'smodulusestimator$$\gamma(h) = [\frac{1}{N_h} \sum_{i=1}^{N_h}|Y(x_{i+h}) - Y(x_i)|^{\frac{1}{2}}]^4$$

Defining the bins

The default If the argument uvec is not provided, the default option is assumed and the bins are defined as follows:

  1. read the argumentmax.dist. If not provided is it set to the maximum distance between a pair of points.
  2. the center of the bins are in initially givenu = seq(0, max.dist, l = 13).
  3. the interval spanned by each bin is given by the mid-points between the centers of the bins.
  4. The center of the first bin is set tou[1] = u[2]/4.

variations on the default The default definition of the bins can be different in some cases.

  1. if there are data points at coincident locations the bins follows the default above but one more bin is added for collocated points (distance zero).
  2. if the argumentnugget.toleranceis provided the separation distance between all pairs in the interval$[0, nugget.tolerance]$are considered to zero. The first element is now set to zerou[1] = 0. The remaining bins follows the default.
  3. if a single number is provided in the argumentuvecthe default sequence size 13 is replaces by this number:u = seq(0, max.dist, l = uvec)
  4. if a vector is provided in the argumentuvec, its elements are taken central points of the bins, this vectors replaces the default sequence

References

Cressie, N.A.C (1993) Statistics for Spatial Data. New York: Wiley. Further information about geoR can be found at: http://www.maths.lancs.ac.uk/~ribeiro/geoR.

See Also

variog4 for more on computation of directional variograms, variog.model.env and variog.mc.env for variogram envelopes, variofit for variogram based parameter estimation and plot.variogram for graphical output.

Examples

Run this code
# Loading data:
if(is.R()) data(s100)
#
# computing variograms:
#
# binned variogram
vario.b <- variog(s100, max.dist=1)
# variogram cloud
vario.c <- variog(s100, max.dist=1, op="cloud")
#binned variogram and stores the cloud
vario.bc <- variog(s100, max.dist=1, bin.cloud=TRUE)
# smoothed variogram
vario.s <- variog(s100, max.dist=1, op="sm", band=0.2)
#
#
# plotting the variograms:
par(mfrow=c(2,2))
plot(vario.b, main="binned variogram") 
plot(vario.c, main="variogram cloud")
plot(vario.bc, bin.cloud=TRUE, main="clouds for binned variogram")  
plot(vario.s, main="smoothed variogram") 

# computing a directional variogram
vario.0 <- variog(s100, max.dist=1, dir=0, tol=pi/8)
plot(vario.b, type="l", lty=2)
lines(vario.0)
legend(0, 1.2, legend=c("omnidirectional", expression(0 * degree)), lty=c(2,1))

Run the code above in your browser using DataLab