Package 'multAbund'

Title: Model Multivariate Abundance and Occurence Using the Dirichlet Process Prior
Description: This package provides RJMCMC samplers to make Bayesian inference for Joint Species Distribution models (JSDM) using a Dirichlet Process clustering method. The DP clustering method allows species to be grouped into functional guilds for modeling between species associations in abundance or occurence values at surveyed sites.
Authors: Devin S. Johnson
Maintainer: Devin S. Johnson <[email protected]>
License: CC0
Version: 0.03.9002
Built: 2025-01-31 04:09:36 UTC
Source: https://github.com/dsjohnson/multAbund

Help Index


Use Dirichlet Process Prior to Model Multivariate Animal Abundance and Occurance

Description

Functions for implementing the RJMCMC estimation of multivariate abundence and occurence. These functions model multivariate abundence with latent group designations for each species. The associations between species are functions of common group membership.

Package: multAbund
Type: Package
Version: 0.03.9001
Date: March 28, 2018
License: CC0
LazyLoad: yes

Author(s)

Devin S. Johnson

Maintainer: Devin S. Johnson <[email protected]>


Obtain parameters for gamma prior such that the distribution of the number of groups is equal to the target argument

Description

This function uses the method of Dorazio (2009) to calculate the parameters of a gamma prior on the Dirichlet process such that the induced distribution function of the number of clusters is equal to 1/k.

Usage

get_opt_alpha_prior(n, target = NULL)

Arguments

n

An integer representing the maximum number of groups. Typically this is the number of individuals.

target

The desired prior probability mass function for the number of groups. This function must return a vector of length n which contains the prior probabilities for each group size.

Author(s)

Devin S. Johnson

References

Dorazio, R. M. (2009) On selecting a prior for the precision parameter of Dirichlet process mixture models. Journal of Statistical Planning and Inference 139:3384-3390.


Make necessary data matrices for multivariate abundance and occurence RJMCMC functions

Description

Makes the necessary lists for imput into the RJMCMC fitting functions

Usage

make_data_list(
  counts = NULL,
  occur = NULL,
  z_col = NULL,
  delta_model,
  X_model,
  sigma_model = ~1,
  gamma_model = ~1,
  data
)

Arguments

counts

A character string providing the name of the column in ⁠data⁠ that contains the counts

occur

A character string providing the name of the column in ⁠data⁠ that contains the binary occurence data

z_col

A character string providing the name of the column in ⁠data⁠ that contains the continuous abundance data

delta_model

A formula decribing the variables for which delta will be the coefficients.

X_model

A formula giveng additional variables to be used for all groups.

sigma_model

A formula describing the sigma vector. Must be of the form ⁠~factorVariable-1⁠.

gamma_model

A formula describing the gamma vector for ZIP models

data

Data.frame containing counts and environmental variables

Value

A list containing the following elements:

counts

The column containing count data

occur

The column containing occurence data

z_col

The column containing Gaussian response data

H

The environmental variables from which the clustering is based

X

The design matrix for the global covariates

D

Design matrix defining sigma_ij

M

Design matrix defining the gamma_ij

data

Data frame containing the original data

Author(s)

Devin S. Johnson


Perform RJMCMC for posterior sampling of multivariate cluster abundance model with Gaussian observations

Description

Fit a Dirichlet Process random effect model for joint species distribution inference of Gaussian abundance (typically resulting from a log transformation) data using a RJMCMC procedure. THIS IS CURRENTLY A TEST FUNCTION THAT IS NOT FULLY DEVELOPED YET! IT USES A DIFFERENT VARIANCE MODEL FOR DELTA PARAMETERS.

Usage

mult_abund_norm(
  data_list,
  initial_list,
  prior_list,
  block,
  begin_group_update,
  update_omega = T,
  burn,
  iter
)

Arguments

data_list

A named list created of data items created from user data with the function multAbund::make_data_list. This data will be used for model fitting.

