Chaozhi Zheng, Otso Ovaskainen, Tomas Roslin, and Ayco J. M. Tack. 2015. Beyond metacommunity paradigms: habitat configuration, life history, and movement shape an herbivore community on oak. Ecology 96:3175–3185. http://dx.doi.org/10.1890/15-0180.1


Supplement

Annotated Mathematica code for the Bayesian state-space model and simulations.
Ecological Archives E096-273-S1.

Copyright


Authors
File list (downloads)
Description


Author(s)

Chaozhi Zheng
Biometris
Wageningen University and Research Centre
PO Box 100
6700 Wageningen
The Netherlands
E-mail: [email protected]

Otso Ovaskainen
Department of Biosciences
University of Helsinki
PO Box 65 (Viikinkaari 1)
FI-00014 University of Helsinki
Finland
E-mail: [email protected]

Tomas Roslin
Spatial Foodweb Ecology Group
Department of Agricultural Sciences
PO Box 27 (Latokartanonkaari 5)
FI-00014 University of Helsinki
Finland
E-mail: [email protected]

Ayco Tack
Department of Ecology, Environment and Plant Sciences
Stockholm University
SE-10691 Stockholm
Sweden
E-mail: [email protected]


File list

All Files at Once: Zheng_et_al_Supplement.zip (MD5: 6230624ab714d9525b38704cc2523360)

consisting of these folders: Inference, Packages, and Postsimulation. Packages has subfolders Metropolis, RandomGenerator, and Toolbox.

List of all the files:
          
mcstate_SmallLand_Realdata_withHI.txt
res_InsectsOaks_Adp_SmallLand_Realdata_withHI.txt
res_InsectsOaks_All_SmallLand_Realdata_withHI.txt
res_InsectsOaks_Concise_SmallLand_Realdata_withHI.txt
Step1_Inference_Metcommunity.nb
Step2_PredictiveCheck.nb
Metropolis.nb
_2.cfs
segments.gen
segments_7
AdaptiveMetropolis.nb
AdaptiveProposal.nb
AdaptiveProposalScale.nb
BlockAdaptiveMetropolis.nb
BlockMetropolis.nb
BlockStudentTMetropolis.nb
dir.txt
DomainConstraint.nb
InitialProposal.nb
InitialProposalScale.nb
IsDiscrete.nb
IsReturnLast.nb
Metropolis.nb
MultiTryMetropolis.nb
PrintDetails.nb
SamplingPattern.nb
StartLogpdf.nb
StudentTDisplacements.nb
StudentTMetropolis.nb
_a.cfs
segments.gen
segments_n
init.m
RandomGenerator.nb
_0.cfs
_0.cfx
segments.gen
segments_2
DiscreteRatioOfUniform.nb
RandomBinomial.nb
RandomCanonicalMultiNorm.nb
RandomCanonicalMultiNorm2.nb
RandomMultiNormPrecision.nb
RandomMultiNormVariance.nb
RandomNegativeBinomial.nb
RandomOneSideTruncNorm.nb
RandomPoisson.nb
_0.cfx
_4.cfs
segments.gen
segments_2
init.m
init.m
CalculateTR.m
InsectOakSampler.m
logpdf1F1.m
MergeLand.m
recurInter1F1.txt
mcstate_SmallLand_Realdata_withHI.txt
res_InsectsOaks_Adp_SmallLand_Realdata_withHI.txt
res_InsectsOaks_All_SmallLand_Realdata_withHI.txt
res_InsectsOaks_Concise_SmallLand_Realdata_withHI.txt
Step1_Inference_Metcommunity.nb
Step2_PredictiveCheck.nb
col_perCaptia_dynamics_posterior_simland_ntree_100_crownA_0_cluster_1.txt
col_perCaptia_dynamics_posterior_simland_ntree_100_crownA_10_cluster_1.txt
col_perCaptia_dynamics_posterior_simland_ntree_100_crownA_10_cluster_10.txt
col_perCaptia_dynamics_posterior_simland_ntree_100_crownA_10_cluster_5.txt
col_perCaptia_dynamics_posterior_simland_ntree_100_crownA_20_cluster_1.txt
col_perCaptia_dynamics_posterior_simland_ntree_100_crownA_5_cluster_1.txt
col_perCaptia_dynamics_posterior_simland_ntree_200_crownA_10_cluster_1.txt
col_perCaptia_dynamics_posterior_simland_ntree_50_crownA_10_cluster_1.txt
dynamics_posterior_simland_ntree_100_crownA_0_cluster_1.txt
dynamics_posterior_simland_ntree_100_crownA_10_cluster_1.txt
dynamics_posterior_simland_ntree_100_crownA_10_cluster_10.txt
dynamics_posterior_simland_ntree_100_crownA_10_cluster_5.txt
dynamics_posterior_simland_ntree_100_crownA_20_cluster_1.txt
dynamics_posterior_simland_ntree_100_crownA_5_cluster_1.txt
dynamics_posterior_simland_ntree_200_crownA_10_cluster_1.txt
dynamics_posterior_simland_ntree_50_crownA_10_cluster_1.txt
R0_dynamics_posterior_simland_ntree_100_crownA_0_cluster_1.txt
R0_dynamics_posterior_simland_ntree_100_crownA_10_cluster_1.txt
R0_dynamics_posterior_simland_ntree_100_crownA_10_cluster_10.txt
R0_dynamics_posterior_simland_ntree_100_crownA_10_cluster_5.txt
R0_dynamics_posterior_simland_ntree_100_crownA_20_cluster_1.txt
R0_dynamics_posterior_simland_ntree_100_crownA_5_cluster_1.txt
R0_dynamics_posterior_simland_ntree_200_crownA_10_cluster_1.txt
R0_dynamics_posterior_simland_ntree_50_crownA_10_cluster_1.txt
res_InsectsOaks_All_SmallLand_Realdata_withHI.txt
simland_ntree_100_crownA_0_cluster_1.txt
simland_ntree_100_crownA_10_cluster_1.txt
simland_ntree_100_crownA_10_cluster_10.txt
simland_ntree_100_crownA_10_cluster_5.txt
simland_ntree_100_crownA_20_cluster_1.txt
simland_ntree_100_crownA_5_cluster_1.txt
simland_ntree_200_crownA_10_cluster_1.txt
simland_ntree_50_crownA_10_cluster_1.txt
Step3_SimulateDynamics.nb
Step4_Colonization per Captia.nb
Step5_Plot_SimulateResult.nb

