Title: | Testing Spatial Dependence Using Empirical Variogram |
---|---|
Description: | Applying Monte Carlo permutation to generate pointwise variogram envelope and checking for spatial dependence at different scales using permutation test. Empirical Brown's method and Fisher's method are used to compute overall p-value for hypothesis test. |
Authors: | Craig Wang [aut, cre] , Reinhard Furrer [ctb] |
Maintainer: | Craig Wang <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3-1 |
Built: | 2024-10-23 06:42:43 UTC |
Source: | CRAN |
Applying Monte Carlo permutation to generate pointwise variogram envelope and checking for spatial dependence at different scales using permutation test. Empirical Brown's method and Fisher's method are used to compute overall p-value for hypothesis test.
Package: | variosig |
Type: | Package |
Version: | 0.3-1 |
Date: | 2020-02-08 |
License: | GPL (>= 3) |
LazyLoad: | yes |
Craig Wang [email protected]
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.
## 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, ...)
## 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, ...)
vario |
variogram of class |
data |
an object of class |
locations |
matrix. Contains x-coordinates in the first column and y-coordinates in the second column. |
formula |
only works with |
trend |
only works with |
cluster |
logical. If |
n.cluster |
integer. The number of clusters used in the permutation. Only used when |
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 |
... |
any other arguments that will be passed to variogram computation using either |
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.
A list with the following elements:
data |
contains a list of all permutated data, only exists if |
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 |
Craig Wang, Reinhard Furrer
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)
envplot
to plot an empirical variogram based on the data and its envelope
## 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)
## 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)
Plot empirical variogram and its pointwise variogram envelope.
envplot(envlist, shade = TRUE, shade.color = "lightgrey", show.variance = FALSE, xlim = NULL, ylim = NULL, main = NULL, xlab = "Distance", ylab = "Semivariance")
envplot(envlist, shade = TRUE, shade.color = "lightgrey", show.variance = FALSE, xlim = NULL, ylim = NULL, main = NULL, xlab = "Distance", ylab = "Semivariance")
envlist |
output from |
shade |
logical. If |
shade.color |
string. Color of the envelope if it is shaded. |
show.variance |
logical. Plot horizontal lines showing the sample variance and its confidence interval of residuals ignoring spatial information. |
xlim , ylim
|
x-axis and y-axis range. If |
main |
string. Title of the plot. |
xlab , ylab
|
string. Labels for x- and y-axis. |
Nothing is returned, generates a plot.
Craig Wang
envelope
to use Monte Carlo permutations for generating variogram envelope.
## Not run: library(sp) data(meuse) coordinates(meuse) = ~x+y vario0 <- gstat::variogram(log(zinc)~1, meuse) varioEnv <- envelope(vario0, data = meuse, formula = log(zinc)~1, nsim = 499) envplot(varioEnv) ## End(Not run)
## Not run: library(sp) data(meuse) coordinates(meuse) = ~x+y vario0 <- gstat::variogram(log(zinc)~1, meuse) varioEnv <- envelope(vario0, data = meuse, formula = log(zinc)~1, nsim = 499) envplot(varioEnv) ## End(Not run)
Determine the significance of spatial dependence at different scales using pointwise variogram envelope based on permutation test.
envsig(envlist, index = NULL, method = c("eb", "fisher", "min"))
envsig(envlist, index = NULL, method = c("eb", "fisher", "min"))
envlist |
output from |
index |
integer. Indicating the index which the permutation test for spatial dependence is performed up to. For example, |
method |
string. One of p-value combination methods. |
The default and preferred method for computing overall p-value is "eb" (empirical Brown's method), which has good power and close to nominal type I error rate. "fisher" (Fisher's method assumes independent pointwise p-values and requires higher sample size to achieve good power. "min" has the highest power but also much higher type I error rate.
A list contains:
p.pointwise |
Adjusted pointwise p-values. |
p.overall |
Overall p-value of the permutation test. |
Craig Wang
Walker, D. D., J. C. Loftis, and J. P. W. Mielke (1997). Permutation methods for determining the significance of spatial dependence. Mathematical Geology 29(8), 1011–1024.
Fisher R. A. (1932). Statistical methods for research workers, 4th ed. Oliver & Boyd.
Poole, W., D. L. Gibbs, I. Shmulevich, B. Bernard, and T. A. Knijnenburg (2016). Combining dependent P-values with an empirical adaptation of Brown’s method. Bioinformatics 32(17), 430–436.
Wang, C., Furrer, R. (2018) Monte Carlo Permutation Tests for Assessing Spatial Dependence at Difference Scales. Nonparametric Statistics. (Submitted)
envelope
to use Monte Carlo permutations for generating variogram envelope.
## Not run: library(sp) data(meuse) coordinates(meuse) = ~x+y vario0 <- gstat::variogram(log(zinc)~1, meuse) varioEnv <- envelope(vario0, data = meuse, formula = log(zinc)~1, nsim = 500, cluster = TRUE, n.cluster = 10) envplot(varioEnv) envsig(varioEnv, index = 2, method = "eb") ## End(Not run)
## Not run: library(sp) data(meuse) coordinates(meuse) = ~x+y vario0 <- gstat::variogram(log(zinc)~1, meuse) varioEnv <- envelope(vario0, data = meuse, formula = log(zinc)~1, nsim = 500, cluster = TRUE, n.cluster = 10) envplot(varioEnv) envsig(varioEnv, index = 2, method = "eb") ## End(Not run)