Description Usage Arguments Details Value Author(s) See Also Examples
Bayesian Model To Identify Factors Affecting Wildlife-Vehicle Collisions
1 | finalModel(X, vectorFinalVariables, collisions, nYear, Area, departement)
|
X |
a data.frame containing the numeric variables supposed to have an effect on the wildlife-vehicle collisions (columns) for spatial unit (rows). |
vectorFinalVariables |
a vector of character strings containing the names of the final variables used in the combination. |
collisions |
an integer vector with length equal to
|
nYear |
an integer vector with length equal to |
Area |
a numeric vector with length equal to |
departement |
a character vector with length equal to
|
finalModel fits the final Bayesian model used to
predict the number of collisions between ungulates and vehicle as a
function of a linear combination of a set of environmental
variables.
a list with all elements required for the fit of the model
with JAGS, that is: (i) data4jags: the list of the data
required by the model, to be passed to the argument data of
the function jags.model of the package rjags, (ii)
ini: list of starting values for the parameters, to be
passed to the argument init of the function
jags.model, (iii) modelstring: a character string
containing the model fit by JAGS, (iv) coefnames: vector of
character strings containing the names of the coefficients of
interest in the model, to be passed to the argument
variable.names of the function coda.samples of the
package rjags.
Clement Calenge, clement.calenge@oncfs.gouv.fr
jags.model,
coda.samples, prepareFit
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 | ## The data used for the fit
data("dataCollision")
## Consider the Kuo-Mallik model fit (see ?prepareFit to see how
## this model was fitted)
data("modelRedDeer")
## we consider the probability associated to each model
probabilityKM(modelRedDeer)
## The best model seems to be the model including forFrag and hunt
## Prepare the data
X <- dataCollision$RedDeer$X
## We scale the variables to improve mixing
X <- as.data.frame(scale(X))
## Prepare the final model, including only the variables forFrag and hunt
pfm <- finalModel(X, c("forFrag","hunt"), dataCollision$RedDeer$coll,
dataCollision$RedDeer$Y, dataCollision$RedDeer$Area,
dataCollision$RedDeer$departement)
## Not run:
## WARNING: long execution (about 10 min)!!
## the results are stored in the dataset "finalModelRedDeer"
## But if you want to try it, the data are now ready for the fit:
mo <- jags.model(textConnection(pfm$modelstring), ini=pfm$ini, data=pfm$data4jags)
update(mo, n.iter=1000)
finalModelRedDeer <- coda.samples(mo, variable.names = pfm$coefnames,
n.iter = 500000, thin=100)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.