Learn R Programming

sptotal (version 1.0.1)

sv: 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, ...)

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)

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.

Examples

Run this code
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")

Run the code above in your browser using DataLab