# Functions For Performing Hierarchical Analysis of Distance Sampling Data

## Documentation for package ‘hierarchicalDS’ version 2.9

- DESCRIPTION file.

## Help Pages

calc_linex_a | estimate optimal 'a' parameter for linex loss function
convert.HDS.to.mcmc | function to convert HierarchicalDS MCMC list vector (used in estimation) into an mcmc object (cf. coda package)
generate_inits | generate initial values for MCMC chain if not already specified by user
generate_inits_misID | generate initial values for misID model if not already specified by user
get_confusion_array | Fill confusion array - one confusion matrix for each individual (DEPRECATED)
get_confusion_mat | Fill a list with confusion matrices for each record
get_mod_matrix | function to produce a design matrix given a dataset and user-specified formula object
hierarchical_DS | Primary function for hierarchical, areal analysis of distance sampling data. This function pre-processes data and calls other functions to perform the analysis, and is the only function the user needs to call themselves.
linear_adj | Produce an adjacency matrix for a vector
log_lambda_gradient | compute the first derivative of log_lambda likelihood component for Langevin-Hastings
log_lambda_log_likelihood | compute the likelihood for nu parameters
mcmc_ds | Function for MCMC analysis
plot_N_map | function to plot a map of abundance. this was developed for spatio-temporal models in mind
plot_obs_pred | plot 'observed' versus predicted values for abundance of each species at each transect
post_loss | function to calculate posterior predictive loss given the output object from hierarchicalDS
probit.fct | Mrds probit detection and related functions
rect_adj | Produce an RW1 adjacency matrix for a rectangular grid for use with areal spatial models (queens move)
rect_adj_RW2 | Produce an RW2 Adjacency matrix for a rectangular grid for use with areal spatial models. This formulation uses cofficients inspired by a thin plate spline, as described in Rue & Held, section 3.4.2 Here I'm outputting an adjacency matrix of 'neighbor weights' which makes Q construction for regular latices easy to do when not trying to make inference about all cells (i.e., one can just eliminate rows and columns associated with cells one isn't interested in and set Q=-Adj+Diag(sum(Adj))
rrw | SIMULATE AN ICAR PROCESS
simdata | MCMC output from running example in Hierarchical DS
simulate_data | function to simulate double observer spatial distance sampling data subject to possible zero inflation and species misidentification
sim_out | MCMC output from running example in Hierarchical DS
square_adj | Produce an adjacency matrix for a square grid
stack_data | function to stack data (going from three dimensional array to a two dimensional array including only "existing" animals
stack_data_misID | function to stack data for midID updates (going from four dimensional array to a two dimensional array including observed groups
summary_N | calculate parameter estimates and confidence intervals for various loss functions
switch_pdf | function to calculate the joint pdf for a sample of values from one of a number of pdfs
switch_sample | function to sample from a specified probability density function
switch_sample_prior | function to sample from hyperpriors of a specified probability density function; note that initial values for sigma of lognormal random effects are fixed to a small value (0.05) to prevent numerical errors
table.mcmc | function to export posterior summaries from an mcmc object to a table