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

<h2>File List</h2><blockquote> <a href="1_MCMC_FUNCTIONS.R">1_MCMC_FUNCTIONS.R</a><br> <a href="2_IFM_NO_MISSING_MCMC_FUNCTION.R">2_IFM_NO_MISSING_MCMC_FUNCTION.R</a><br> <a href="3_IFM_MISSING_MCMC_FUNCTION.R">3_IFM_MISSING_MCMC_FUNCTION.R</a><br> <a href="4_IFM_ROBUST_MCMC_FUNCTION.R">4_IFM_ROBUST_MCMC_FUNCTION.R</a><br> <a href="5_CHAIN_DIAGNOSTICS_FUNCTIONS.R">5_CHAIN_DIAGNOSTICS_FUNCTIONS.R</a>.<br> <a href="6_IFM_SIM_DATA_PREP.R">6_IFM_SIM_DATA_PREP.R</a><br> <a href="7_AUDIT_INM.R">7_AUDIT_INM.R</a><br> <a href="8_AUDIT_IFM_MISSING.R">8_AUDIT_IFM_MISSING.R</a><br> <a href="9_AUDIT_IFM_ROBUST.R">9_AUDIT_IFM_ROBUST.R</a> </blockquote><h2>Description</h2><blockquote> <p>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.</p> <p>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.</p> <p>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 <a href="appendix-A.htm">Appendix A</a>.</p> <p>The file 3_IFM_MISSING_MCMC_FUNCTION.R contains the function that uses MCMC to estimate the IFM Missing. The methods are described in <a href="appendix-A.htm">Appendix A</a>.</p> <p>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 <a href="appendix-A.htm">Appendix A</a>.</p> <p>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.</p> <p>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.</p> <p>The file 7_AUDIT_INM.R estimates the parameters of the IFM Naïve using data created in 6_IFM_SIM_DATA_PREP.R.</p> <p>The file 8_AUDIT_IFM_MISSING.R estimates the parameters of the IFM Missing using data created in 6_IFM_SIM_DATA_PREP.R.</p> <p>The file 9_AUDIT_IFM_ROBUST.R estimates the parameters of the IFM Robust using data created in 6_IFM_SIM_DATA_PREP.R.</p> </blockquote>