.\" -*- nroff -*- generated from .Rd format
.BG
.FN variog
.TL
Compute Empirical Variograms
.DN
Computes sample (empirical) variograms using either 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 and, in this case,  variogram for the residuals are computed.
.CS

variog(geodata, coords=geodata$coords, data=geodata$data, 
       uvec = "default", trend = "cte", lambda = 1, 
       option = c("bin", "cloud", "smooth"), 
       estimator.type = c("classical", "robust"), 
       nugget.tolerance = 0, max.dist = NULL, pairs.min = 2, 
       bin.cloud = FALSE, ...) 

.RA
.AG geodata
a list containing elements `coords' and
`$data' described below. If not provided the arguments
`coords' and `data' must be provided instead.
.AG coords
an n x 2 matrix containing
coordinates of the n data locations in each row.
Defaults to `geodata$coords', if provided.
.AG 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.
.AG uvec
a vector with values defining the variogram binning when
`option = "bin"'. The values of `uvec' defines the middle
points of the bins.
.br
If uvec[1] > 0 the first bin is: 0 < u <= uvec[2] - 0.5*(uvec[2] - uvec[1]).
.br
If uvec[1] = 0 first bin is: 0 < u <= 0.5*uvec[1] and
uvec[1] is replaced by the midpoint of this interval.
.AG trend
defines the mean part of the model (or trend).
The default is `"cte"' implying constant mean. Other
options are `"1st"' (trend is a first degree polynomial on the
coordinates), `"2nd"' (trend is a second degree polynomial on the
coordinates), or a formula of the type ~X where X is a matrix with
external trend (covariates) measured at data locations.
If trend is different from `"cte"'
a linear model defined by the trend is fitted to the data and
variogram are computed for the residuals.
.AG lambda
Box-Cox transformation parameter. Defaults to 1 (no
transformation) otherwise the variogram is computed for transformed
data. Notice that lambda = 0 implies log-transformation.
.AG option
defines the output type: `bin' returns values of
binned variogram, `cloud' returns the variogram cloud and `
      smooth' returns the kernel smoothed variogram. Defaults to `"bin"'.
.AG estimator.type
`classical' computes the classical method of
moments estimator and `robust' returns the robust variogram
estimator. See Cressie (1993) for the expressions of the estimators.
Defaults to `"classical"'.
.AG nugget.tolerance
a number defining a distance. Distances
between pairs of points lower than this values are set to zero and
the pairs are used to estimate the nugget effect. Defaults to zero.
.AG max.dist
a number defining a distance. Pairs of points
separated for distance greater than this value are ignored in the
variogram calculation. Defaults to the maximum distance
between to points.
.AG pairs.min
a integer number. If `option = "bin"', bins with number of pairs smaller than this
value are ignored. Defaults to {NULL}.
.AG bin.cloud
Logical. If `TRUE' and `option = "bin"' the cloud values for each class are
also included in the output. Defaults to `FALSE'.
.AG \&...
passes arguments to the function `ksmooth', if
`option = "smooth"'.  
.RT
A list with components:
.AG u 
a vector with distances.
.AG v 
a vector with estimated variogram values at distances `u'.
.AG n 
number of pairs in each bin if
`option = "bin"'.  
.AG var.mark 
variance of the data.
.AG output.type 
echoes the `option' argument.  
.AG estimator.type 
echoes the estimator used.  
.AG n.data 
number of data points.  
.AG call 
the function call.  
.SH REFERENCES
Cressie, N.A.C.(1993) Statistics for Spatial Data, Wiley.
.IP "" 
Further information about `geoR/geoS' can be found at:
.br
<URL: http://www.maths.lancs.ac.uk/~ribeiro/geoR.html>
.SA
`variog.env', `olsfit',
`wlsfit', `plot.variogram'.
.EX
# Loading data:
data(s100) # R only

# computing variogram:
#
# 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=T)
# 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=T, main="clouds for binned variogram")  
plot(vario.s, main="smoothed variogram") 

.KW spatial, smooth
.WR
