############################################# # # JAGS code for comparing effects of species # loss among different extinction steps and # at different ages, corresponding to the # equation 9 in the maintext. # Code tested in "R 3.3.1" with package # "rjags 4-6" and "JAGS 4.3.0" # Version: Feb. 2, 2019 # Programmer: Yuxin Chen # Contact: chenyux9@gmail.com # ############################################### #----------------------- # Note for variables #----------------------- # r_comm: random effect for community composition # r_plot: random effect for plot # div_level: diversity level or extinction step model { for (i in 1:N){ y_mu[i] <- theta0[age_level[i], div_level[i]] + theta1 * site[i] + r_comm[comm[i]] + r_plot[plot[i]] y[i] ~ dnorm(y_mu[i], tau_y) } for (j in 1:N_age){ for (k in 1:N_div){ theta0[j,k] ~ dnorm(0, 0.01) } } for (k in 1:N_comm){ r_comm[k] ~ dnorm(0, tau_comm) } for (l in 1:N_plot){ r_plot[l] ~ dnorm(0, tau_plot) } theta1 ~ dnorm(0, 0.01) tau_comm ~ dgamma(0.001, 0.001) sd_comm <- pow(tau_comm, -0.5) tau_plot ~ dgamma(0.001, 0.001) sd_plot <- pow(tau_plot, -0.5) tau_y ~ dgamma(0.001, 0.001) sd_y <- pow(tau_y, -0.5) }