figshare
Browse
1/1
10 files

Supplement 1. R-code used to simulate occupancy data and to fit the IFM naïve, IFM missing, and IFM robust models.

dataset
posted on 2016-08-09, 09:39 authored by Benjamin B. Risk, Perry de Valpine, Steven R. Beissinger

File List

1_MCMC_FUNCTIONS.R
2_IFM_NO_MISSING_MCMC_FUNCTION.R
3_IFM_MISSING_MCMC_FUNCTION.R
4_IFM_ROBUST_MCMC_FUNCTION.R
5_CHAIN_DIAGNOSTICS_FUNCTIONS.R.
6_IFM_SIM_DATA_PREP.R
7_AUDIT_INM.R
8_AUDIT_IFM_MISSING.R
9_AUDIT_IFM_ROBUST.R

Description

The files in this Supplement are used to fit the three models described in this study (IFM Naïve, IFM Missing, and IFM Robust) and include a program that simulates occupancy data following the Incidence Function Model.

The file 1_MCMC_FUNCTIONS.R contains four auxiliary functions used in 2_IFM_NO_MISSING_MCMC_FUNCTION.R, 3_IFM_MISSING_MCMC_FUNCTION.R, and 4_IFM_ROBUST_MCMC_FUNCTION.R. It includes a function that accepts or rejects proposed values in the Metropolis-Hastings algorithm, a function that counts the acceptance rates, a function that counts the number of missing values, and a function that is used when proposing values from a bivariate normal distribution for the parameters gamma and beta.

The file 2_IFM_NO_MISSING_MCMC_FUNCTION.R contains the function that uses MCMC to estimate the IFM Naïve. The methods are described in Appendix A.

The file 3_IFM_MISSING_MCMC_FUNCTION.R contains the function that uses MCMC to estimate the IFM Missing. The methods are described in Appendix A.

The file 4_IFM_ROBUST_MCMC_FUNCTION.R contains the function that uses MCMC to estimate the IFM Robust. It implements the IFM Robust, and the methods are described in Appendix A.

The file 5_CHAIN_DIAGNOSTICS_FUNCTIONS.R contains a number of functions used to diagnose the convergence of MCMC chains. In particular, the function coda.create converts the files created by the MCMC functions to a format that can be read by the “coda” R-package.

The file 6_IFM_SIM_DATA_PREP.R simulates occupancy data from the Incidence Function Model. These data sets are then used in the subsequent programs.

The file 7_AUDIT_INM.R estimates the parameters of the IFM Naïve using data created in 6_IFM_SIM_DATA_PREP.R.

The file 8_AUDIT_IFM_MISSING.R estimates the parameters of the IFM Missing using data created in 6_IFM_SIM_DATA_PREP.R.

The file 9_AUDIT_IFM_ROBUST.R estimates the parameters of the IFM Robust using data created in 6_IFM_SIM_DATA_PREP.R.

History