envelope: Generate Pointwise Variogram Envelope

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/envelope.R

Description

Apply Monte Carlo permutation on the data values over different locations, and compute the variogram estimates for each permutation. The pointwise variogram envelope is taken based on quantiles of variogram estimates at each distance binning.

Usage

1
2
3
4
5
6
7
8
9
## S3 method for class 'gstatVariogram'
envelope(vario, data, locations = coordinates(data),
  formula = NULL, cluster = FALSE, n.cluster = NULL,
  nsim = 999, conf.level = 0.95, save.sim = FALSE, ...)

## S3 method for class 'variogram'
envelope(vario, data, locations = data$coords,
  trend = NULL, cluster = FALSE, n.cluster = NULL,
  nsim = 999, conf.level = 0.95, save.sim = FALSE, ...)

Arguments

vario

variogram of class gstatVariogram from the gstat package or variogram from the geoR package.

data

an object of class SpatialPointsDataFrame if vario is from geoR or class geodata if vario is from gstat.

locations

matrix. Contains x-coordinates in the first column and y-coordinates in the second column.

formula

only works with gstat package, a formula defining the response variable and possible covariates.

trend

only works with geoR package, definng the response variable and possible covariates. See documentation of trend.spatial for further details.

cluster

logical. If TRUE, clustering-based permutation is used. See Details.

n.cluster

integer. The number of clusters used in the permutation. Only used when cluster = TRUE.

nsim

integer. The number of permutations conducted to compute the envelope. The default is 999.

conf.level

confidence level of the envelope. The default is 0.95.

save.sim

logical. If TRUE, save all the permutated data.

...

any other arguments that will be passed to variogram computation using either variogram from gstat package or variog from geoR package.

Details

There are two possible permutation methods implemented. If cluster = FALSE, complete spatial randomness is assumed and values are permuted over all locations. If cluster = TRUE, spatial dependence at small scales is assumed and and values are permuted only within clusters which are determined using kmeans clustering over spatial locations. When the interest is about the existence of spatial dependence at small scales, cluster = TRUE is preferred to acheive a higher statistical power.

Value

A list with the following elements:

data

contains a list of all permutated data, only exists if save.sim=TRUE

variogram

the original variogram estimates and estimates from each of the permutations

upper

upper quantile of the variogram estimates according to the confidence level

lower

lower quantile of the variogram estimates according to the confidence level

data.values

the values used for variogram estimation, namely the residuals after removing covariates' effect

variogram0

the original variogram supplied via vario argument

Author(s)

Craig Wang, Reinhard Furrer

References

Diggle, P.J., Ribeiro, P.J. (2007), Model-Based Geostatistics, Springer Series in Statistics. Springer.

Wang, C., Furrer, R. (2018) Monte Carlo Permutation Tests for Assessing Spatial Dependence at Difference Scales. Nonparametric Statistics. (Submitted)

See Also

envplot to plot an empirical variogram based on the data and its envelope

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
library(sp)
data(meuse)

## for gstat variogram

library(gstat)
data(meuse)
coordinates(meuse) = ~x+y
vario0 <- gstat::variogram(log(zinc)~1, meuse)
varioEnv <- envelope(vario0, data = meuse,
  formula = log(zinc)~1, nsim = 499, cluster = TRUE, n.cluster = 10)

## for geoR variog

library(geoR)
data(meuse)
meuse <- as.geodata(meuse, coords.col = 1:2, data.col = 6, covar.col = 3:5)
meuse$data <- log(meuse$data)
vario0 <- variog(meuse,max.dist=1500)
varioEnv <- envelope(vario0, data = meuse,
  trend = trend.spatial(~lead, meuse), nsim = 499)

## End(Not run)

variosig documentation built on Feb. 10, 2020, 1:06 a.m.