0% found this document useful (0 votes)
13 views3 pages

Zipkin al2010.MultiSpOccurrModelEvaluatEffectConservManagActions s1

artigo cientifico
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Zipkin al2010.MultiSpOccurrModelEvaluatEffectConservManagActions s1

artigo cientifico
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Appendix A.

Supplementary material
Model code

The model code below is written for program R and uses the R2WinBUGS package to run
WinBUGS.

#The detection/non-detection data is defined in a three dimensional


#array X where the first dimension, j, is the point; the second
#dimension, k, is the rep; and the last dimension, i, is the species.
#In addition, all zero encounter histories have been added to the
#array X as part of the data augmentation to account for additional
#species (beyond the n observed species as in Royle et al. 2007 – full
#reference in main text).

#n is the number of observed species


#nzeroes is the number of all-zero encounter histories that has been
#added to the data X
#J is the number of sampled points
#K is a vector of length J indicating the number of reps at each
#point j

#Define the necessary arguments to run the bugs() command

#Load all the data: detection array and covariate information


sp.data = list(n=n, nzeroes=nzeroes, J=J, K=K, X=X, date=date,
date2=date2, sunrise=sunrise, ufc=ufc, ba=ba,
ufc2=ufc2, ba2=ba2, Ind=Ind, ground=ground, mid=mid)

#Specify the parameters to be monitored


sp.params = list('u.cato', 'u.fcw', 'v.cato', 'v.fcw', 'omega',
'a1', 'a2', 'a3', 'a4', 'b1', 'b2', 'b3', 'Nsite', 'N',
'Nground', 'Nmid')

#Specify the initial values


sp.inits = function() {
omegaGuess = runif(1, n/(n+nzeroes), 1)
psi.meanGuess = runif(1, .25,1)
list(omega=omegaGuess,w=c(rep(1, n), rbinom(nzeroes, size=1,
prob=omegaGuess)),
u.cato=rnorm(n+nzeroes), v.cato=rnorm(n+nzeroes),
u.fcw=rnorm(n+nzeroes), v.fcw=rnorm(n+nzeroes),
Z = matrix(rbinom((n+nzeroes)*nsites, size=1,
prob=psi.meanGuess), nrow=nsites, ncol=(n+nzeroes)),
a1=rnorm(n+nzeroes), a2=rnorm(n+nzeroes),
a3=rnorm(n+nzeroes), a4=rnorm(n+nzeroes),
b1=rnorm(n+nzeroes), b2=rnorm(n+nzeroes),
b3=rnorm(n+nzeroes)
)
}

1
#Write the model code to a text file called “deerbrowse.txt”
cat("
model{

#Define prior distributions for community-level model parameters


omega ~ dunif(0,1)

cato.mean ~ dunif(0,1)
mu.ucato <- log(cato.mean) - log(1-cato.mean)

fcw.mean ~ dunif(0,1)
mu.ufcw <- log(fcw.mean) - log(1-fcw.mean)

cato2.mean ~ dunif(0,1)
mu.vcato <- log(cato2.mean) - log(1-cato2.mean)

fcw2.mean ~ dunif(0,1)
mu.vfcw <- log(fcw2.mean) - log(1-fcw2.mean)

mua1 ~ dnorm(0, 0.001)


mua2 ~ dnorm(0, 0.001)
mua3 ~ dnorm(0, 0.001)
mua4 ~ dnorm(0, 0.001)
mub1 ~ dnorm(0, 0.001)
mub2 ~ dnorm(0, 0.001)
mub3 ~ dnorm(0, 0.001)

tau.ucato ~ dgamma(0.1,0.1)
tau.ufcw ~ dgamma(0.1,0.1)
tau.vcato ~ dgamma(0.1,0.1)
tau.vfcw ~ dgamma(0.1,0.1)
tau.a1 ~ dgamma(0.1,0.1)
tau.a2 ~ dgamma(0.1,0.1)
tau.a3 ~ dgamma(0.1,0.1)
tau.a4 ~ dgamma(0.1,0.1)
tau.b1 ~ dgamma(0.1,0.1)
tau.b2 ~ dgamma(0.1,0.1)
tau.b3 ~ dgamma(0.1,0.1)

for (i in 1:(n+nzeroes)) {

#Specify priors for species i from the community level prior


#distributions
w[i] ~ dbern(omega)
u.cato[i] ~ dnorm(mu.ucato, tau.ucato)
u.fcw[i] ~ dnorm(mu.ufws, tau.ufws)
v.cato[i] ~ dnorm(mu.vcato, tau.cato)
v.fcw[i] ~ dnorm(mu.vfws, tau.vfws)
a1[i] ~ dnorm(mua1, tau.a1)
a2[i] ~ dnorm(mua2, tau.a2)
a3[i] ~ dnorm(mua3, tau.a3)
a4[i] ~ dnorm(mua4, tau.a4)

2
b1[i] ~ dnorm(mub1, tau.b1)
b2[i] ~ dnorm(mub2, tau.b2)
b3[i] ~ dnorm(mub3, tau.b3)

#Create a loop to define the Z matrix (true occurrence for species i


#at point j.
for (j in 1:J) {
logit(psi[j,i]) <- u.cato[i]*(1-Ind[j]) + u.fcw[i]*Ind[j] +
a1[i]*ufc[j] + a2[i]*ufc2[j] + a3[i]*ba[j] + a4[i]*ba2[j]

mu.psi[j,i] <- psi[j,i]*w[i]


Z[j,i] ~ dbern(mu.psi[j,i])

#Create a loop to define detection for species i at point k during


#sampling period k.
for (k in 1:K[j]) {
logit(theta[j,k,i]) <- v.cato[i]*(1-Ind[j]) + v.fcw[i]*Ind[j] +
b1[i]*date[j,k] + b2[i]*date2[j,k] + b3[i]*sunrise[j,k]

mu.theta[j,k,i] <- theta[j,k,i]*Z[j,i]


X[j,k,i] ~ dbern(mu.theta[j,k,i])
} } }

#Sum all species observed (n) and unobserved species (n0) to find the
#total estimated richness
n0 <- sum(w[(n+1):(n+nzeroes)])
N <- n + n0

#Create a loop to determine point level richness for the whole


#community and for subsets or assemblages of interest.
for(j in 1:J){
Nsite[j]<- inprod(Z[j,1:(n+nzeroes)],w[1:(n+nzeroes)])
Nground[j]<- inprod(Z[j,1:n],ground[1:n])
Nmid[j]<- inprod(Z[j,1:n],mid[1:n])
}

#Finish writing the text file.


}
",file="biolcons.txt")

#Load the R2Winbugs library


library(R2WinBUGS)

#Run the model and call the results “fit”


fit = bugs(sp.data, sp.inits, sp.params, "biolcons.txt", debug=TRUE,
n.chains=3, n.iter=30000, n.burnin=20000, n.thin=10)

#See a summary of the parameter estimates


fit$summary

You might also like