R/RcppExports.R

Defines functions convertSBtoNormal getql rmultinom1 ncs

Documented in convertSBtoNormal getql ncs

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

#' Summarize the data for mixture model
#' 
#' This function summarizes the data by calculating the number of observations across all locations 
#' assigned to a given group for which the species was present (stored in res1) or absent (stored in res0)
#' 
#' @param dat this matrix has L rows (locations) and S columns (species)
#'            and contains the presence-absence data (i.e., number of times 
#'            a given species was observed at a given location)
#' @param n.minus.y matrix with L rows (e.g., locations) and S columns (e.g., species),
#'                  calculated as matrix(nl,L,S)-dat           
#' @param z vector of size L with cluster assignment for each location
#' @param nspp number of species (S)
#' @param nloc number of locations (L)
#' @param ngroup maximum number of groups (K)
#' @return this function returns a list containing two matrices of size K x S: res1 and res0
#' @export
NULL

#' This function calculates ncs1 and ncs0
ncs <- function(dat, nminusy, z, nspp, nloc, ngroup) {
    .Call('_EcoCluster_ncs', PACKAGE = 'EcoCluster', dat, nminusy, z, nspp, nloc, ngroup)
}

rmultinom1 <- function(prob, randu) {
    .Call('_EcoCluster_rmultinom1', PACKAGE = 'EcoCluster', prob, randu)
}

#' Summarize data for SBM according to the different location and species groups
#' 
#' This function determines how many observations are in each location group 
#' and species group for two cases: 
#' - when dat(i,j)=1: these results are stored in matrix nql1
#' - when dat(i,j)=0: these results are stored in matrix nql0
#' 
#' @param z integer vector with cluster assignments of locations
#' @param w integer vector with cluster assignments of species
#' @param dat this matrix has L rows (e.g., locations) and S columns (e.g., species)
#'        and contains the presence-absence data
#' @param ngrloc number of location groups (KL)
#' @param ngrspp number of species groups (KS)
#' @return this function returns a list with two KL x KS matrices: nql1 and nql0
#' @export
#'
getql <- function(z, w, dat, ngrloc, ngrspp) {
    .Call('_EcoCluster_getql', PACKAGE = 'EcoCluster', z, w, dat, ngrloc, ngrspp)
}

#' Convert the vector v into the vector theta/phi using the stick-breaking formula
#' 
#' This function converts the input vector v into another vector of probabilities 
#' that sum to one based on the stick-breaking equation
#' 
#' @param v vector of probabilities (these do not have to sum to 1)
#' @return this function returns a vector res with probabilities that sum to one
#' @export
#' 
convertSBtoNormal <- function(v) {
    .Call('_EcoCluster_convertSBtoNormal', PACKAGE = 'EcoCluster', v)
}
drvalle1/EcoCluster documentation built on Jan. 25, 2022, 12:46 a.m.