Package 'variosig'

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-11-22 06:49:31 UTC
Source: CRAN

Help Index


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.

Details

Package: variosig
Type: Package
Version: 0.3-1
Date: 2020-02-08
License: GPL (>= 3)
LazyLoad: yes

Author(s)

Craig Wang [email protected]


Generate Pointwise Variogram Envelope

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

## 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

## 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 Envelope

Description

Plot empirical variogram and its pointwise variogram envelope.

Usage

envplot(envlist, shade = TRUE, shade.color = "lightgrey",
        show.variance = FALSE, xlim = NULL, ylim = NULL,
        main = NULL, xlab = "Distance", ylab = "Semivariance")

Arguments

envlist

output from envelope function.

shade

logical. If TRUE, the envelope is shaded.

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 NULL, default values are chosen.

main

string. Title of the plot.

xlab, ylab

string. Labels for x- and y-axis.

Value

Nothing is returned, generates a plot.

Author(s)

Craig Wang

See Also

envelope to use Monte Carlo permutations for generating variogram envelope.

Examples

## 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 Significance of Spatial Dependence Using Pointwise Variogram Envelope

Description

Determine the significance of spatial dependence at different scales using pointwise variogram envelope based on permutation test.

Usage

envsig(envlist, index = NULL, method = c("eb", "fisher", "min"))

Arguments

envlist

output from envelope function.

index

integer. Indicating the index which the permutation test for spatial dependence is performed up to. For example, index = 2 indicates only the first two variogram estimates are considered in the hypothesis test, i.e. null hypothesis is there is no spatial dependence at small scales. If NULL, all variogram estimates are considered, which corresponds to the null hypothesis of no overall spatial dependence.

method

string. One of p-value combination methods.

Details

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.

Value

A list contains:

p.pointwise

Adjusted pointwise p-values.

p.overall

Overall p-value of the permutation test.

Author(s)

Craig Wang

References

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)

See Also

envelope to use Monte Carlo permutations for generating variogram envelope.

Examples

## 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)