Description

Organization of the three folders

1) The folder Packages contains mathematica packages used in inference and simulations of metacommunity dynamics.

1.1) The subfolder Metropolis is the general metropolis algorithm used in mcmc simulations.

1.2) The subfolder RandomGenerator is a collection of random generators not provided with the basic functions of mathematica.

1.3) The subfolder Toolbox is a collection of miscellaneous tools including plots and mcmc diagnostics.

1.4) The metacommunity related package files.

1.4.1) MergeLand.m: merge closely related trees.

1.4.2) logpdf1F1.m and recurInter1F1.txt: precomputation of the confluent hypergeometric function 1F1, aiming to improve computational speed.

1.4.3) InsectOakSampler.m: block update functions for Gibbs sampler.

2) The folder Inference contains code used for parameter estimation of the metacommunity model via mcmc

2.1) The notebook Step1_Inference_Metcommunity.nb

2.1.1) The input datafile should contain the definitions of allspp, prileafden, mergtree, isextdata, occdata, abunddata, dispdata. Here allspp is a list of species names (abbreviations); prileafden is the prior species density per leaf in log scale, mergtree is the merged set of trees including their locations and radii; isextdata is the indicator of extinction experiments for each year and each tree and each species, in the format of sparse array; occdata is the occupancy data; abunddata is the abundance data; dispdata is the data from dispersal experiments.

2.1.2) The temporary files such as mcstate_SmallLand_Realdata_withHI.txt saves the mcmc state, so that the long mcmc chain can restart from unexpected/manual loop break.

2.1.3) There are three mcmc output files

2.1.3.1) res_InsectsOaks_Adp_SmallLand_Realdata_withHI.txt saves the adaptation parameter values

2.1.3.2) res_InsectsOaks_Concise_SmallLand_Realdata_withHI.txt saves all the model parameter values except the large size of latent states (abundance).

2.1.3.3) res_InsectsOaks_All_SmallLand_Realdata_withHI.txt saves all the model parameter values including the latent states.

2.2) The notebook Step2_PredictiveCheck.nb performs model evaluation by posterior predictive checks including observed abundance and species richness.

3) The folder PostSimulation contains code used in simulation of metacommunity dynamics in hypothetical landscapes

3.1) The notebook Step3_SimulateDynamics.nb simulates the metacommunity dynamics based on the posterior distributions of model parameters (for illustration, only five species were analyzed in step2 mcmc), in eight scenarios of habitat configurations. Output eight land files simland_ntree_*.txt and eight dynamics files dynamics_posterior_simland_*.txt.

3.2) The notebook Step4_Colonization per captia.nb calculates basic reproduction number R0 saved in R0_dynamics_*.txt, and calculates the per-capita colonization rate saved in col_perCaptia_*.txt.

3.3) The notebook Step5_SimulateResult_Plot.nb plots Fig. 3 in the manuscript, based on the simulation results and calculated R0 and colonization rates.