我一直在尝试将平滑融入我创建的 runjags 模型中,以模拟海鸟洞穴数量和整个岛屿的分布。通过从模型输出中提取计数数据以及 x 和 y 坐标并使用此页面http://www.petrkeil.com/?p=2385上的 JAGAM 教程,我设法生成了一些平滑代码
我想我可以通过将平滑合并到 jags 模型中来提高模型性能,但我不知道如何做到这一点。你能给我一些关于如何实现这一目标的指示吗?
我在下面附上了一段 runjags 代码和 JAGAM 输出。
runjags 代码:
for(i in 1:K) {
S1[i]~dpois(lambda1[i])
SS1[i]~dpois(lambda1[i])
lambda1[i]<-exp(a0+
a1*Tussac[i]+
a2*normalise_DEM_aspect[i]+
a3*normalise_DEM_slope[i]+
a4*Tussac[i]*normalise_DEM_aspect[i]+
a5*Tussac[i]*normalise_DEM_slope[i]+
a6*normalise_sentinel1[i]+
a7*normalise_setinel3[i]+
a8*normalise_sentinel4[i]+
a9*normalise_sentinel5[i]+
a10*normalise_sentinel8[i]+
a11*normalise_sentinel10[i]+
a12*S2[i])
}
JAGAM 输出:
readLines("jagam.bug")
"model {"
" eta <- X %*% b ## linear predictor"
" for (i in 1:n) { mu[i] <- exp(eta[i]) } ## expected response"
" for (i in 1:n) { y[i] ~ dpois(mu[i]) } ## response "
" ## Parametric effect priors CHECK tau=1/35^2 is appropriate!"
" for (i in 1:1) { b[i] ~ dnorm(0,0.00083) }"
" ## prior for s(x,y)... "
" K1 <- S1[1:29,1:29] * lambda[1] + S1[1:29,30:58] * lambda[2]"
" b[2:30] ~ dmnorm(zero[2:30],K1) "
" ## smoothing parameter priors CHECK..."
" for (i in 1:2) {"
" lambda[i] ~ dgamma(.05,.005)"
" rho[i] <- log(lambda[i])"
" }"
"}"
样本数据:
S1 Logit_tussac soil_moisture DEM_slope DEM_aspect DEM_elevation sentinel1 sentinel2 sentinel3 sentinel4 sentinel5 sentinel6 sentinel7 sentinel8 sentinel9 sentinel10
NA NA NA 14.917334 256.1612 12.24432 0.0513 0.0588 0.0541 0.1145 0.1676 0.1988 0.1977 0.1658 0.1566 0.0770
0 -9.210240 1 23.803741 225.1231 16.88028 0.1058 0.1370 0.2139 0.2387 0.2654 0.2933 0.3235 0.2928 0.3093 0.1601
NA NA NA 20.789165 306.0945 18.52480 0.0287 0.0279 0.0271 0.0276 0.0290 0.0321 0.0346 0.0452 0.0475 0.0219
NA -9.210240 1 6.689442 287.9641 36.08975 0.0462 0.0679 0.1274 0.1535 0.1797 0.2201 0.2982 0.2545 0.4170 0.2252
0 -9.210240 1 25.476444 203.0659 23.59964 0.0758 0.1041 0.1326 0.1571 0.2143 0.2486 0.2939 0.2536 0.3336 0.1937
1 -1.385919 3 1.672511 270.0000 39.55215 0.0466 0.0716 0.1227 0.1482 0.2215 0.2715 0.3334 0.2903 0.3577 0.1957