我正在R2jags中创建简单的分层占用模型,最后得出对p,B0和B1的单个估计值。但是,我收到了每个栖息地斑块的psi估计值(n = 88)。 B1是代表每个栖息地斑块的公顷(cs)面积的协变量。我已经阅读了许多贝叶斯occu论文的代码,并且紧随其后的是Hobbs和Hooten,2015年提出的建议。是否有可能获得psi的单一估算值?代码如下:
#create data list
dataListColArea <- list(
y_sf = y_sf,
cs = cs,
J = J,
nsite = length(y_sf)
)
#create model
swfoColArea <- function() {
#priors
p ~ dunif(0, 1)
beta0 ~ dlogis(0, .01)
beta1 ~ dlogis(0, .01)
#liklihood
logit(psi0) <- beta0
for (i in 1:nsite) {
logit(psi[i]) = beta0 + beta1*cs[i]
z[i] ~ dbern(psi[i])
y_sf[i] ~ dbinom((z[i]*p), J[i])
}
}
#set inits
initsswfoColArea <- function() {
list(
beta0 = .5,
beta1 = .5,
p = .5
)
}
#write model into jags
parameters <- c("psi", "p", "beta0", "beta1")
fm_swfoColArea <-jags(data = dataListColArea,
inits = initsswfoColArea,
parameters.to.save = parameters,
model.file = swfoColArea,
n.chains = 5,
n.iter = 50000,
n.burnin = 10000,
n.thin = 10)
fm_swfoColArea
#output:
beta0 193.328 123.519 23.823 103.231 171.417 258.910 492.839 1.002 1900
beta1 21.424 101.062 -144.867 -47.632 8.660 78.420 254.472 1.005 720
p 0.154 0.026 0.107 0.136 0.153 0.170 0.208 1.001 13000
psi[1] 1.000 0.007 1.000 1.000 1.000 1.000 1.000 1.286 3000
psi[2] 1.000 0.009 1.000 1.000 1.000 1.000 1.000 1.261 1700
psi[3] 1.000 0.010 1.000 1.000 1.000 1.000 1.000 1.249 1500
psi[4] 0.999 0.015 1.000 1.000 1.000 1.000 1.000 1.184 1300
psi[5] 1.000 0.008 1.000 1.000 1.000 1.000 1.000 1.278 2400
psi[6] 1.000 0.007 1.000 1.000 1.000 1.000 1.000 1.285 3000
psi[7] 0.998 0.021 1.000 1.000 1.000 1.000 1.000 1.114 1700
.......and so forth -> psi[88]