R/RcppExports.R

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' rcpp_ac_stats
#'
#' Computes spatial autocorrelation statistics for a given input matrix
#'
#' @param nbs An \code{spdep} \code{nb} object listing all neighbours of each
#' point
#' @param x Corresponding vector of values
#' @param ac_type Character string specifying type of aucorrelation
#' (\code{moran}, \code{geary}, or code{getis-ord}).
#'
#' @return A vector of sorted spatial autocorrelation statistics scaled between
#' zero and one.
#'
rcpp_ac_stats <- function(z, nbs, wts, ac_type) {
    .Call('hotspotr_rcpp_ac_stats', PACKAGE = 'hotspotr', z, nbs, wts, ac_type)
}

#' rcpp_trunc_ndist
#'
#' Truncated normal distribution (mean 1, respective upper and lower limits of
#' 0 and 2). Code copied directly from `github.com/mpadge/tnorm`, with the
#' readme of that repo demonstrating the speed advantages of using this rather
#' than pre-existing approaches (the R package `truncnorm`).
#'
#' @param len Number of elements to be simulated
#' @param sd Standard deviation
#'
#' @return A vector of truncated normally distributed values
#'
rcpp_trunc_ndist <- function(len, sd) {
    .Call('hotspotr_rcpp_trunc_ndist', PACKAGE = 'hotspotr', len, sd)
}

#' rcpp_neutral_hotspots
#'
#' Implements neutral model in two dimensions
#'
#' @param nbs An \code{spdep} \code{nb} object listing all neighbours of each
#' point. 
#' @param wts Weighting factors for each neighbour; must have same length as
#' nbs. 
#' @param nbsi List of matrices as returned from \code{get_nbsi}. each element
#' of which contains the i-th nearest neighbour to each point.
#' @param alpha Strength of spatial autocorrelation
#' @param sd0 Standard deviation of truncated normal distribution used to model
#' environmental variation (with mean of 1)
#' @param log_scale If TRUE, raw hotspot values are log-transformed
#' @param niters Number of iterations of spatial autocorrelation
#' @param ac_type Character string specifying type of aucorrelation
#' (\code{moran}, \code{geary}, or code{getis-ord}).
#'
#' @return A vector of simulated values of same size as \code{nbs}.
#'
rcpp_neutral_hotspots <- function(nbs, wts, nbsi, alpha, sd0, log_scale, niters, ac_type) {
    .Call('hotspotr_rcpp_neutral_hotspots', PACKAGE = 'hotspotr', nbs, wts, nbsi, alpha, sd0, log_scale, niters, ac_type)
}

#' rcpp_neutral_hotspots_ntests
#'
#' Performs repeated neutral tests to yield average distributions of both
#' hotspot values and spatial autocorrelation statistics.
#'
#' @param nbs An \code{spdep} \code{nb} object listing all neighbours of each
#' point. 
#' @param wts Weighting factors for each neighbour; must have same length as
#' nbs. 
#' @param nbsi List of matrices as returned from \code{get_nbsi}. each element
#' of which contains the i-th nearest neighbour to each point.
#' @param alpha Strength of spatial autocorrelation
#' @param sd0 Standard deviation of truncated normal distribution used to model
#' environmental variation (with mean of 1)
#' @param nt Number of successive layers of temporal and spatial autocorrelation
#' used to generate final modelled values
#' @param ntests Number of tests used to obtain average values
#' @param ac_type Character string specifying type of aucorrelation
#' (\code{moran}, \code{geary}, or code{getis-ord}).
#'
#' @return A matrix of dimension (size, 2), with first column containing
#' sorted and re-scaled hotspot values, and second column containing sorted and
#' re-scaled spatial autocorrelation statistics.
#'
rcpp_neutral_hotspots_ntests <- function(nbs, wts, nbsi, alpha, sd0, niters, ac_type, log_scale, ntests) {
    .Call('hotspotr_rcpp_neutral_hotspots_ntests', PACKAGE = 'hotspotr', nbs, wts, nbsi, alpha, sd0, niters, ac_type, log_scale, ntests)
}
mpadge/hotspotr documentation built on May 23, 2019, 6:23 a.m.