diff --git a/NAMESPACE b/NAMESPACE index f530b6f3..09f83df8 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -88,13 +88,8 @@ export(extract_spectrum) export(extract_variogram) export(flowlength_sews) export(generic_sews) -export(generic_spews) -export(indicator_moran) export(indicator_plrange) export(indicator_psdtype) -export(indicator_sdr) -export(indicator_skewness) -export(indicator_variance) export(indictest) export(kbdm_sews) export(label) @@ -103,7 +98,6 @@ export(lsw_sews) export(pLSW) export(pair_counts) export(patchdistr_sews) -export(patchdistr_spews) export(patchsizes) export(percolation) export(pl_fit) @@ -125,7 +119,6 @@ export(raw_structvar) export(raw_variogram_metrics) export(rspectrum) export(spectral_sews) -export(spectral_spews) export(tpl_fit) export(variogram_sews) export(xmin_estim) diff --git a/NEWS b/NEWS index da450fd9..7ab9ae33 100644 --- a/NEWS +++ b/NEWS @@ -7,8 +7,8 @@ This release has received external contributions from K. Siteur Improvements: * The type of neighborhood can now be specified in all patch-related functions, - including high-level functions (e.g. patchdistr_sews). Neighborhood can also be - specified using "von_neumann" or "moore", on top of a 3x3 matrix + including high-level functions (e.g. `patchdistr_sews`). Neighborhood can also be + specified using the strings "von_neumann" or "moore", on top of a 3x3 matrix New indicators: @@ -16,9 +16,11 @@ New indicators: * Indicators related to the LSW distribution (Siteur et al. 2023) -Bug fixes: +Bug fixes and misc changes: * Documentation improvements and minor fixes + + * Old defunct functions have been removed spatialwarnings v3.0.3 (Release date: 2022-03-21) ================================================= diff --git a/R/RcppExports.R b/R/RcppExports.R index 55630b30..63516931 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -36,7 +36,7 @@ label_cpp <- function(mat, nbmask, wrap) { #' \code{NaN} is returned. This function assumes a 4-way neighborhood, and does #' not wrap around at the sides of the matrix. #' -#' @seealso \code{\link{indicator_moran}}, \code{\link{generic_sews}} +#' @seealso \code{\link{generic_sews}} #' #' @examples #' diff --git a/R/clustering.R b/R/clustering.R index bf0e9b5e..f8664032 100644 --- a/R/clustering.R +++ b/R/clustering.R @@ -61,6 +61,8 @@ #' print(clust) #' #' # Compute clustering along the gradient for the serengeti dataset +#' \donttest{ +#' #' data(forestgap) #' clust_indic <- compute_indicator(serengeti, raw_clustering, #' wrap = TRUE, use_8_nb = FALSE) @@ -80,6 +82,8 @@ #' # ... or the total count #' pair_counts(serengeti[[5]], prop = FALSE) #' +#' } +#' #'@export raw_clustering <- function(mat, wrap = TRUE, diff --git a/R/deprecation.R b/R/deprecation.R index 5a2b78ef..38975164 100644 --- a/R/deprecation.R +++ b/R/deprecation.R @@ -1,434 +1,4 @@ # -# This file contains deprecated/defunct functions +# Cleaned up for 3.1.0 -> old functions now removed. # -#' @rdname generic_spews-deprecated -#' -#' @title (DEFUNCT) Generic Spatial Early-Warning signals -#' -#' @description Computation, significance assesment and display of spatial -#' generic early warning signals (Moran's I, variance and skewness) -#' -#' @param mat A matrix (quantitative data), a binary matrix (TRUE/FALSE data), -#' or a list of those -#' -#' @param subsize The subsize used for the coarse-graining phase (see Details) -#' -#' @param abs_skewness Should the absolute skewness be used instead of its -#' raw values ? -#' -#' @param moranI_coarse_grain Should the input matrix be coarse-grained before -#' computing the Moran's I indicator value ? -#' -#' @details \code{generic_spews} has been renamed, please use -#' \code{\link{generic_sews}} instead. -#' -#'@export -generic_spews <- function(mat, - subsize = 4, - abs_skewness = FALSE, - moranI_coarse_grain = FALSE) { - .Defunct(new = "generic_sews", package = "spatialwarnings") -} - -#' @rdname patchdistr_spews-deprecated -#' -#' @title (DEFUNCT) Early-warning signals based on patch size distributions -#' -#' @description Compute early-warnings based on -#' patch size distributions and review/plot the results -#' -#' @param x A logical matrix (TRUE/FALSE values) or a list of these -#' -#' @param merge The default behavior is to produce indicators values for each -#' matrix. If this parameter is set to TRUE then the patch size distributions -#' are pooled together for fitting. -#' -#' @param fit_lnorm When patch size distributions are compared, should we -#' consider lognormal type ? (see details) -#' -#' @param best_by The criterion to use to select the best fit (one of "AIC", -#' "BIC" or "AICc") -#' -#' @param xmin The xmin to be used to fit the patch size distributions. Use -#' the special value "estimate" to compute first the xmin that produces -#' the best power-law fit, then use this estimated value to fit all -#' distributions. -#' -#' @param xmin_bounds Bounds when estimating the xmin for power-law distributions -#' -#' @param wrap Determines whether patches are considered to wrap around the -#' matrix when reaching the side -#' -#' @details \code{patchdistr_spews} has been renamed, please use -#' \code{\link{patchdistr_sews}} instead. -#' -#'@export -patchdistr_spews <- function(x, - merge = FALSE, - fit_lnorm = FALSE, - best_by = "BIC", - xmin = 1, # a number, or "estimate" option - xmin_bounds = NULL, - wrap = FALSE) { - .Defunct(new = "patchdistr_sews", package = "spatialwarnings") -} - -#' @rdname spectral_spews-deprecated -#' -#' @title (DEFUNCT) Spectrum-based spatial early-warning signals. -#' -#' @description Computation of spatial early warning signals based on spectral -#' properties. -#' -#' @param mat The input matrix or a list of matrices. -#' -#' @param sdr_low_range The range of values (in proportion) to -#' use for the computation of the spectral density ratio. -#' For example, for the lowest 20% (default value), set sdr_low_range to -#' c(0, .2). See also the Details section. -#' -#' @param sdr_high_range The range of values (in proportion) to -#' use for the computation of the spectral density ratio. For example, for -#' the higher 20% (default value), set sdr_high_range to -#' c(.8, 1). See also the Details section. -#' -#' @param quiet Do not display some warnings -#' -#' @details \code{spectral_spews} has been renamed, please use -#' \code{\link{spectral_sews}} instead. -#' -#'@export -spectral_spews <- function(mat, - sdr_low_range = NULL, - sdr_high_range = NULL, - quiet = FALSE) { - .Defunct(new = "spectral_sews", package = "spatialwarnings") -} - -#' @title (DEFUNCT) Moran's Index at lag of 1 -#' -#' @description This functions computes the Moran's spatial correlation index -#' (with lag one). It also computes a null value obtained by randomizing -#' the matrix. -#' -#' @references -#' -#' 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. -#' -#' Legendre, P., & Legendre, L. F. J. (2012). Numerical Ecology. -#' Elsevier Science. -#' -#' @param input An matrix or a list of matrix object. It should -#' be a square matrix -#' -#' @param subsize logical. Dimension of the submatrix used to coarse-grain the -#' original matrix (set to 1 for no coarse-graining). -#' -#' @param nulln Number of replicates to produce to estimate null -#' distribution of index (default: 999). -#' -#' @return A list (or a list of those if input is a list of matrix -#' object) of: -#' \itemize{ -#' \item `value`: Spatial autocorrelation of the matrix -#' } -#' If nulln is above 2, then the list has the following additional -#' components : -#' \itemize{ -#' \item `null_mean`: Mean autocorrelation of the null distribution -#' \item `null_sd`: SD of autocorrelation in the null distribution -#' \item `z_score`: Z-score of the observed value in the null distribution -#' \item `pval`: p-value based on the rank of the observed autocorrelation -#' in the null distribution. -#' } -#' -#' @examples -#' -#' \dontrun{ -#' data(serengeti) -#' -#' # One matrix -#' indicator_moran(serengeti[[1]]) -#' -#' # Several matrices -#' indicator_moran(serengeti) -#' } -#' -#'@export -indicator_moran <- function(input, - subsize = 1, # default = no cg - nulln = 99) { - .Defunct(new = "compute_indicator(input, f = raw_moran)", - package = "spatialwarnings") -} - -#' @title (DEFUNCT) Skewness indicator -#' -#' @description Compute the spatial skewness of spatial data. -#' It also computes a null value obtained by randomizing -#' the matrix. -#' -#' @param input A matrix or a list of matrices. The matrix -#' values can be logical, with \code{FALSE} (empty) or \code{TRUE} (occupied) -#' values. The entries can also be continuous (like NDVI or EVI data). -#' -#' @param subsize Dimension of the submatrix used to coarse-grain the -#' original matrix. This must be an integer less than size of the full -#' matrix. Coarse-graining reduces the size of the matrix by a factor -#' \code{subsize} in each dimension of the matrix. Skewness is calculated -#' on the coarse-grained matrix. -#' -#' @param absolute Should the function return the absolute value or raw value -#' of skewness ? -#' -#' @param nulln Number of simulations used to produce the null -#' distribution of indicator values. -#' -#' @return A list (or a list of lists if input was a list of matrices) with -#' components: -#' \itemize{ -#' \item `value`: Spatial skewness of the matrix -#' } -#' If nulln is above 2, then the list has the following additional -#' components : -#' \itemize{ -#' \item `null_mean`: Mean skewness of the null distribution -#' \item `null_sd`: SD of skewness in the null distribution -#' \item `z_score`: Z-score of the observed value in the null distribution -#' (value minus the null mean and divided by null -#' standard deviation) -#' \item `pval`: p-value based on the rank of the observed skewness -#' in the null distribution. A low p-value means that -#' the indicator value is significantly higher than the -#' null values. -#' } -#' -#' @details -#' -#' Spatial skewness is a measure of fluctuations in space; specifically, it -#' measures if fluctuations are getting biased (skewed) in one direction. Based -#' on the theory of critical slowing down, when systems approach critical -#' points they are expected to show increased fluctuations in space. Thus, -#' increasing spatial skewness is proposed as an early warning signal of -#' impending critical transitions. -#' -#' Computing spatial skewness is straightforward. However, detecting trends of -#' skewness that correspond to critical slowing down can be tricky, especially -#' if data come from discrete classification of state variable. -#' -#' For example, many high resolution spatial data are classified as FALSE (empty) -#' or TRUE (occupied by plant). In such cases, spatial skewness captures just -#' the skewness in data, but not that of spatial structure. -#' To resolve the issue, this function employs a method called coarse-graining, -#' proposed in Kefi et al (2014), and described in detail in -#' Sankaran et al. (2017). One must specify a subsize above one for -#' binary valued data sets to obtain meaningful values. -#' -#' \code{subsize} has to be an integer. It has to be less than or equal to -#' half of matrix size (N). \code{subsize} must also be preferably a -#' divisor of N. If it is not a divisor of N, the remainder rows and columns -#' are discarded when computing coarse-graining matrices. -#' -#' Null model evaluations are also done on coarse-grained matrices. -#' -#' @references -#' -#' Guttal, V., and Jayaprakash, C. (2009). Spatial variance and -#' spatial skewness: leading indicators of regime shifts in spatial -#' ecological systems. Theoretical Ecology, 2(1), 3-12. -#' -#' 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. -#' -#' Sankaran, S., Majumder, S., Kefi, S., and Guttal, V. (2017). Implication of -#' being discrete and spatial in detecting early warning signals of regime -#' shifts. Ecological indicators. -#' -#' @examples -#' -#' \dontrun{ -#' data(serengeti) -#' indicator_skewness(serengeti) -#' } -#' -#'@export -indicator_skewness <- function(input, - subsize = 5, - absolute = TRUE, - nulln = 99) { - .Defunct(new = "compute_indicator(input, f = raw_cg_skewness)", - package = "spatialwarnings") -} - -#' @title (DEFUNCT) Spatial variance indicator -#' -#' @description This functions computes the spatial variance of spatial data. -#' It also computes a null value obtained by randomizing -#' the matrix. -#' -#' @param input A matrix or a list of matrices. The matrix -#' values can be logical, with \code{FALSE} (empty) or \code{TRUE} (occupied) -#' values. The entries can also be continuous (like NDVI or EVI data). -#' -#' @param subsize Dimension of the submatrix used to coarse-grain the -#' original matrix. This must be an integer less than size of the full -#' matrix. Coarse-graining reduces the size of the matrix by a factor -#' \code{subsize} in each dimension of the matrix. Variance is calculated -#' on the coarse-grained matrix. -#' -#' @param nulln Number of simulations used to produce the null -#' distribution of indicator values. -#' -#' @return A list (or a list of lists if input was a list of matrices) with -#' components: -#' \itemize{ -#' \item `value`: Spatial variance of the matrix -#' } -#' If nulln is above 2, then the list has the following additional -#' components : -#' \itemize{ -#' \item `null_mean`: Mean spatial variance of the null distribution -#' \item `null_sd`: SD of spatial variance in the null distribution -#' \item `z_score`: Z-score of the observed value in the null distribution -#' (value minus the null mean and divided by null -#' standard deviation) -#' \item `pval`: p-value based on the rank of the observed spatial variance -#' in the null distribution. A low p-value means that -#' the indicator value is significantly higher than the -#' null values. -#' } -#' -#' @details -#' -#' Spatial variance is a measure of fluctuations in space. Based on the theory -#' of critical slowing down, when systems approach critical points -#' they are expected to show increased fluctuations in space. Thus, increasing -#' spatial variance is proposed as an early warning signal of impending -#' critical transitions. -#' -#' For example, many high resolution spatial data are classified as FALSE (empty) -#' or TRUE (occupied by plant). In such cases, spatial variance captures just -#' the variance in data, but not that of spatial structure. -#' To resolve the issue, this function employs a method called coarse-graining, -#' proposed in Kefi et al (2014), and described in detail in -#' Sankaran et al. (2017). One must specify a subsize above one for -#' binary valued data sets to obtain meaningful values. -#' -#' \code{subsize} has to be an integer. It has to be less than or equal to -#' half of matrix size (N). \code{subsize} must also be preferably a -#' divisor of N. If it is not a divisor of N, the remainder rows and columns -#' are discarded when computing coarse-graining matrices. -#' -#' Null model evaluations are also done on coarse-grained matrices. -#' -#' @references -#' -#' Guttal, V., and Jayaprakash, C. (2009). Spatial variance and -#' spatial skewness: leading indicators of regime shifts in spatial -#' ecological systems. Theoretical Ecology, 2(1), 3-12. -#' -#' 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. -#' -#' Sankaran, S., Majumder, S., Kefi, S., and Guttal, V. (2017). Implication -#' of being discrete and spatial in detecting early warning signals -#' of regime shifts. Ecological Indicators. -#' -#' @examples -#' -#' data(serengeti) -#' \dontrun{ -#' indicator_variance(serengeti, nulln = 499) -#' } -#' -#'@export -indicator_variance <- function(input, - subsize = 5, - nulln = 99) { - .Defunct(new = "compute_indicator(input, f = raw_cg_variance)", - package = "spatialwarnings") -} - -# -#' @title (DEFUNCT) Density Ratio (SDR) indicator -#' -#' @description Compute the ratio of low frequencies over high frequencies -#' of the r-spectrum. It also computes a null value obtained by -#' randomizing the matrix. -#' -#' @param input A matrix or a logical matrix (TRUE/FALSE), or a list of these. -#' -#' @param sdr_low_range The range of values (in proportion) to -#' use for the computation of the spectral density ratio. -#' For example, for the lowest 20\% (default value), set \code{sdr_low_range} -#' to \code{c(0, .2)}. -#' -#' @param sdr_high_range The range of values (in proportion) to -#' use for the computation of the spectral density ratio. For example, for -#' the highest 20\% (default value), set \code{sdr_high_range} to -#' \code{c(.8, 1)}. -#' -#' @param nulln The number of simulations to compute for the null -#' distribution -#' -#' @return A list (or a list of lists if input was a list of matrices) with -#' components: -#' \itemize{ -#' \item `value`: SDR of the matrix -#' } -#' If nulln is above 2, then the list has the following additional -#' components : -#' \itemize{ -#' \item `null_mean`: Mean SDR of the null distribution -#' \item `null_sd`: SD of SDR in the null distribution -#' \item `z_score`: Z-score of the observed value in the null distribution -#' (value minus the null mean and divided by null -#' standard deviation) -#' \item `pval`: p-value based on the rank of the observed SDR -#' in the null distribution. A low p-value means that -#' the indicator value is significantly higher than the -#' null values. -#' } -#' -#' @details -#' -#' SDR measures the increase in long-range correlations before a critical point. -#' It is the ratio of the average low frequency value over high frequency -#' values. In this implementation, an increase in SDR implies a "reddening" -#' of the \link[=rspectrum]{r-spectrum}. See also \code{\link{spectral_sews}} for -#' a more complete description. -#' -#' Low and high frequencies are averaged in order to compute the SDR. The -#' parameters \code{sdr_low_range} and \code{sdr_high_range} control which -#' frequencies are selected for averaging. For example -#' \code{sdr_low_range = c(0, .2)} (default) uses the lower 20% to compute -#' the average of low frequencies. \code{sdr_high_range = c(.8, 1)} uses the -#' higher 20% for the average of high frequencies. -#' -#' @seealso spectral_sews, rspectrum -#' -#' @references -#' -#' Carpenter, S.R. & Brock, W.A. (2010). Early warnings of regime shifts in -#' spatial dynamics using the discrete Fourier transform. Ecosphere -#' -#' @examples -#' -#' \dontrun{ -#' serengeti.sdr <- indicator_sdr(serengeti, nulln = 499) -#' do.call(rbind, serengeti.sdr) # convert results to data.frame -#' } -#' -#' @export -indicator_sdr <- function(input, - sdr_low_range = NULL, - sdr_high_range = NULL, - nulln = 99) { - .Defunct(new = "compute_indicator(input, f = raw_sdr)", - package = "spatialwarnings") -} diff --git a/R/extra_doc.R b/R/extra_doc.R index 125c2468..2cc2e738 100644 --- a/R/extra_doc.R +++ b/R/extra_doc.R @@ -38,47 +38,47 @@ #' of computations when working with multiple matrices. #' #' A \code{simple_sews_single} object is a list with the following components -#' \itemize{ -#' \code{itemvalue}: the indicator values. A vector of length one if there is +#' \describe{ +#' \item{\code{itemvalue}}{the indicator values. A vector of length one if there is #' only one numeric value returned by the indicator function (e.g. -#' \code{\link{flowlength_sews}}, or with a length above one otherwise -#' \item \code{orig_data}: the original matrix on which the indicator was computed -#' \item \code{fun.args}: the argument used in the call to the indicator function +#' \code{\link{flowlength_sews}}, or with a length above one otherwise} +#' \item{\code{orig_data}}{the original matrix on which the indicator was computed} +#' \item{\code{fun.args}}{the argument used in the call to the indicator function #' (the function that given a matrix, returns the spatial metrics of -#' interest) -#' \item \code{taskname}: a character string describing the current indicator(s) -#' being computed -#' \item \©ode{indicf}: the indicator function, which given the matrix, returns the -#' spatial metric(s) of interest +#' interest)} +#' \item{\code{taskname}}{a character string describing the current indicator(s) +#' being computed} +#' \item{\code{indicf}}{the indicator function, which given the matrix, returns the +#' spatial metric(s) of interest} #' } #' #' \code{simple_sews_test_single} have all of the above components, plus #' the following: #' -#' \itemize{ -#' \item \code{nulldistr}: the null distribution of values, with nulln rows and +#' \describe{ +#' \item{\code{nulldistr}}{the null distribution of values, with nulln rows and #' as many columns as the number of values returned by the indicator -#' function -#' \item \code{null_mean}: the mean indicator values in the null distribution -#' \item \code{null_sd}: the standard deviation of the null distribution -#' \item \code{null_qsup}: the upper quantile of the null distribution, by default +#' function} +#' \item{\code{null_mean}}{the mean indicator values in the null distribution} +#' \item{code{null_sd}}{the standard deviation of the null distribution} +#' \item{\code{null_qsup}}{the upper quantile of the null distribution, by default #' the 95% upper quantile, but see \code{\link{indictest}} for a way to -#' adjust this -#' \item \code{null_qinf}: the upper quantile of the null distribution, by default +#' adjust this} +#' \item{\code{null_qinf}}{the upper quantile of the null distribution, by default #' the 05% upper quantile, but see \code{\link{indictest}} for a way to -#' adjust this -#' \item \code{z_score}: the z_score of the observed value relative to the null -#' distribution, i.e. (value - null_mean) / null_sd -#' \item \code{pval}: the p-value of the indicator, i.e. the proporation of values -#' of the null distribution that fall below the observed indicator value -#' \item \code{null_method}: the method used to produce the null matrices. See -#' \code{\link{indictest}} for details -#' \item \code{nulln}: the number of null matrices used -#' \item \code{get_nullmat}: a function that can be called to obtain a randomized -#' matrix -#' \item \code{matrixn}: the number of the matrix, can be above one if the +#' adjust this} +#' \item{\code{z_score}}{the z_score of the observed value relative to the null +#' distribution, i.e. (value - null_mean) / null_sd} +#' \item{\code{pval}}{the p-value of the indicator, i.e. the proporation of values +#' of the null distribution that fall below the observed indicator value} +#' \item{\code{null_method}}{the method used to produce the null matrices. See +#' \code{\link{indictest}} for details} +#' \item{\code{nulln}}{the number of null matrices used} +#' \item{\code{get_nullmat}}{a function that can be called to obtain a randomized +#' matrix} +#' \item{\code{matrixn}}{the number of the matrix, can be above one if the #' computations have been run on a list of matrices, or non-existent if -#' only one matrix was used +#' only one matrix was used} #' } #' #' @seealso \code{\link{custom_indicator}} diff --git a/R/fitpsd.R b/R/fitpsd.R index 7f86ddbe..da0b51df 100644 --- a/R/fitpsd.R +++ b/R/fitpsd.R @@ -212,22 +212,22 @@ pl_ll <- function(dat, expo, xmin) { #' #' @return A list containing at list the following components: #' -#' \itemize{ -#' \item \code{type}: The type of distribution fitted (as a character string) -#' \item \code{method}: The method used for the fit - here, maximum likelihood, 'll' -#' \item \code{ll}: The log likelihood at the estimated parameter values -#' \item \code{xmin}: The value of xmin used for the fit -#' \item \code{npars}: The number of parameters of the distribution +#' \describe{ +#' \item{\code{type}}{The type of distribution fitted (as a character string)} +#' \item{\code{method}}{The method used for the fit - here, maximum likelihood, 'll'} +#' \item{\code{ll}}{The log likelihood at the estimated parameter values} +#' \item{\code{xmin}}{The value of xmin used for the fit} +#' \item{\code{npars}}{The number of parameters of the distribution} #' } #' #' Additionally, this list may have one or more of the following elements depending on #' the type of distribution that has been fitted: -#' \itemize{ -#' \item \code{plexpo}: The exponent of the power-law -#' \item \code{cutoff}: The rate of truncation, for truncated power law and -#' exponential fits -#' \item \code{meanlog}: The mean of the lognormal distribution -#' \item \code{sdlog}: The s.d. of the lognormal distribution +#' \describe{ +#' \item{\code{plexpo}}{The exponent of the power-law} +#' \item{\code{cutoff}}{The rate of truncation, for truncated power law and +#' exponential fits} +#' \item{\code{meanlog}}{The mean of the lognormal distribution} +#' \item{\code{sdlog}}{The s.d. of the lognormal distribution} #' } #' #' @details These functions will fit distributions to a set of values using @@ -253,11 +253,11 @@ pl_ll <- function(dat, expo, xmin) { #' #' For reference, the shape of the distributions is as follow: #' -#' \itemize{ -#' \item{power-law }{\eqn{x^{-a}}{x^(-a)} where a is the power-law exponent} -#' \item{exponential }{\eqn{exp(-bx)}{exp(-bx)} where b is the truncation rate -#' of the exponential } -#' \item{truncated power-law }{\eqn{x^{-a}exp(-bx)}{x^(-a)exp(-bx)} where a +#' \describe{ +#' \item{power-law}{\eqn{x^{-a}}{x^(-a)} where a is the power-law exponent} +#' \item{exponential}{\eqn{exp(-bx)}{exp(-bx)} where b is the truncation rate +#' of the exponential} +#' \item{truncated power-law}{\eqn{x^{-a}exp(-bx)}{x^(-a)exp(-bx)} where a #' and b are the exponent of the power law and the rate of truncation} #' } #' @@ -265,7 +265,7 @@ pl_ll <- function(dat, expo, xmin) { #' #' The following global options can be used to change the behavior of fitting functions #' and/or produce more verbose output: -#' \itemize{ +#' \describe{ #' \item{spatialwarnings.constants.reltol}{the relative tolerance to use to compute #' the power-law normalizing constant #' \deqn{sum_{k=1}^{\infty} x^{ak}e^{-bk}}{sum( x^(ak)exp(-bk)) for k in 1:Inf}. @@ -294,7 +294,7 @@ pl_ll <- function(dat, expo, xmin) { #' exp_fit(patchsizes(forestgap[[8]])) #' #' # Use the estimated parameters as an indicator function -#' \dontrun{ +#' \donttest{ #' #' get_truncation <- function(mat) { #' c(exp_cutoff = exp_fit(patchsizes(mat))$cutoff) @@ -374,7 +374,7 @@ pl_fit <- function(dat, xmin = 1) { #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' psd <- patchsizes(forestgap[[5]]) #' xmin_estim(psd) #' } diff --git a/R/indicator_plrange.R b/R/indicator_plrange.R index 5e5e7be6..037433f8 100644 --- a/R/indicator_plrange.R +++ b/R/indicator_plrange.R @@ -51,7 +51,7 @@ #' @seealso \code{\link{patchdistr_sews}} #' #' @examples -#' \dontrun{ +#' \donttest{ #' forestgap.plr <- indicator_plrange(forestgap) #' do.call(rbind, forestgap.plr) # convert results to data.frame #' @@ -134,7 +134,7 @@ indicator_plrange <- function(mat, #' @seealso \code{\link{patchdistr_sews}} #' #' @examples -#' \dontrun{ +#' \donttest{ #' forestgap.plr <- raw_plrange(forestgap[[2]]) #' #' # Restrict to small xmins diff --git a/R/indicator_psdtype.R b/R/indicator_psdtype.R index f218f411..482d5129 100644 --- a/R/indicator_psdtype.R +++ b/R/indicator_psdtype.R @@ -40,18 +40,18 @@ #' @return A data.frame (or a list of these if x is a list) with the #' following columns: #' \itemize{ -#' \item `method` the method used for fitting (currently: only +#' \item \code{method} the method used for fitting (currently: only #' log-likelihood is implemented, "ll") -#' \item `type` the type of distribution fit -#' \item `npars` the number of parameters of the distribution type -#' \item `AIC`, `AICc` and `BIC` the values for Akaike Information +#' \item \code{type} the type of distribution +#' \item npars the number of parameters of the distribution type +#' \item AIC, `AICc` and `BIC` the values for Akaike Information #' Criterion (or the corrected for small samples equivalent AICc), #' and Bayesion Information Criterion (BIC) -#' \item `best` A logical vector indicating which distribution is the +#' \item \code{best} A logical vector indicating which distribution is the #' best fit -#' \item `plexpo`, `cutoff`, `meanlog`, `sdlog` the estimates for -#' distribution parameters (see \code{\link{pl_fit}}) -#' \item 'percolation' A logical value indicating whether there is +#' \item \code{plexpo}, \code{cutoff}, \code{meanlog}, \code{sdlog} the estimates +#' for distribution parameters (see \code{\link{pl_fit}}) +#' \item \code{percolation} A logical value indicating whether there is #' \code{\link{percolation}} in the system. #' } #' @@ -104,7 +104,7 @@ #' indicator_psdtype(forestgap[[1]]) #' #' # A list of these matrices -#' \dontrun{ +#' \donttest{ #' indicator_psdtype(forestgap) #' } #' diff --git a/R/indictest.R b/R/indictest.R index 1bd06851..60c103ff 100644 --- a/R/indictest.R +++ b/R/indictest.R @@ -64,16 +64,16 @@ #' #' The list \code{null_control} can be used to adjust the computation of #' null matrices. It can have the following components: -#' \itemize{ -#' \item `family` The family used in the model used to produce the null +#' \describe{ +#' \item{\code{family}}{The family used in the model used to produce the null #' matrices. Typically, it is one of \code{\link[=stats]{binomial}()}, -#' \code{\link[=stats]{binomial}()}, etc. +#' \code{\link[=stats]{binomial}()}, etc. } #' -#' \item `qinf` The lower quantile to compute from the null distribution -#' and display in summaries/plots. A numeric value between 0 and 1. +#' \item{\code{qinf}}{The lower quantile to compute from the null distribution +#' and display in summaries/plots. A numeric value between 0 and 1.} #' -#' \item `qsup` The upper quantile to compute from the null distribution -#' and display in summaries/plots. A numeric value between 0 and 1. +#' \item{\code{qsup}}{The upper quantile to compute from the null distribution +#' and display in summaries/plots. A numeric value between 0 and 1.} #' } #' #' @seealso \code{\link{generic_sews}}, \code{\link{spectral_sews}}, diff --git a/R/simple_indic.R b/R/simple_indic.R index eb04222f..c8aa7563 100644 --- a/R/simple_indic.R +++ b/R/simple_indic.R @@ -55,7 +55,7 @@ #' mp_indic <- maxpatch_sews(forestgap) #' summary(mp_indic) #' -#' \dontrun{ +#' \donttest{ #' # Assess significance and display trends #' mp_test <- indictest(mp_indic, nulln = 49) #' plot(mp_test) @@ -81,7 +81,7 @@ #' cv_indic2 <- compute_indicator(serengeti, spatial_cv, subsize = 3) #' plot(cv_indic2, along = serengeti.rain) #' -#' \dontrun{ +#' \donttest{ #' indictest(cv_indic, nulln = 99) #' } #'@export diff --git a/R/spatialwarnings-deprecated.R b/R/spatialwarnings-deprecated.R index a590bbcb..9b53f373 100644 --- a/R/spatialwarnings-deprecated.R +++ b/R/spatialwarnings-deprecated.R @@ -1,18 +1,3 @@ -#' @title Deprecated functions in package \pkg{spatialwarnings}. -#' -#' @description The functions listed below are deprecated and will be defunct in -#' the near future. When possible, alternative functions with similar -#' functionality are also mentioned. -#' -#' @section \code{generic_spews}: -#' For \code{\link{generic_spews}}, use \code{\link{generic_sews}}. -#' -#' @section \code{spectral_spews}: -#' For \code{\link{spectral_spews}}, use \code{\link{spectral_sews}}. -#' -#' @section \code{patchdistr_spews}: -#' For \code{\link{patchdistr_spews}}, use \code{\link{patchdistr_sews}}. -#' -#' @name spatialwarnings-deprecated -#' @keywords internal -NULL +# +# No deprecated functions in current version +# diff --git a/R/task_flowlength.R b/R/task_flowlength.R index fb3c8ae3..f5f268bf 100644 --- a/R/task_flowlength.R +++ b/R/task_flowlength.R @@ -79,7 +79,7 @@ #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' fl_result <- flowlength_sews(arizona, slope = 20, cell_size = 1) #' #' # Compute the Z-score (standardized deviation to null distribution) and plot @@ -251,7 +251,7 @@ indictest.flowlength_sews_single <- function(x, #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' raw_flowlength_uniform(arizona[[1]], slope = 20, cell_size = 1) #' } #' diff --git a/R/task_generic_indic.R b/R/task_generic_indic.R index 26d293af..79fd5154 100644 --- a/R/task_generic_indic.R +++ b/R/task_generic_indic.R @@ -96,7 +96,7 @@ #' plot(gen_indic, along = serengeti.rain) #' #' # Compute significance (long) -#' \dontrun{ +#' \donttest{ #' gen_test <- indictest(gen_indic, nulln = 199) #' #' print(gen_test) @@ -237,7 +237,7 @@ raw_generic_indic <- function(mat, #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' data(serengeti) #' raw_cg_variance(serengeti[[1]]) #' compute_indicator(serengeti, fun = raw_cg_variance, subsize = 5) @@ -279,7 +279,7 @@ raw_cg_variance <- function(mat, subsize = 5) { #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' data(serengeti) #' raw_cg_moran(serengeti[[1]], subsize = 1) #' } @@ -360,7 +360,7 @@ raw_cg_moran <- function(mat, subsize = 1) { #' @examples #' #' data(serengeti) -#' \dontrun{ +#' \donttest{ #' raw_cg_skewness(serengeti[[1]]) #' compute_indicator(serengeti, fun = raw_cg_skewness, subsize = 5) #' } diff --git a/R/task_kbdm.R b/R/task_kbdm.R index 96be548c..3ebdd0ef 100644 --- a/R/task_kbdm.R +++ b/R/task_kbdm.R @@ -45,7 +45,7 @@ #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' #' kbdm_result <- kbdm_sews(serengeti, subsize = 3) #' plot(kbdm_result, along = serengeti.rain) @@ -94,7 +94,7 @@ kbdm_sews <- function(mat, subsize = 3) { #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' raw_kbdm(forestgap[[1]], subsize = 3) #' } #' diff --git a/R/task_patch_indic.R b/R/task_patch_indic.R index 0911eac6..f3be837c 100644 --- a/R/task_patch_indic.R +++ b/R/task_patch_indic.R @@ -119,7 +119,7 @@ #' #' data(forestgap) #' -#' \dontrun{ +#' \donttest{ #' psd_indic <- patchdistr_sews(forestgap) #' #' summary(psd_indic) diff --git a/R/task_patch_indic_methods.R b/R/task_patch_indic_methods.R index a896aec4..0261004e 100644 --- a/R/task_patch_indic_methods.R +++ b/R/task_patch_indic_methods.R @@ -52,7 +52,7 @@ #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' data(forestgap) #' psd_indic <- patchdistr_sews(forestgap) #' @@ -408,7 +408,7 @@ plot_distr.patchdistr_sews_list <- function(x, #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' patch_indics <- patchdistr_sews(forestgap) #' #' predict(patch_indics) diff --git a/R/task_spectral_indic.R b/R/task_spectral_indic.R index 360435cd..5e00b589 100644 --- a/R/task_spectral_indic.R +++ b/R/task_spectral_indic.R @@ -82,7 +82,7 @@ #' \code{\link{indictest}}, to test the significance of indicator values. #' #' @examples -#' \dontrun{ +#' \donttest{ #' #' data(serengeti) #' data(serengeti.rain) @@ -253,7 +253,7 @@ spectral_sews <- function(mat, #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' data(serengeti) #' serengeti.sdr <- raw_sdr(serengeti[[1]], #' sdr_low_range = c(0, 0.2), diff --git a/R/task_variogram_indic.R b/R/task_variogram_indic.R index a9bd0934..d27d4d0e 100644 --- a/R/task_variogram_indic.R +++ b/R/task_variogram_indic.R @@ -76,7 +76,7 @@ #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' serengeti_ews <- variogram_sews(serengeti, #' model ="exp") #' plot(serengeti_ews, along = serengeti.rain) @@ -156,7 +156,7 @@ variogram_sews <- function(mat, #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' vario_indics <- variogram_sews(serengeti) #' predict(vario_indics) #' vario_test <- indictest(vario_indics, nulln = 19) @@ -207,7 +207,7 @@ extract_variogram.variogram_sews_single <- function(x, ...) { #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' vario_indics <- variogram_sews(serengeti) #' predict(vario_indics) #' vario_test <- indictest(vario_indics, nulln = 19) @@ -270,7 +270,7 @@ predict.variogram_sews_single <- function(object, newdist = NULL, ...) { #' #' @examples #' -#' \dontrun{ +#' \donttest{ #' serengeti_ews <- variogram_sews(serengeti, model ="exp") #' #' # Display the change in variogram parameters diff --git a/man/create_indicator.Rd b/man/create_indicator.Rd index c5aff628..b97785a8 100755 --- a/man/create_indicator.Rd +++ b/man/create_indicator.Rd @@ -63,7 +63,7 @@ maxpatch_sews <- create_indicator(maxpatchsize) mp_indic <- maxpatch_sews(forestgap) summary(mp_indic) -\dontrun{ +\donttest{ # Assess significance and display trends mp_test <- indictest(mp_indic, nulln = 49) plot(mp_test) @@ -89,7 +89,7 @@ plot(cv_indic, along = serengeti.rain) cv_indic2 <- compute_indicator(serengeti, spatial_cv, subsize = 3) plot(cv_indic2, along = serengeti.rain) -\dontrun{ +\donttest{ indictest(cv_indic, nulln = 99) } } diff --git a/man/extract_variogram.Rd b/man/extract_variogram.Rd index 97b791d7..a3091e02 100644 --- a/man/extract_variogram.Rd +++ b/man/extract_variogram.Rd @@ -23,7 +23,7 @@ Extract the empirical variogram from a \code{variogram_sews} } \examples{ -\dontrun{ +\donttest{ vario_indics <- variogram_sews(serengeti) predict(vario_indics) vario_test <- indictest(vario_indics, nulln = 19) diff --git a/man/flowlength_sews.Rd b/man/flowlength_sews.Rd index ce49a4b9..ee001805 100755 --- a/man/flowlength_sews.Rd +++ b/man/flowlength_sews.Rd @@ -54,7 +54,7 @@ In general, Flowlength can be used as indicator of dryland functional status } \examples{ -\dontrun{ +\donttest{ fl_result <- flowlength_sews(arizona, slope = 20, cell_size = 1) # Compute the Z-score (standardized deviation to null distribution) and plot diff --git a/man/generic_sews.Rd b/man/generic_sews.Rd index f1fd0481..911d9dea 100755 --- a/man/generic_sews.Rd +++ b/man/generic_sews.Rd @@ -81,7 +81,7 @@ summary(gen_indic) plot(gen_indic, along = serengeti.rain) # Compute significance (long) -\dontrun{ +\donttest{ gen_test <- indictest(gen_indic, nulln = 199) print(gen_test) diff --git a/man/generic_spews-deprecated.Rd b/man/generic_spews-deprecated.Rd deleted file mode 100755 index ea31c6ec..00000000 --- a/man/generic_spews-deprecated.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecation.R -\name{generic_spews} -\alias{generic_spews} -\title{(DEFUNCT) Generic Spatial Early-Warning signals} -\usage{ -generic_spews( - mat, - subsize = 4, - abs_skewness = FALSE, - moranI_coarse_grain = FALSE -) -} -\arguments{ -\item{mat}{A matrix (quantitative data), a binary matrix (TRUE/FALSE data), -or a list of those} - -\item{subsize}{The subsize used for the coarse-graining phase (see Details)} - -\item{abs_skewness}{Should the absolute skewness be used instead of its -raw values ?} - -\item{moranI_coarse_grain}{Should the input matrix be coarse-grained before -computing the Moran's I indicator value ?} -} -\description{ -Computation, significance assesment and display of spatial - generic early warning signals (Moran's I, variance and skewness) -} -\details{ -\code{generic_spews} has been renamed, please use - \code{\link{generic_sews}} instead. -} diff --git a/man/indicator_moran.Rd b/man/indicator_moran.Rd deleted file mode 100755 index 9838c49f..00000000 --- a/man/indicator_moran.Rd +++ /dev/null @@ -1,60 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecation.R -\name{indicator_moran} -\alias{indicator_moran} -\title{(DEFUNCT) Moran's Index at lag of 1} -\usage{ -indicator_moran(input, subsize = 1, nulln = 99) -} -\arguments{ -\item{input}{An matrix or a list of matrix object. It should -be a square matrix} - -\item{subsize}{logical. Dimension of the submatrix used to coarse-grain the -original matrix (set to 1 for no coarse-graining).} - -\item{nulln}{Number of replicates to produce to estimate null -distribution of index (default: 999).} -} -\value{ -A list (or a list of those if input is a list of matrix - object) of: - \itemize{ - \item `value`: Spatial autocorrelation of the matrix - } - If nulln is above 2, then the list has the following additional - components : - \itemize{ - \item `null_mean`: Mean autocorrelation of the null distribution - \item `null_sd`: SD of autocorrelation in the null distribution - \item `z_score`: Z-score of the observed value in the null distribution - \item `pval`: p-value based on the rank of the observed autocorrelation - in the null distribution. - } -} -\description{ -This functions computes the Moran's spatial correlation index - (with lag one). It also computes a null value obtained by randomizing - the matrix. -} -\examples{ - -\dontrun{ -data(serengeti) - -# One matrix -indicator_moran(serengeti[[1]]) - -# Several matrices -indicator_moran(serengeti) -} - -} -\references{ -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. - -Legendre, P., & Legendre, L. F. J. (2012). Numerical Ecology. -Elsevier Science. -} diff --git a/man/indicator_plrange.Rd b/man/indicator_plrange.Rd index 497fca0b..453be3fa 100755 --- a/man/indicator_plrange.Rd +++ b/man/indicator_plrange.Rd @@ -44,7 +44,7 @@ where \eqn{x_{max}}{x_max} is the maximum observed patch size, and \eqn{x_{smallest}}{x_smallest} is the minimum observed patch size. } \examples{ -\dontrun{ +\donttest{ forestgap.plr <- indicator_plrange(forestgap) do.call(rbind, forestgap.plr) # convert results to data.frame diff --git a/man/indicator_psdtype.Rd b/man/indicator_psdtype.Rd index 0acb3695..b55d7722 100755 --- a/man/indicator_psdtype.Rd +++ b/man/indicator_psdtype.Rd @@ -45,18 +45,18 @@ such neighborhoods.} A data.frame (or a list of these if x is a list) with the following columns: \itemize{ - \item `method` the method used for fitting (currently: only + \item \code{method} the method used for fitting (currently: only log-likelihood is implemented, "ll") - \item `type` the type of distribution fit - \item `npars` the number of parameters of the distribution type - \item `AIC`, `AICc` and `BIC` the values for Akaike Information + \item \code{type} the type of distribution + \item npars the number of parameters of the distribution type + \item AIC, `AICc` and `BIC` the values for Akaike Information Criterion (or the corrected for small samples equivalent AICc), and Bayesion Information Criterion (BIC) - \item `best` A logical vector indicating which distribution is the + \item \code{best} A logical vector indicating which distribution is the best fit - \item `plexpo`, `cutoff`, `meanlog`, `sdlog` the estimates for - distribution parameters (see \code{\link{pl_fit}}) - \item 'percolation' A logical value indicating whether there is + \item \code{plexpo}, \code{cutoff}, \code{meanlog}, \code{sdlog} the estimates + for distribution parameters (see \code{\link{pl_fit}}) + \item \code{percolation} A logical value indicating whether there is \code{\link{percolation}} in the system. } } @@ -96,7 +96,7 @@ data(forestgap) indicator_psdtype(forestgap[[1]]) # A list of these matrices -\dontrun{ +\donttest{ indicator_psdtype(forestgap) } diff --git a/man/indicator_sdr.Rd b/man/indicator_sdr.Rd deleted file mode 100755 index 2d823ef6..00000000 --- a/man/indicator_sdr.Rd +++ /dev/null @@ -1,78 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecation.R -\name{indicator_sdr} -\alias{indicator_sdr} -\title{(DEFUNCT) Density Ratio (SDR) indicator} -\usage{ -indicator_sdr(input, sdr_low_range = NULL, sdr_high_range = NULL, nulln = 99) -} -\arguments{ -\item{input}{A matrix or a logical matrix (TRUE/FALSE), or a list of these.} - -\item{sdr_low_range}{The range of values (in proportion) to -use for the computation of the spectral density ratio. -For example, for the lowest 20\% (default value), set \code{sdr_low_range} -to \code{c(0, .2)}.} - -\item{sdr_high_range}{The range of values (in proportion) to -use for the computation of the spectral density ratio. For example, for -the highest 20\% (default value), set \code{sdr_high_range} to -\code{c(.8, 1)}.} - -\item{nulln}{The number of simulations to compute for the null -distribution} -} -\value{ -A list (or a list of lists if input was a list of matrices) with - components: - \itemize{ - \item `value`: SDR of the matrix - } - If nulln is above 2, then the list has the following additional - components : - \itemize{ - \item `null_mean`: Mean SDR of the null distribution - \item `null_sd`: SD of SDR in the null distribution - \item `z_score`: Z-score of the observed value in the null distribution - (value minus the null mean and divided by null - standard deviation) - \item `pval`: p-value based on the rank of the observed SDR - in the null distribution. A low p-value means that - the indicator value is significantly higher than the - null values. - } -} -\description{ -Compute the ratio of low frequencies over high frequencies - of the r-spectrum. It also computes a null value obtained by - randomizing the matrix. -} -\details{ -SDR measures the increase in long-range correlations before a critical point. - It is the ratio of the average low frequency value over high frequency - values. In this implementation, an increase in SDR implies a "reddening" - of the \link[=rspectrum]{r-spectrum}. See also \code{\link{spectral_sews}} for - a more complete description. - -Low and high frequencies are averaged in order to compute the SDR. The - parameters \code{sdr_low_range} and \code{sdr_high_range} control which - frequencies are selected for averaging. For example - \code{sdr_low_range = c(0, .2)} (default) uses the lower 20% to compute - the average of low frequencies. \code{sdr_high_range = c(.8, 1)} uses the - higher 20% for the average of high frequencies. -} -\examples{ - -\dontrun{ -serengeti.sdr <- indicator_sdr(serengeti, nulln = 499) -do.call(rbind, serengeti.sdr) # convert results to data.frame -} - -} -\references{ -Carpenter, S.R. & Brock, W.A. (2010). Early warnings of regime shifts in - spatial dynamics using the discrete Fourier transform. Ecosphere -} -\seealso{ -spectral_sews, rspectrum -} diff --git a/man/indicator_skewness.Rd b/man/indicator_skewness.Rd deleted file mode 100755 index ae47a278..00000000 --- a/man/indicator_skewness.Rd +++ /dev/null @@ -1,98 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecation.R -\name{indicator_skewness} -\alias{indicator_skewness} -\title{(DEFUNCT) Skewness indicator} -\usage{ -indicator_skewness(input, subsize = 5, absolute = TRUE, nulln = 99) -} -\arguments{ -\item{input}{A matrix or a list of matrices. The matrix -values can be logical, with \code{FALSE} (empty) or \code{TRUE} (occupied) -values. The entries can also be continuous (like NDVI or EVI data).} - -\item{subsize}{Dimension of the submatrix used to coarse-grain the -original matrix. This must be an integer less than size of the full -matrix. Coarse-graining reduces the size of the matrix by a factor -\code{subsize} in each dimension of the matrix. Skewness is calculated -on the coarse-grained matrix.} - -\item{absolute}{Should the function return the absolute value or raw value -of skewness ?} - -\item{nulln}{Number of simulations used to produce the null -distribution of indicator values.} -} -\value{ -A list (or a list of lists if input was a list of matrices) with - components: - \itemize{ - \item `value`: Spatial skewness of the matrix - } - If nulln is above 2, then the list has the following additional - components : - \itemize{ - \item `null_mean`: Mean skewness of the null distribution - \item `null_sd`: SD of skewness in the null distribution - \item `z_score`: Z-score of the observed value in the null distribution - (value minus the null mean and divided by null - standard deviation) - \item `pval`: p-value based on the rank of the observed skewness - in the null distribution. A low p-value means that - the indicator value is significantly higher than the - null values. - } -} -\description{ -Compute the spatial skewness of spatial data. - It also computes a null value obtained by randomizing - the matrix. -} -\details{ -Spatial skewness is a measure of fluctuations in space; specifically, it -measures if fluctuations are getting biased (skewed) in one direction. Based -on the theory of critical slowing down, when systems approach critical -points they are expected to show increased fluctuations in space. Thus, -increasing spatial skewness is proposed as an early warning signal of -impending critical transitions. - -Computing spatial skewness is straightforward. However, detecting trends of -skewness that correspond to critical slowing down can be tricky, especially -if data come from discrete classification of state variable. - -For example, many high resolution spatial data are classified as FALSE (empty) -or TRUE (occupied by plant). In such cases, spatial skewness captures just -the skewness in data, but not that of spatial structure. -To resolve the issue, this function employs a method called coarse-graining, -proposed in Kefi et al (2014), and described in detail in -Sankaran et al. (2017). One must specify a subsize above one for -binary valued data sets to obtain meaningful values. - -\code{subsize} has to be an integer. It has to be less than or equal to -half of matrix size (N). \code{subsize} must also be preferably a -divisor of N. If it is not a divisor of N, the remainder rows and columns -are discarded when computing coarse-graining matrices. - -Null model evaluations are also done on coarse-grained matrices. -} -\examples{ - -\dontrun{ -data(serengeti) -indicator_skewness(serengeti) -} - -} -\references{ -Guttal, V., and Jayaprakash, C. (2009). Spatial variance and -spatial skewness: leading indicators of regime shifts in spatial -ecological systems. Theoretical Ecology, 2(1), 3-12. - -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. - -Sankaran, S., Majumder, S., Kefi, S., and Guttal, V. (2017). Implication of -being discrete and spatial in detecting early warning signals of regime -shifts. Ecological indicators. -} diff --git a/man/indicator_variance.Rd b/man/indicator_variance.Rd deleted file mode 100755 index 68c678cf..00000000 --- a/man/indicator_variance.Rd +++ /dev/null @@ -1,90 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecation.R -\name{indicator_variance} -\alias{indicator_variance} -\title{(DEFUNCT) Spatial variance indicator} -\usage{ -indicator_variance(input, subsize = 5, nulln = 99) -} -\arguments{ -\item{input}{A matrix or a list of matrices. The matrix -values can be logical, with \code{FALSE} (empty) or \code{TRUE} (occupied) -values. The entries can also be continuous (like NDVI or EVI data).} - -\item{subsize}{Dimension of the submatrix used to coarse-grain the -original matrix. This must be an integer less than size of the full -matrix. Coarse-graining reduces the size of the matrix by a factor -\code{subsize} in each dimension of the matrix. Variance is calculated -on the coarse-grained matrix.} - -\item{nulln}{Number of simulations used to produce the null -distribution of indicator values.} -} -\value{ -A list (or a list of lists if input was a list of matrices) with - components: - \itemize{ - \item `value`: Spatial variance of the matrix - } - If nulln is above 2, then the list has the following additional - components : - \itemize{ - \item `null_mean`: Mean spatial variance of the null distribution - \item `null_sd`: SD of spatial variance in the null distribution - \item `z_score`: Z-score of the observed value in the null distribution - (value minus the null mean and divided by null - standard deviation) - \item `pval`: p-value based on the rank of the observed spatial variance - in the null distribution. A low p-value means that - the indicator value is significantly higher than the - null values. - } -} -\description{ -This functions computes the spatial variance of spatial data. - It also computes a null value obtained by randomizing - the matrix. -} -\details{ -Spatial variance is a measure of fluctuations in space. Based on the theory -of critical slowing down, when systems approach critical points -they are expected to show increased fluctuations in space. Thus, increasing -spatial variance is proposed as an early warning signal of impending -critical transitions. - -For example, many high resolution spatial data are classified as FALSE (empty) -or TRUE (occupied by plant). In such cases, spatial variance captures just -the variance in data, but not that of spatial structure. -To resolve the issue, this function employs a method called coarse-graining, -proposed in Kefi et al (2014), and described in detail in -Sankaran et al. (2017). One must specify a subsize above one for -binary valued data sets to obtain meaningful values. - -\code{subsize} has to be an integer. It has to be less than or equal to -half of matrix size (N). \code{subsize} must also be preferably a -divisor of N. If it is not a divisor of N, the remainder rows and columns -are discarded when computing coarse-graining matrices. - -Null model evaluations are also done on coarse-grained matrices. -} -\examples{ - -data(serengeti) -\dontrun{ -indicator_variance(serengeti, nulln = 499) -} - -} -\references{ -Guttal, V., and Jayaprakash, C. (2009). Spatial variance and -spatial skewness: leading indicators of regime shifts in spatial -ecological systems. Theoretical Ecology, 2(1), 3-12. - -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. - -Sankaran, S., Majumder, S., Kefi, S., and Guttal, V. (2017). Implication -of being discrete and spatial in detecting early warning signals -of regime shifts. Ecological Indicators. -} diff --git a/man/indictest.Rd b/man/indictest.Rd index 74061b26..ff9731d3 100755 --- a/man/indictest.Rd +++ b/man/indictest.Rd @@ -65,16 +65,16 @@ If a matrix has attributes, then these are preserved and passed to the The list \code{null_control} can be used to adjust the computation of null matrices. It can have the following components: - \itemize{ - \item `family` The family used in the model used to produce the null + \describe{ + \item{\code{family}}{The family used in the model used to produce the null matrices. Typically, it is one of \code{\link[=stats]{binomial}()}, - \code{\link[=stats]{binomial}()}, etc. + \code{\link[=stats]{binomial}()}, etc. } - \item `qinf` The lower quantile to compute from the null distribution - and display in summaries/plots. A numeric value between 0 and 1. + \item{\code{qinf}}{The lower quantile to compute from the null distribution + and display in summaries/plots. A numeric value between 0 and 1.} - \item `qsup` The upper quantile to compute from the null distribution - and display in summaries/plots. A numeric value between 0 and 1. + \item{\code{qsup}}{The upper quantile to compute from the null distribution + and display in summaries/plots. A numeric value between 0 and 1.} } } \references{ diff --git a/man/kbdm_sews.Rd b/man/kbdm_sews.Rd index fe2da8bb..5e182de0 100755 --- a/man/kbdm_sews.Rd +++ b/man/kbdm_sews.Rd @@ -37,7 +37,7 @@ be a useful indicator to anticipate transitions in model ecological } \examples{ -\dontrun{ +\donttest{ kbdm_result <- kbdm_sews(serengeti, subsize = 3) plot(kbdm_result, along = serengeti.rain) diff --git a/man/patchdistr_sews.Rd b/man/patchdistr_sews.Rd index 0b0b58a2..410b96fd 100755 --- a/man/patchdistr_sews.Rd +++ b/man/patchdistr_sews.Rd @@ -108,7 +108,7 @@ as documented in \link[=patchdistr_sews_predict]{this page}. data(forestgap) -\dontrun{ +\donttest{ psd_indic <- patchdistr_sews(forestgap) summary(psd_indic) diff --git a/man/patchdistr_sews_plot.Rd b/man/patchdistr_sews_plot.Rd index 20bc5f1f..4183c65c 100755 --- a/man/patchdistr_sews_plot.Rd +++ b/man/patchdistr_sews_plot.Rd @@ -53,7 +53,7 @@ The \code{plot} function will produce a figure summarizing the changes } \examples{ -\dontrun{ +\donttest{ data(forestgap) psd_indic <- patchdistr_sews(forestgap) diff --git a/man/patchdistr_sews_predict.Rd b/man/patchdistr_sews_predict.Rd index e804158c..7bc35f82 100755 --- a/man/patchdistr_sews_predict.Rd +++ b/man/patchdistr_sews_predict.Rd @@ -38,7 +38,7 @@ The function \code{\link{patchdistr_sews}} fits competing } \examples{ -\dontrun{ +\donttest{ patch_indics <- patchdistr_sews(forestgap) predict(patch_indics) diff --git a/man/patchdistr_spews-deprecated.Rd b/man/patchdistr_spews-deprecated.Rd deleted file mode 100755 index b813d2f9..00000000 --- a/man/patchdistr_spews-deprecated.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecation.R -\name{patchdistr_spews} -\alias{patchdistr_spews} -\title{(DEFUNCT) Early-warning signals based on patch size distributions} -\usage{ -patchdistr_spews( - x, - merge = FALSE, - fit_lnorm = FALSE, - best_by = "BIC", - xmin = 1, - xmin_bounds = NULL, - wrap = FALSE -) -} -\arguments{ -\item{x}{A logical matrix (TRUE/FALSE values) or a list of these} - -\item{merge}{The default behavior is to produce indicators values for each -matrix. If this parameter is set to TRUE then the patch size distributions -are pooled together for fitting.} - -\item{fit_lnorm}{When patch size distributions are compared, should we -consider lognormal type ? (see details)} - -\item{best_by}{The criterion to use to select the best fit (one of "AIC", -"BIC" or "AICc")} - -\item{xmin}{The xmin to be used to fit the patch size distributions. Use -the special value "estimate" to compute first the xmin that produces -the best power-law fit, then use this estimated value to fit all -distributions.} - -\item{xmin_bounds}{Bounds when estimating the xmin for power-law distributions} - -\item{wrap}{Determines whether patches are considered to wrap around the -matrix when reaching the side} -} -\description{ -Compute early-warnings based on - patch size distributions and review/plot the results -} -\details{ -\code{patchdistr_spews} has been renamed, please use - \code{\link{patchdistr_sews}} instead. -} diff --git a/man/pl_fit.Rd b/man/pl_fit.Rd index 7f93da2d..27f36bba 100644 --- a/man/pl_fit.Rd +++ b/man/pl_fit.Rd @@ -24,22 +24,22 @@ distribution} \value{ A list containing at list the following components: -\itemize{ - \item \code{type}: The type of distribution fitted (as a character string) - \item \code{method}: The method used for the fit - here, maximum likelihood, 'll' - \item \code{ll}: The log likelihood at the estimated parameter values - \item \code{xmin}: The value of xmin used for the fit - \item \code{npars}: The number of parameters of the distribution +\describe{ + \item{\code{type}}{The type of distribution fitted (as a character string)} + \item{\code{method}}{The method used for the fit - here, maximum likelihood, 'll'} + \item{\code{ll}}{The log likelihood at the estimated parameter values} + \item{\code{xmin}}{The value of xmin used for the fit} + \item{\code{npars}}{The number of parameters of the distribution} } Additionally, this list may have one or more of the following elements depending on the type of distribution that has been fitted: - \itemize{ - \item \code{plexpo}: The exponent of the power-law - \item \code{cutoff}: The rate of truncation, for truncated power law and - exponential fits - \item \code{meanlog}: The mean of the lognormal distribution - \item \code{sdlog}: The s.d. of the lognormal distribution + \describe{ + \item{\code{plexpo}}{The exponent of the power-law} + \item{\code{cutoff}}{The rate of truncation, for truncated power law and + exponential fits} + \item{\code{meanlog}}{The mean of the lognormal distribution} + \item{\code{sdlog}}{The s.d. of the lognormal distribution} } } \description{ @@ -70,11 +70,11 @@ Please note that a best effort is made to have the fit converge, but For reference, the shape of the distributions is as follow: -\itemize{ - \item{power-law }{\eqn{x^{-a}}{x^(-a)} where a is the power-law exponent} - \item{exponential }{\eqn{exp(-bx)}{exp(-bx)} where b is the truncation rate - of the exponential } - \item{truncated power-law }{\eqn{x^{-a}exp(-bx)}{x^(-a)exp(-bx)} where a +\describe{ + \item{power-law}{\eqn{x^{-a}}{x^(-a)} where a is the power-law exponent} + \item{exponential}{\eqn{exp(-bx)}{exp(-bx)} where b is the truncation rate + of the exponential} + \item{truncated power-law}{\eqn{x^{-a}exp(-bx)}{x^(-a)exp(-bx)} where a and b are the exponent of the power law and the rate of truncation} } @@ -82,7 +82,7 @@ The lognormal form follows the \link[=dlnorm]{standard definition}. The following global options can be used to change the behavior of fitting functions and/or produce more verbose output: -\itemize{ +\describe{ \item{spatialwarnings.constants.reltol}{the relative tolerance to use to compute the power-law normalizing constant \deqn{sum_{k=1}^{\infty} x^{ak}e^{-bk}}{sum( x^(ak)exp(-bk)) for k in 1:Inf}. @@ -103,7 +103,7 @@ The following global options can be used to change the behavior of fitting funct exp_fit(patchsizes(forestgap[[8]])) # Use the estimated parameters as an indicator function -\dontrun{ +\donttest{ get_truncation <- function(mat) { c(exp_cutoff = exp_fit(patchsizes(mat))$cutoff) diff --git a/man/raw_cg_moran.Rd b/man/raw_cg_moran.Rd index a7eef799..1c13112a 100644 --- a/man/raw_cg_moran.Rd +++ b/man/raw_cg_moran.Rd @@ -22,7 +22,7 @@ This functions computes the Moran's spatial correlation index } \examples{ -\dontrun{ +\donttest{ data(serengeti) raw_cg_moran(serengeti[[1]], subsize = 1) } diff --git a/man/raw_cg_skewness.Rd b/man/raw_cg_skewness.Rd index d6203952..8df8fd37 100755 --- a/man/raw_cg_skewness.Rd +++ b/man/raw_cg_skewness.Rd @@ -56,7 +56,7 @@ Null model evaluations are also done on coarse-grained matrices. \examples{ data(serengeti) -\dontrun{ +\donttest{ raw_cg_skewness(serengeti[[1]]) compute_indicator(serengeti, fun = raw_cg_skewness, subsize = 5) } diff --git a/man/raw_cg_variance.Rd b/man/raw_cg_variance.Rd index 4a712946..d6d5c7b0 100644 --- a/man/raw_cg_variance.Rd +++ b/man/raw_cg_variance.Rd @@ -47,7 +47,7 @@ Null model evaluations are also done on coarse-grained matrices. } \examples{ -\dontrun{ +\donttest{ data(serengeti) raw_cg_variance(serengeti[[1]]) compute_indicator(serengeti, fun = raw_cg_variance, subsize = 5) diff --git a/man/raw_clustering.Rd b/man/raw_clustering.Rd index e3a92764..e8528769 100644 --- a/man/raw_clustering.Rd +++ b/man/raw_clustering.Rd @@ -66,6 +66,8 @@ clust <- raw_clustering(mm, wrap = TRUE, use_8_nb = TRUE) print(clust) # Compute clustering along the gradient for the serengeti dataset +\donttest{ + data(forestgap) clust_indic <- compute_indicator(serengeti, raw_clustering, wrap = TRUE, use_8_nb = FALSE) @@ -86,3 +88,5 @@ pair_counts(serengeti[[5]]) pair_counts(serengeti[[5]], prop = FALSE) } + +} diff --git a/man/raw_flowlength_uniform.Rd b/man/raw_flowlength_uniform.Rd index f75efc3e..7b5412ff 100755 --- a/man/raw_flowlength_uniform.Rd +++ b/man/raw_flowlength_uniform.Rd @@ -31,7 +31,7 @@ This function computes the Flowlength of a given matrix, using a } \examples{ -\dontrun{ +\donttest{ raw_flowlength_uniform(arizona[[1]], slope = 20, cell_size = 1) } diff --git a/man/raw_kbdm.Rd b/man/raw_kbdm.Rd index bfce81f2..65f964d0 100755 --- a/man/raw_kbdm.Rd +++ b/man/raw_kbdm.Rd @@ -29,7 +29,7 @@ The Kolmogorov complexity cannot be computed directly for large strings } \examples{ -\dontrun{ +\donttest{ raw_kbdm(forestgap[[1]], subsize = 3) } diff --git a/man/raw_moran.Rd b/man/raw_moran.Rd index bad58390..9204fec4 100755 --- a/man/raw_moran.Rd +++ b/man/raw_moran.Rd @@ -37,5 +37,5 @@ raw_moran(m) } \seealso{ -\code{\link{indicator_moran}}, \code{\link{generic_sews}} +\code{\link{generic_sews}} } diff --git a/man/raw_plrange.Rd b/man/raw_plrange.Rd index d54262f9..0fc4afed 100755 --- a/man/raw_plrange.Rd +++ b/man/raw_plrange.Rd @@ -36,7 +36,7 @@ where \eqn{x_{max}}{x_max} is the maximum observed patch size, and \eqn{x_{smallest}}{x_smallest} is the minimum observed patch size. } \examples{ -\dontrun{ +\donttest{ forestgap.plr <- raw_plrange(forestgap[[2]]) # Restrict to small xmins diff --git a/man/raw_sdr.Rd b/man/raw_sdr.Rd index 2915cf1e..0aff6b76 100644 --- a/man/raw_sdr.Rd +++ b/man/raw_sdr.Rd @@ -43,7 +43,7 @@ Low and high frequencies are averaged in order to compute the SDR. The } \examples{ -\dontrun{ +\donttest{ data(serengeti) serengeti.sdr <- raw_sdr(serengeti[[1]], sdr_low_range = c(0, 0.2), diff --git a/man/simple_sews.Rd b/man/simple_sews.Rd index 9e271fd1..53804ece 100644 --- a/man/simple_sews.Rd +++ b/man/simple_sews.Rd @@ -36,47 +36,47 @@ The \code{\link{spatialwarnings}} uses S3 objects (lists) internally to store of computations when working with multiple matrices. A \code{simple_sews_single} object is a list with the following components - \itemize{ - \code{itemvalue}: the indicator values. A vector of length one if there is + \describe{ + \item{\code{itemvalue}}{the indicator values. A vector of length one if there is only one numeric value returned by the indicator function (e.g. - \code{\link{flowlength_sews}}, or with a length above one otherwise - \item \code{orig_data}: the original matrix on which the indicator was computed - \item \code{fun.args}: the argument used in the call to the indicator function + \code{\link{flowlength_sews}}, or with a length above one otherwise} + \item{\code{orig_data}}{the original matrix on which the indicator was computed} + \item{\code{fun.args}}{the argument used in the call to the indicator function (the function that given a matrix, returns the spatial metrics of - interest) - \item \code{taskname}: a character string describing the current indicator(s) - being computed - \item \©ode{indicf}: the indicator function, which given the matrix, returns the - spatial metric(s) of interest + interest)} + \item{\code{taskname}}{a character string describing the current indicator(s) + being computed} + \item{\code{indicf}}{the indicator function, which given the matrix, returns the + spatial metric(s) of interest} } \code{simple_sews_test_single} have all of the above components, plus the following: -\itemize{ - \item \code{nulldistr}: the null distribution of values, with nulln rows and +\describe{ + \item{\code{nulldistr}}{the null distribution of values, with nulln rows and as many columns as the number of values returned by the indicator - function - \item \code{null_mean}: the mean indicator values in the null distribution - \item \code{null_sd}: the standard deviation of the null distribution - \item \code{null_qsup}: the upper quantile of the null distribution, by default + function} + \item{\code{null_mean}}{the mean indicator values in the null distribution} + \item{code{null_sd}}{the standard deviation of the null distribution} + \item{\code{null_qsup}}{the upper quantile of the null distribution, by default the 95% upper quantile, but see \code{\link{indictest}} for a way to - adjust this - \item \code{null_qinf}: the upper quantile of the null distribution, by default + adjust this} + \item{\code{null_qinf}}{the upper quantile of the null distribution, by default the 05% upper quantile, but see \code{\link{indictest}} for a way to - adjust this - \item \code{z_score}: the z_score of the observed value relative to the null - distribution, i.e. (value - null_mean) / null_sd - \item \code{pval}: the p-value of the indicator, i.e. the proporation of values - of the null distribution that fall below the observed indicator value - \item \code{null_method}: the method used to produce the null matrices. See - \code{\link{indictest}} for details - \item \code{nulln}: the number of null matrices used - \item \code{get_nullmat}: a function that can be called to obtain a randomized - matrix - \item \code{matrixn}: the number of the matrix, can be above one if the + adjust this} + \item{\code{z_score}}{the z_score of the observed value relative to the null + distribution, i.e. (value - null_mean) / null_sd} + \item{\code{pval}}{the p-value of the indicator, i.e. the proporation of values + of the null distribution that fall below the observed indicator value} + \item{\code{null_method}}{the method used to produce the null matrices. See + \code{\link{indictest}} for details} + \item{\code{nulln}}{the number of null matrices used} + \item{\code{get_nullmat}}{a function that can be called to obtain a randomized + matrix} + \item{\code{matrixn}}{the number of the matrix, can be above one if the computations have been run on a list of matrices, or non-existent if - only one matrix was used + only one matrix was used} } } \seealso{ diff --git a/man/spatialwarnings-deprecated.Rd b/man/spatialwarnings-deprecated.Rd deleted file mode 100755 index 73c264d5..00000000 --- a/man/spatialwarnings-deprecated.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatialwarnings-deprecated.R -\name{spatialwarnings-deprecated} -\alias{spatialwarnings-deprecated} -\title{Deprecated functions in package \pkg{spatialwarnings}.} -\description{ -The functions listed below are deprecated and will be defunct in - the near future. When possible, alternative functions with similar - functionality are also mentioned. -} -\section{\code{generic_spews}}{ - - For \code{\link{generic_spews}}, use \code{\link{generic_sews}}. -} - -\section{\code{spectral_spews}}{ - - For \code{\link{spectral_spews}}, use \code{\link{spectral_sews}}. -} - -\section{\code{patchdistr_spews}}{ - - For \code{\link{patchdistr_spews}}, use \code{\link{patchdistr_sews}}. -} - -\keyword{internal} diff --git a/man/spectral_sews.Rd b/man/spectral_sews.Rd index e9ae0467..5bf21f29 100755 --- a/man/spectral_sews.Rd +++ b/man/spectral_sews.Rd @@ -68,7 +68,7 @@ The trend of SDR values can be plotted using the \code{plot()} method. method. } \examples{ -\dontrun{ +\donttest{ data(serengeti) data(serengeti.rain) diff --git a/man/spectral_spews-deprecated.Rd b/man/spectral_spews-deprecated.Rd deleted file mode 100755 index df0a3673..00000000 --- a/man/spectral_spews-deprecated.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprecation.R -\name{spectral_spews} -\alias{spectral_spews} -\title{(DEFUNCT) Spectrum-based spatial early-warning signals.} -\usage{ -spectral_spews(mat, sdr_low_range = NULL, sdr_high_range = NULL, quiet = FALSE) -} -\arguments{ -\item{mat}{The input matrix or a list of matrices.} - -\item{sdr_low_range}{The range of values (in proportion) to -use for the computation of the spectral density ratio. -For example, for the lowest 20% (default value), set sdr_low_range to -c(0, .2). See also the Details section.} - -\item{sdr_high_range}{The range of values (in proportion) to -use for the computation of the spectral density ratio. For example, for -the higher 20% (default value), set sdr_high_range to -c(.8, 1). See also the Details section.} - -\item{quiet}{Do not display some warnings} -} -\description{ -Computation of spatial early warning signals based on spectral - properties. -} -\details{ -\code{spectral_spews} has been renamed, please use - \code{\link{spectral_sews}} instead. -} diff --git a/man/variogram_sews.Rd b/man/variogram_sews.Rd index 86e26ebb..9099df0b 100644 --- a/man/variogram_sews.Rd +++ b/man/variogram_sews.Rd @@ -66,7 +66,7 @@ Please note that this part of the package is still experimental and deserves } \examples{ -\dontrun{ +\donttest{ serengeti_ews <- variogram_sews(serengeti, model ="exp") plot(serengeti_ews, along = serengeti.rain) diff --git a/man/variogram_sews_plot.Rd b/man/variogram_sews_plot.Rd index c40293f3..adcc55bf 100644 --- a/man/variogram_sews_plot.Rd +++ b/man/variogram_sews_plot.Rd @@ -53,7 +53,7 @@ The \code{plot()} function will display how the estimated } \examples{ -\dontrun{ +\donttest{ serengeti_ews <- variogram_sews(serengeti, model ="exp") # Display the change in variogram parameters diff --git a/man/variogram_sews_predict.Rd b/man/variogram_sews_predict.Rd index 2a83baa0..1bd56234 100644 --- a/man/variogram_sews_predict.Rd +++ b/man/variogram_sews_predict.Rd @@ -25,7 +25,7 @@ Export the fitted variogram(s) } \examples{ -\dontrun{ +\donttest{ vario_indics <- variogram_sews(serengeti) predict(vario_indics) vario_test <- indictest(vario_indics, nulln = 19) diff --git a/man/xmin_estim.Rd b/man/xmin_estim.Rd index 85918494..570bd83d 100755 --- a/man/xmin_estim.Rd +++ b/man/xmin_estim.Rd @@ -28,7 +28,7 @@ The function returns NA if \code{dat} has only three unique values } \examples{ -\dontrun{ +\donttest{ psd <- patchsizes(forestgap[[5]]) xmin_estim(psd) } diff --git a/tests/testthat/test-clustering.R b/tests/testthat/test-clustering.R index 8b40d609..b25a1eec 100644 --- a/tests/testthat/test-clustering.R +++ b/tests/testthat/test-clustering.R @@ -4,11 +4,24 @@ test_that("Neighbor-counting is OK", { + # Check that total number of pairs matches counting done by hand expect_true( total_pair_count(diag(2), TRUE, TRUE) == 16 ) expect_true( total_pair_count(diag(2), FALSE, TRUE) == 6 ) expect_true( total_pair_count(diag(2), FALSE, FALSE) == 4 ) expect_true( total_pair_count(diag(2), TRUE, FALSE) == 8 ) - + + # Check that total number of pairs matches a manual sum after the fact + for ( wrap in c(TRUE, FALSE) ) { + for ( use_8_nb in c(TRUE, FALSE) ) { + a <- pair_counts(diag(10), wrap = wrap, use_8_nb = use_8_nb) + b <- pair_counts(diag(10), prop = FALSE, wrap = wrap, use_8_nb = use_8_nb) + b <- b / sum(b, na.rm = TRUE) + expect_true({ + all( abs(a[!is.na(a)] - b[!is.na(b)]) < 1e-8 ) + }) + } + } + }) test_that("Computation of clustering are OK", {