pkern_vario_fun: Theoretical variogram function

View source: R/pkern_sample.R

pkern_vario_funR Documentation

Theoretical variogram function

Description

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

Usage

pkern_vario_fun(pars, d = NULL)

Arguments

pars

list of the form returned by pkern_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 v is Var( Z(s1) - Z(s2) ), where s1 and s2 are a pair of spatial locations, and Z is the spatial process value. pkern assumes that Z is second-order stationary, which means that v only depends on the relative displacement s1-s2. v in this case is equal to twice the covariance function. pkern_vario_fun computes the covariance function as the sum of eps and psill times 1 minus the correlation function for the supplied distances.

NOTE: v is twice the semi-variogram, usually denoted by greek letter gamma. Variogram v 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 covariance function by 2, returning the variogram v (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

Examples

# set up example grid and parameters
gdim = c(10, 15)
d_max = sqrt(sum(gdim^2))
pars = pkern_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 = pkern_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 = pkern_vario_fun(pars, d=d_test)
lines(d_test, vario_lims[,1])
lines(d_test, vario_lims[,2])


deankoch/pkern documentation built on Oct. 26, 2023, 8:54 p.m.