initial_list

A named list of initial values for the parameters (see details). The functions multAbund::sugs or multAbund::make_inits can be used to create this list.

prior_list

A named list of prior distribution parameters. See details.

block

Number of iterations between Metropolis proposal adaptation.

begin_group_update

The iteration at with the group clusters begin updating. The RJMCMC often performs better when the chain is allowed to sample only the parameters before the groups begin updating.

update_omega

Logical. Should omega be updated or not?

burn

Number of burnin iterations that are discarded.

iter

Number of iterations retained for posterior inference.

Details

The prior_list argument needs to contain the following items:

  • a_alpha numeric. shape parameter for gamma prior on alpha,

  • b_alpha numeric. scale parameter for gamma prior on alpha,

  • Sigma_beta_inv numeric matrix. precision matrix for global regression coefficients, beta

  • mu_beta numeric vector. prior mean of beta parameters

  • phi_omega numeric. scale for half t/normal prior on delta variance parameter (omega),

  • df_omega numeric. degrees of freedom for half-t prior on omega (df_omega>=50 means a half-normal will be assumed)

  • phi_sigma numeric. scale parameter for half-t/normal prior for sigma parameters

  • df_sigma numeric. degrees of freedom for sigma prior (>=50 implies half-normal will be used)

Vignette

A demonstration using simulated data is available in vignette form and can be accessed by typing ⁠vignette("simulation_demo", package="multAbund")⁠. The vignette demo uses a realistic number of iterations, so, if the user decides to run the associated ⁠R⁠ code it will take some time.

Author(s)

Devin S. Johnson


Perform RJMCMC for posterior sampling of multivariate cluster abundance model with Poisson observations

Description

Fit a Dirichlet Process random effect model for joint species distribution inference of Poisson count data using a RJMCMC procedure.

Usage

mult_abund_pois(
  data_list,
  initial_list,
  prior_list,
  block,
  begin_group_update,
  burn,
  iter
)

Arguments

data_list

A named list created of data items created from user data with the function multAbund::make_data_list. This data will be used for model fitting.

initial_list

A named list of initial values for the parameters (see details). The functions multAbund::sugs or multAbund::make_inits can be used to create this list.

prior_list

A named list of prior parameters. See details.

block

Number of iterations between Metropolis proposal adaptation.

begin_group_update

The iteration at with the group clusters begin updating. The RJMCMC often performs better when the chain is allowed to sample only the parameters before the groups begin updating.

burn

Number of burnin iterations that are discarded.

iter

Number of iterations retained for posterior inference.

Details

The prior_list argument needs to contain the following items:

  • a_alpha numeric. shape parameter for gamma prior on alpha,

  • b_alpha numeric. scale parameter for gamma prior on alpha,

  • Sigma_beta_inv numeric matrix. precision matrix for global regression coefficients, beta

  • mu_beta numeric vector. prior mean of beta parameters

  • phi_omega numeric. scale for half t/normal prior on delta variance parameter (omega),

  • df_omega numeric. degrees of freedom for half-t prior on omega (df_omega>=50 means a half-normal will be assumed)

  • phi_sigma numeric. scale parameter for half-t/normal prior for sigma parameters

  • df_sigma numeric. degrees of freedom for sigma prior (>=50 implies half-normal will be used)

Vignette

A demonstration using simulated data is available in vignette form and can be accessed by typing ⁠vignette("simulation_demo", package="multAbund")⁠. The vignette demo uses a realistic number of iterations, so, if the user decides to run the associated ⁠R⁠ code it will take some time.

Author(s)

Devin S. Johnson


Perform RJMCMC for posterior sampling of multivariate cluster occurence model with Bernoulli observations

Description

Fit a Dirichlet Process random effect model for joint species distribution inference of binary occurence data using a RJMCMC procedure.

Usage

