sv: Semi-variogram computation

View source: R/sv.R

svR Documentation

Semi-variogram computation

Description

Compute the empirical semivariogram for a data set with specified x and y spatial coordinates and residuals.

Usage

sv(data, xcoordcol, ycoordcol, residcol, bins = 15, cutoff = NULL, ...)

Arguments

data

A data frame or tibble that contains variables for the x coordinates, y coordinates, and residuals.

xcoordcol

is the name of the column in the data frame with x coordinates or longitudinal coordinates

ycoordcol

is the name of the column in the data frame with y coordinates or latitudinal coordinates

residcol

is the name of the column in the data frame with residuals.

bins

Number of equally spaced semivariogram bins. The default is 15.

cutoff

The maximum spatial distance to be considered. The default is half of the maximum observed distance in the data frame.

...

Additional arguments to be used by stats::dist() for spatial distance calculations.

Value

A data frame with the average distance in each bin (dist), the semivariance (gamma), and the number of unique pairs in each bin (np)

Examples

data(exampledataset) ## load a toy data set
slmobj <- slmfit(formula = counts ~ pred1 + pred2, data = exampledataset,
xcoordcol = 'xcoords', ycoordcol = 'ycoords', areacol = 'areavar')
sampleddataset <- na.omit(exampledataset)
svexample <- data.frame(
  xcoords = sampleddataset$xcoords,
  ycoords = sampleddataset$ycoords,
  resids = residuals(slmobj)
)
svdata <- sv(svexample, "xcoords", "ycoords", "resids")

sptotal documentation built on Dec. 12, 2022, 1:06 a.m.