CDOoDocuments.StdDocumentDescDocuments.DocumentDescContainers.ViewDescViews.ViewDescStores.StoreDescDocuments.ModelDescContainers.ModelDescModels.ModelDescStores.ElemDesc TextViews.StdViewDescTextViews.ViewDescTextModels.StdModelDescTextModels.ModelDescTextModels.AttributesDesc'*
5(Times New Roman
r*$D*/>-%:ZfY
1*>
(Times New RomanQA=2)2Y0A06 =%# Capture-recapture data for white storks with survival possibly regressed on 10 covariates
# Uses the add-on package "Jump" to perform the reversible jump steps
# Created by RK April 09
model {
# Set constant recapture probability
for (i in 1 : nj) {
p[i] <- pconstant
p1[i] <- 1-p[i]
}
# Define priors for recapture probability
pconstant ~ dbeta(1,1)
for (i in 1 : nj) {
# Set the (logit) link function for the survival probabilities
logit(phi[i]) <- mu[i]
# Specify the prior on the parameter (normal)
mu[i] ~ dnorm(psi[i],taueps)
}
# Define the current values for the linear predictor term
psi[1 : nj] <- jump.lin.pred(X[1:nj, 1:Q], K, beta.prec)
id <- jump.model.id(psi[1:nj])
# Note - 'id' need to be monitored to obtain the posterior model probabilities (using the Jump menu)
# In order to obtain posterior regression parameters estimates (need to monitor 'effect')
pred[1:(Q + 1)] <- jump.lin.pred.pred(psi[1:nj], X.pred[1:(Q + 1), 1:Q])
for (i in 1:Q)
{
X.pred[i, i] <- 1
for (j in 1:(i - 1)) {X.pred[i, j] <- 0}
for (j in (i + 1):Q) {X.pred[i, j] <- 0}
X.pred[(Q + 1), i] <- 0
effect[i] <- pred[i] - pred[Q + 1]
}
# Specify the prior on precision for the random effects (gamma) and
# different models (uniform) and set prior precision for beta terms
taueps ~ dgamma(0.001,0.001)
K ~ dbin(0.5,Q)
beta.prec <- 0.1
# Define the likelihood:
for (i in 1 : ni){
m[i, 1 : (nj + 1)] ~ dmulti(q[i, ], r[i]) }
# Calculate the no. of birds released each year (see input data)
for (i in 1 : ni){
r[i] <- sum(m[i, ]) }
# Calculate the multinomial cell probabilities
for (i in 1 : ni){
# Calculate the diagonal elements
q[i, i] <- phi[i]*p[i]
# Calculate remaining terms above diagonal
for(j in (i+1) : nj ){
q[i,j] <- prod(phi[i:j])*prod(p1[i:(j-1)])*p[j]
}
# Zero probabilities in lower triangle of table
for(j in 1 : (i - 1)){
q[i, j] <- 0
}
# Probability of an animal not being seen again
q[i, nj + 1] <- 1 - sum(q[i,1:nj])
}
}
# Example Data Set: White storks
list(ni=16,nj=16,Q=10,m=structure(.Data = c(
19,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,
0,33,3,0,0,0,0,0,0,0,0,0,0,0,0,0,14,
0,0,35,4,0,0,0,0,0,0,0,0,0,0,0,0,14,
0,0,0,42,1,0,0,0,0,0,0,0,0,0,0,0,26,
0,0,0,0,42,1,0,0,0,0,0,0,0,0,0,0,30,
0,0,0,0,0,32,2,1,0,0,0,0,0,0,0,0,36,
0,0,0,0,0,0,46,2,0,0,0,0,0,0,0,0,16,
0,0,0,0,0,0,0,33,3,0,0,0,0,0,0,0,28,
0,0,0,0,0,0,0,0,44,2,0,0,0,0,0,0,20,
0,0,0,0,0,0,0,0,0,43,1,0,0,1,0,0,10,
0,0,0,0,0,0,0,0,0,0,34,1,0,0,0,0,25,
0,0,0,0,0,0,0,0,0,0,0,36,1,0,0,0,16,
0,0,0,0,0,0,0,0,0,0,0,0,27,2,0,0,22,
0,0,0,0,0,0,0,0,0,0,0,0,0,22,0,0,16,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,1,17,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,8),.Dim =c(16,17)),
X=structure(.Data = c(
0.73,-0.70,0.61,0.79,1.38,1.60,0.28,1.75,0.17,-0.73,
0.41,0.82,-0.23,2.04,0.27,1.50,0.32,0.97,-0.81,0.28,
0.84,2.44,0.03,1.04,0.50,0.41,0.90,-0.13,1.89,-0.27,
-0.24,0.86,1.77,-0.15,-0.41,0.79,-0.40,0.93,0.79,0.74,
0.72,-0.33,0.41,-0.01,0.42,-0.50,-0.45,-0.52,-0.92,0.44,
-0.49,-0.31,-0.13,-0.48,1.30,-0.77,1.45,-0.02,0.13,0.05,
-0.55,-0.12,-1.10,1.72,0.66,-1.56,-0.06,0.02,0.07,3.22,
-1.64,0.27,1.38,-0.83,-0.07,-1.21,1.35,-0.91,-0.01,-0.47,
1.12,0.96,0.02,-0.02,-0.16,0.80,-0.98,1.20,-0.13,0.09,
-0.22,0.19,0.58,0.14,-0.23,1.08,0.86,0.61,1.11,-0.70,
-0.40,-1.54,1.22,-0.71,0.09,-0.44,-1.22,0.20,0.01,-0.07,
0.94,-1.26,-1.57,0.50,0.40,-1.43,1.23,0.29,1.38,-1.02,
-2.45,0.46,-1.82,-0.62,-2.76,-0.65,0.03,-1.52,-0.72,0.32,
1.00,-0.91,-0.53,-0.88,-0.06,0.09,-0.34,-0.62,-1.48,-0.70,
-0.32,0.09,-0.16,-1.00,0.21,0.40,-1.05,-0.15,0.33,-0.84,
0.55,-0.93,-0.48,-1.52,-1.55,-0.11,-1.94,-2.10,-1.81,-0.36),.Dim = c(16,10)))
# Initial values
list(taueps=0.01,K=0,pconstant=0.5)
TextControllers.StdCtrlDescTextControllers.ControllerDescContainers.ControllerDescControllers.ControllerDesc TextRulers.StdRulerDescTextRulers.RulerDescTextRulers.StdStyleDescTextRulers.StyleDescZTextRulers.AttributesDesc$ ZGo
*,[@Documents.ControllerDesc Ws,!
[h$