Learn R Programming

spatialwarnings (version 1.2)

generic_sews: Generic Spatial Early-Warning signals

Description

Computation, significance assesment and display of spatial generic early warning signals (Moran's I, variance and skewness)

Usage

generic_sews(mat, subsize = 4, abs_skewness = FALSE,
  moranI_coarse_grain = FALSE)

# S3 method for generic_sews indictest(x, nperm = 999, ...)

# S3 method for generic_sews_test plot(x, along = NULL, what = "value", display_null = TRUE, ...)

# S3 method for generic_sews plot(x, along = NULL, ...)

Arguments

mat

A matrix (quantitative data), a binary matrix (TRUE/FALSE data), or a list of those

subsize

The subsize used for the coarse-graining phase (see Details)

abs_skewness

Should the absolute skewness be used instead of its raw values ?

moranI_coarse_grain

Should the input matrix be coarse-grained before computing the Moran's I indicator value ?

x

A generic_sews object (as provided by the generic_sews function).

nperm

The number of replicates to use to compute a null distribution

...

Additional arguments passed onto methods

along

A vector providing values over which the indicator trend will be plotted. If NULL then the values are plotted sequentially in their original order.

what

The trendline to be displayed. Defaults to the indicator's values ("value") but other metrics can be displayed. Correct values are "value", "pval" or "z_score".

display_null

Chooses whether a grey ribbon should be added to reflect the null distribution. Note that it can not be displayed when the trend line reflects something else than the indicator values (when what is not set to "value").

Value

generic_sews returns an object of class generic_sews_single (actually a list) if mat is a single matrix or an object of class generic_sews_list if mat is a list.

indictest returns an object of class generic_test (actually a data.frame).

plot methods return ggplot objects, usually immediately displayed when used interactively.

Details

The Generic Early warning signal are based on the property of a dynamical system to "slow down" when approaching a critical point, that is take more time to return to equilibrium after a perturbation. This is expected to be reflected in several spatial characteristics: the variance, the spatial autocorrelation (at lag-1) and the skewness. This function provides a convenient workflow to compute these indicators, assess their significance and display the results.

Before computing the actual indicators, the matrix can be "coarse-grained". This process reduces the matrix by averaging the nearby cells using a square window defined by the subsize parameter. This makes spatial variance and skewness reflect actual spatial patterns when working with binary (TRUE/FALSE data), but is optional when using continous data. Keep in mind that it effectively reduces the size of the matrix by approximately subsize on each dimension.

The significance of generic early-warning signals can be estimated by reshuffling the original matrix (function indictest). Indicators are then recomputed on the shuffled matrices and the values obtained are used as a null distribution. P-values are obtained based on the rank of the observered value in the null distribution. A small P-value means that the indicator is significantly above the null values, as expected before a critical point.

The plot method can displays the results graphically. A text summary can be obtained using the summary method.

Note that the produced plot is adjusted depending on whether along is numeric or not.

References

Kefi, S., Guttal, V., Brock, W.A., Carpenter, S.R., Ellison, A.M., Livina, V.N., et al. (2014). Early Warning Signals of Ecological Transitions: Methods for Spatial Patterns. PLoS ONE, 9, e92097.

Dakos, V., van Nes, E. H., Donangelo, R., Fort, H., & Scheffer, M. (2010). Spatial correlation as leading indicator of catastrophic shifts. Theoretical Ecology, 3(3), 163-174.

Guttal, V., & Jayaprakash, C. (2008). Spatial variance and spatial skewness: leading indicators of regime shifts in spatial ecological systems. Theoretical Ecology, 2(1), 3-12.

See Also

indicator_moran, indicator_variance and indicator_skewness for individual indicators.

Examples

Run this code
# NOT RUN {
data(serengeti)
gen_indic <- generic_sews(serengeti, subsize = 5, 
                           moranI_coarse_grain = TRUE)

# Display results
summary(gen_indic)

# Display trends along the varying model parameter
plot(gen_indic, along = serengeti.rain)

# Compute significance (long)
# }
# NOT RUN {
gen_test <- indictest(gen_indic)

print(gen_test)

# Display the trend, now with a grey ribbon indicating the 5%-95% quantile
# range of the null distribution
plot(gen_test, along = serengeti.rain)

# Display the effect size compared to null distribution 
plot(gen_test, along = serengeti.rain, what = "z_score")

# Note that plot() method returns a ggplot object that can be modified
# for convenience
if ( require(ggplot2) ) { 
  plot(gen_test, along = serengeti.rain) + 
    geom_vline(xintercept = 593, color = "red", linetype = "dashed") +
    xlab('Annual rainfall') + 
    theme_minimal()
}

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab