sk_vario_fun: Theoretical variogram function

View source: R/sk_sample.R

sk_vario_funR Documentation

Theoretical variogram function

Description

Computes the value of the variogram function w, defined by covariance model pars at the component y and x lags supplied in d.

Usage

sk_vario_fun(pars, d = NULL)

Arguments

pars

list of the form returned by sk_pars with entries 'y', 'x', 'eps', 'psill'

d

numeric vector or list with vector entries 'y' and 'x', the distances to evaluate

Details

By definition w is Var( Z(s1) - Z(s2) ), where s1 and s2 are a pair of spatial locations, and Z is the spatial process value. If Z is second-order stationary then w only depends on the relative displacement, s1 - s2 = (dx, dy). snapKrig models the variogram as W = 2 ( eps + psill ( 1 - cy(dy) cx(dx) ) ).

sk_vario_fun evaluates this function using the correlogram functions (cy and cx), partial sill (psill) and nugget (eps) defined in pars, over the displacement (dy and dx) supplied in d.

NOTE: w is twice the semi-variogram, usually denoted by greek letter gamma. Variogram w is therefore often written 2gamma. This can (and does) lead to confusion in the literature about whether to include a factor 2 in downstream calculations. This function multiplies the semi-variogram function by 2, returning the variogram w (ie 2gamma), NOT the semi-variogram.

If d is a list, its 'y' and 'x' components should supply the y and x component distances. These must be equal-length non-negative numeric vectors. The function returns the corresponding variogram values in a vector of the same length.

If d is a numeric vector, it is interpreted as a set of distances at which to evaluate the range of the variogram function. Anisotropic variograms will exhibit a range of values for a given distance (depending on the relative sizes of the x and y components). The function returns this range in a data frame with columns 'min' and 'max'.

Value

data frame (for list d) or numeric vector (for vector d) of variogram values

See Also

sk_pars

Other variogram functions: sk_add_bins()

Examples

# set up example grid and parameters
gdim = c(10, 15)
d_max = sqrt(sum(gdim^2))
pars = sk_pars(gdim, 'mat')

# set up test distances
d_test = seq(0, d_max, length.out=1e2)

# evaluate and plot the variogram values for equal displacements along x and y
d_equal = stats::setNames(rep(list(sqrt(1/2)*d_test), 2), c('y', 'x'))
vario = sk_vario_fun(pars, d=d_equal)
plot(d_test, vario, pch=NA)
lines(d_test, vario, col='blue')

# evaluate and plot the range of variogram values (for all possible x and y displacements)
vario_lims = sk_vario_fun(pars, d=d_test)
lines(d_test, vario_lims[,1])
lines(d_test, vario_lims[,2])


snapKrig documentation built on May 31, 2023, 6:34 p.m.