Description Usage Format Details Source Examples
This help page describes how we fitted the model f1, supposing the
same habitat use by the roe deer in Chize, la Petite Pierre and
Trois-Fontaines. The R and JAGS code used to fit the model is
included in the Examples section of this help page, and the dataset
coefficientModel1
is an object of class mcmc.list
(package rjags) containing the sampled values of the coefficients.
1 | data("coefficientsModel1")
|
This object is an object of class mcmc.list
containing the
values of the coefficients sampled for three chains.
The fitted model was the following (see paper) for the multinomial logit of the probability of use of the scrubs:
log(P(scrubs)/P(CWS)) = a0f + apf * PoleStageInHomeRange + aff * ScrubsInHomeRange + eps1
Where eps1
is a normal overdispersion residual, and for the
probability of use of the pole stage:
log(P(pole stage)/P(CWS)) = a0p + app * PoleStageInHomeRange + apf * ScrubsInHomeRange
Where eps2
is a normal overdispersion residual.
Sonia Said, Centre national d'etude et de recherche appliquee "Cervides-Sangliers", Office national de la chasse et de la faune sauvage, Birieux, Ain, France.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | ## We load the data used for the fit:
data(HS3sites)
## We remove the information concerning the meadows
## (negligible, see the paper)
HS3sites$locs$meadows <- NULL
HS3sites$hr$meadows <- NULL
## The site is not required for this model
HS3sites$site <- NULL
## Calculates the total number of relocations
HS3sites$N <- apply(HS3sites$locs,1,sum)
## stores the number of animals
HS3sites$J <- nrow(HS3sites$locs)
## For a better mixing, we scale the covariates
HS3sites$hr <- scale(HS3sites$hr)
## Not run:
## We define the following starting values
init <- list(
list(a0f=-10,apf=0,aff=0, afp=0,app=0),
list(a0f=-10,apf=1,aff=1, afp=-1,app=-1),
list(a0f=-10,apf=-1,aff=1, afp=1,app=-1))
## We write the JAGS model in a file named model1.jags
## in the working directory
cat("model {
a0f ~ dnorm(0,0.001)
a0p ~ dnorm(0,0.001)
aff ~ dnorm(0,0.001)
afp ~ dnorm(0,0.001)
apf ~ dnorm(0,0.001)
app ~ dnorm(0,0.001)
sig ~ dunif(0,100)
for (j in 1:J) {
eps1[j]~dnorm(0,sig)
eps2[j]~dnorm(0,sig)
eps3[j]~dnorm(0,sig)
ep[j,1] <- a0f + aff*hr[j,1] + apf*hr[j,2] + eps1[j]
ep[j,2] <- a0p + afp*hr[j,1] + app*hr[j,2] + eps2[j]
p[j,1] <- exp(ep[j,1])/(1+exp(ep[j,1])+exp(ep[j,2]))
p[j,2] <- exp(ep[j,2])/(1+exp(ep[j,1])+exp(ep[j,2]))
p[j,3] <- 1/(1+exp(ep[j,1])+exp(ep[j,2]))
locs[j,]~dmulti(p[j,], N[j])
}
}
", file = "model1.jags")
## initialization
mo1 <- jags.model("model1.jags", n.adapt=20000, n.chain=3, data=HS3sites, inits=init)
## We draw 500 000 realization of this model (takes a long time!!!)
coefficientsModel1 <- coda.samples(mo1,
variable.names=c("a0f", "apf", "aff", "afp", "a0p",
"app", "sig"),
n.iter=500000, thin=50)
## End(Not run)
## To avoid waiting a long time for the fit, we have stored the results
## in the dataset coefficientsModel1
data(coefficientsModel1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.