# Downscaling species distributions using multi-scale logistic model

By | September 27, 2012

These are teaching materials to demonstrate how a simple Species Distribution Model can be made multi-scale. We published the methods presented here in the following paper: Keil et al. in Methods in Ecology and Evolution. This post is not entirely self-explanatory, it is going to be used during a lab seminar. Figure 1 Graphic representation of the main goal: To create fine-grain probabilistic map of species occurrence using fine-grain data on environment and coarse-grain data on species presences/absences. Figure 2 Scheme of the Hierarchical Bayesian model. f() will be logistic model that I used in my previous post.

Here you can download the data for this exercise.

This is the code for the exercise:

```
# ------------------------------
# MULTI-SCALE HIERARCHICAL LOGISTIC MODEL

# ------------------------------
# 1.
# You need to download the data file (see the link above)
# and save it to your R working directory.

# see the structure of the data
my.data

# ------------------------------
# 2.
# Sinking the model into a file.

sink("multiscale.txt")
cat("
model
{
# uninformative prior distributions for
# fine-grain regression coefficients
alpha ~ dnorm(0,0.01)
beta ~ dnorm(0,0.01)
gamma ~ dnorm(0,0.01)

# likelihood
for(i in 1:N_loc)
{
# coarse-grain probability of presence
coarse.p[i] <- 1 - prod(p.absence[i,1:9])
# observed coarse-grain presences or absences
coarse.presence[i] ~ dbern(coarse.p[i])

for (j in 1:9)
{
# fine-grain probability of absence
p.absence[i,j] <- 1 - p[i,j]

# the unobserved (latent) fine-grain presence probs
logit(p[i,j]) <-alpha +beta*envi1[i,j] +gamma*envi2[i,j]
}
}
}
")
sink()

# ------------------------------
# 3.
# Setting the parameters to be monitored.

# parameters to estimate
params <- c("alpha", "beta", "gamma")

# ------------------------------
# 4.
# Calling OpenBUGS.

# running openbugs
a1 <- bugs(data=my.data,
inits=NULL,
parameters.to.save=params,
n.iter=2000,
n.chains=3,
n.burnin=1000,
model.file="multiscale.txt",
debug=TRUE,
codaPkg=TRUE,
OpenBUGS.pgm="C:/Program Files (x86)/OpenBUGS/OpenBUGS321/OpenBUGS.exe" ,
working.directory=getwd())

1. petrkeil Post author