mult_abund_probit(
  data_list,
  prior_list,
  initial_list,
  block,
  begin_group_update,
  update_omega,
  burn,
  iter
)

Arguments

data_list

A named list created of data items created from user data with the function multAbund::make_data_list. This data will be used for model fitting.

prior_list

A named list of prior parameters. See details.

initial_list

A named list of initial values for the parameters (see details). The functions multAbund::sugs or multAbund::make_inits can be used to create this list.

block

Number of iterations between Metropolis proposal adaptation.

begin_group_update

The iteration at with the group clusters begin updating. The RJMCMC often performs better when the chain is allowed to sample only the parameters before the groups begin updating.

update_omega

logical. Should omega be updated during the MCMC or remain fixed.

burn

Number of burnin iterations that are discarded.

iter

Number of iterations retained for posterior inference.

Details

The prior_list argument needs to contain the following items:

  • a_alpha numeric. shape parameter for gamma prior on alpha,

  • b_alpha numeric. scale parameter for gamma prior on alpha,

  • Sigma_beta_inv numeric matrix. precision matrix for global regression coefficients, beta

  • mu_beta numeric vector. prior mean of beta parameters

  • phi_omega numeric. scale for half t/normal prior on delta variance parameter (omega),

  • df_omega numeric. degrees of freedom for half-t prior on omega (df_omega>=50 means a half-normal will be assumed)

  • phi_sigma numeric. scale parameter for half-t/normal prior for sigma parameters

  • df_sigma numeric. degrees of freedom for sigma prior (>=50 implies half-normal will be used)

Author(s)

Devin S. Johnson


Perform RJMCMC for posterior sampling of multivariate cluster abundance model with Zero-Inflated Poisson observations

Description

Fit a Dirichlet Process random effect model for joint species distribution inference of Zero-Inflated Poisson count data using a RJMCMC procedure.

Usage

mult_abund_zip(
  data_list,
  initial_list,
  prior_list,
  block,
  begin_group_update,
  update_omega = T,
  burn,
  iter
)

Arguments

data_list

A named list created of data items created from user data with the function multAbund::make_data_list. This data will be used for model fitting.

initial_list

A named list of initial values for the parameters (see details). The functions multAbund::sugs or multAbund::make_inits can be used to create this list.

prior_list

A named list of prior distribution parameters. See details.

block

Number of iterations between Metropolis proposal adaptation.

begin_group_update

The iteration at with the group clusters begin updating. The RJMCMC often performs better when the chain is allowed to sample only the parameters before the groups begin updating.

update_omega

Logical. Should omega be updated or not?

burn

Number of burnin iterations that are discarded.

iter

Number of iterations retained for posterior inference.

Details

The prior_list argument needs to contain the following items:

  • a_alpha numeric. shape parameter for gamma prior on alpha,

  • b_alpha numeric. scale parameter for gamma prior on alpha,

  • Sigma_beta_inv numeric matrix. precision matrix for global regression coefficients, beta

  • mu_beta numeric vector. prior mean of beta parameters

  • phi_omega numeric. scale for half t/normal prior on delta variance parameter (omega),

  • df_omega numeric. degrees of freedom for half-t prior on omega (df_omega>=50 means a half-normal will be assumed)

  • phi_sigma numeric. scale parameter for half-t/normal prior for sigma parameters

  • df_sigma numeric. degrees of freedom for sigma prior (>=50 implies half-normal will be used)

Vignette

A demonstration using simulated data is available in vignette form and can be accessed by typing ⁠vignette("simulation_demo", package="multAbund")⁠. The vignette demo uses a realistic number of iterations, so, if the user decides to run the associated ⁠R⁠ code it will take some time.

Author(s)

Devin S. Johnson


View simulation example

Description

Users can view an .html file that contains an example with simulated abundance data. The demo is similar to a vigette but it takes much too long to build.

Usage

view_example()

Author(s)

Devin S. Johnson