-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChapter5-AlienFishesSpeciesRichness.R
53 lines (23 loc) · 1.49 KB
/
Chapter5-AlienFishesSpeciesRichness.R
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
#############################################################################################################
#### BAYESIAN REGULARISED POISSON-LOG REGRESSION FOR MODELLING ALIEN FISH SPECIES RICHNESS IN AUSTRALIA ####
#############################################################################################################
model{
##### Defining prior distributions
### Topographic division-specific intercepts
alpha.dv[1:n.division]~dmnorm(alphac.mean[], tau.dv[,]) #### n.division: number of topographic divisions, n = 11
for (j in 1:n.division){
alphac.mean[j]<-0
}
tau.dv[1:n.division, 1:n.division]~dwish(S3.dv, n.division+1) #### Precision matrix estimated using a Wishart prior with degress of freedom = n.division+1
for (j in 1:n.cov){ #### n.cov: number of covariates, n = 8
beta[j]~ddexp(0, b) #### Prior for the slopes in the model; use of a double exponential (or Laplace) distribution for obtaining a regularised model
}
b~dunif(0.1, 5) #### Prior for the scale parameter of the double exponential distribution
#### Loop containing the model likelihood ####
for (i in 1:sample.size){ ### sample.size = number of drainages, n = 141
#### Alien fish richness modelled as a function of the 8 covariates using a Poisson-log regression ####
log(lambda[i])<-alpha.dr+beta[1]*area[i]+beta[2]*HFI[i]+beta[3]*flength[i]+beta[4]*facc[i]+beta[5]*up.slope[i]+beta[6]*up.elev[i]+
beta[7]*min.temp[i]+beta[8]*max.temp[i]
richness[i]~dpois(p[i], r)
}
}