distOutlier: Outlier Mahalanobis Distances

View source: R/accessory_geo.R

distOutlierR Documentation

Outlier Mahalanobis Distances

Description

Outlier Mahalanobis Distances

Usage

distOutlier(
  lon,
  lat,
  method = "robust",
  n.min = 10,
  digs = 3,
  probs = c(0.5, 0.75, 0.9, 0.95, 0.975, 0.99, 1)
)

Arguments

lon

numerical. Longitude in decimal degrees

lat

numerical. Latitude in decimal degrees

method

character. Type of method desired: 'classic' or 'robust'

n.min

numerical. Minimum number of unique coordinates to be used in the calculations. Default to 10

digs

numerical. Number of digits to be returned after the decimal point. Default to 4

probs

numerical. Vector of probabilities between 0 and 1 to calculate the sample quantiles. Default to c(0.5, 0.75, 0.9, 0.95, 0.975, 0.99, 100)

Details

The function returns the quantiles of the Mahalanobis distances for the spatial outliers detected automatically, which can be used in the decision making of the more appropriated distance cutoffs to flag spatial outliers.

The automatic detection of spatial outliers is based on an adjusted threshold of the Mahalanobis distances based on function arw() from package mvoutlier.

If the number of unique coordinates is below n.min or if the Minimum Covariance Determinant (MCD) estimator has issues, the function returns NAs. See the help of function mahalanobisDist() for details on the other parameters.

Value

the number of unique coordinates ('n'), the number of outliers detected ('n.out') and the sample quantiles ('qt') of the Mahalanobis distances.

Author(s)

Renato A. Ferreira de Lima

See Also

mahalanobisDist.

Examples

set.seed(123)
lon <- runif(100, -45, -35)
lat <- runif(100, -35, -25)

## Not run: 
distOutlier(lon, lat, method = "classic") # no outliers found...
distOutlier(lon, lat, method = "robust")

# adding some noise
lat[1:5] <- lat[1:5] + runif(5, 10, 20)
lon[96:100] <- lon[96:100] + runif(5, 10, 20)

distOutlier(lon, lat, method = "classic") # quantiles found for 10 outliers
distOutlier(lon, lat, method = "robust")

## End(Not run)


LimaRAF/plantR documentation built on Jan. 1, 2023, 10:18 a.m.