library(coda)
library(runjags)
head(tick2)
## d m n lyme hostHindexAll emptyVariable log_hostPELEprop
## 601 360 4 22 8 1.819 -1.1301030
## 602 360 13 14 6 1.890 -0.7550226
## 603 240 44 44 15 2.568 -1.1488535
## 604 360 17 13 4 1.582 -0.7918632
## 605 360 40 16 7 2.017 -0.4019712
## 606 330 0 22 11 0.555 -0.1996712
## log_hostTASTprop log_hostBLBRprop
## 601 -5.298317 -1.316768
## 602 -1.987774 -1.241329
## 603 -1.067114 -2.830218
## 604 -2.180367 -1.619488
## 605 -5.298317 -2.465104
## 606 -5.298317 -1.931022
\[ \begin{aligned} \text{[2.2a]} && \left. z_{ij} \right| p_i^B \sim \text{(ind) Bernoulli}(p_i^B) \\ \text{[2.3]} && \left. \text{logit } p_i^B \right| \alpha_0, \boldsymbol{\alpha}, \tau^2, \boldsymbol{x}_i \sim \text{(ind) } N(\alpha_0 + \boldsymbol{x}_i ' \boldsymbol{\alpha}, \tau^2) \\ \text{[2.6]} && \left. v_{ij} \right| \{z_{ij}=1\}, p_i^S \sim \text{(ind) Bernoulli}(p_i^S) \\ \text{[2.4c]} && \left. t_{ij} \right| \{z_{ij}=1\}, \{v_{ij}=1\}, p_i^{SH} \sim \text{(ind) Bernoulli}(p_i^{SH}) \\ \text{[2.4c1]} && \left. t_{ij} \right| \{z_{ij}=1\}, \{v_{ij}=0\}, p_i^{FH} \sim \text{(ind) Bernoulli}(p_i^{FH}) \\ \text{[2.7]} && p_i^S = \frac{1-p_i^c/p_i^{FH}}{1-p_i^{SH}/p_i^{FH}} \\ && p_i^{SH} < p_i^c < p_i^{FH} \\ \text{[2.5]} && \text{logit } p_i^c \left| \gamma_0, \boldsymbol{\gamma}, \omega^2, \boldsymbol{x}_i \right. \sim \text{(ind) } N(\gamma_0 + \boldsymbol{x}_i ' \boldsymbol{\gamma}, \omega^2) \\ \end{aligned} \]
print(dat.c) # covariates have been centered
## $S
## [1] 30
##
## $x
## hostHindexAll emptyVariable log_hostPELEprop log_hostTASTprop
## 601 -0.15313333 -0.386414919 -2.77860025
## 602 -0.08213333 -0.011334547 0.53194277
## 603 0.59586667 -0.405165468 1.45260350
## 604 -0.39013333 -0.048175117 0.33934966
## 605 0.04486667 0.341716818 -2.77860025
## 606 -1.41713333 0.544016842 -2.77860025
## 607 0.73686667 -0.258705394 1.39270536
## 608 0.01186667 0.062469427 -2.77860025
## 609 -0.13613333 -0.059274010 2.01055678
## 610 0.67486667 0.163869542 0.47949629
## 611 -0.21713333 0.459997986 -0.86167763
## 612 -0.08413333 -0.017737984 1.14929611
## 613 -0.16713333 -0.272423030 1.54155098
## 614 -0.20913333 0.387013093 1.67574705
## 615 0.06086667 0.195506627 -0.04423274
## 616 0.36086667 0.268872851 0.78244584
## 617 0.66686667 0.247751026 -0.21365089
## 618 0.30586667 0.311365475 0.94949992
## 619 0.33586667 0.188562154 0.03080245
## 620 0.56186667 0.127501898 0.24669083
## 621 -0.35113333 -0.518620344 1.19921050
## 622 0.69686667 -0.275189284 0.46399211
## 623 -0.31313333 -0.323425585 1.12941474
## 624 0.38586667 -0.075022367 0.32149204
## 625 0.21386667 0.278472924 -2.77860025
## 626 -0.18013333 0.458669082 -2.77860025
## 627 -0.37313333 0.249391715 1.56520518
## 628 -0.91313333 -2.036932857 1.85806861
## 629 -0.36913333 0.408215301 -2.77860025
## 630 -0.29713333 -0.004971854 1.44969229
## log_hostBLBRprop
## 601 0.83156557
## 602 0.90700528
## 603 -0.68188397
## 604 0.52884562
## 605 -0.31677015
## 606 0.21731233
## 607 0.48760266
## 608 0.16055952
## 609 0.73364003
## 610 0.45551435
## 611 -0.28208460
## 612 -0.71637014
## 613 0.72951632
## 614 -0.46896197
## 615 0.21731233
## 616 0.02807033
## 617 0.39387018
## 618 1.09565051
## 619 -3.14998350
## 620 0.52378232
## 621 -0.27078504
## 622 -0.19507322
## 623 1.29501794
## 624 0.45551435
## 625 0.76603153
## 626 -3.14998350
## 627 0.20342322
## 628 -3.14998350
## 629 0.73774682
## 630 1.61389838
##
## $n_noLyme
## 601 602 603 604 605
## 14 8 29 9 9
## 606 607 608 609 610
## 11 22 28 4 17
## 611 612 613 614 615
## 9 1 7 11 27
## 616 617 618 619 620
## 20 21 28 19 22
## 621 622 623 624 625
## 26 13 6 18 24
## 626 627 628 629 630
## 24 21 26 8 13
##
## $z_noLyme
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [2,] 0 0 0 0 0 0 0 0 -999 -999 -999 -999 -999
## [3,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [4,] 0 0 0 0 0 0 0 0 0 -999 -999 -999 -999
## [5,] 0 0 0 0 0 0 0 0 0 -999 -999 -999 -999
## [6,] 0 0 0 0 0 0 0 0 0 0 0 -999 -999
## [7,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [8,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [9,] 0 0 0 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [11,] 0 0 0 0 0 0 0 0 0 -999 -999 -999 -999
## [12,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] 0 0 0 0 0 0 0 -999 -999 -999 -999 -999 -999
## [14,] 0 0 0 0 0 0 0 0 0 0 0 -999 -999
## [15,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [16,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [17,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [18,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [19,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [20,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [21,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [22,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [23,] 0 0 0 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [24,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [25,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [26,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [27,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [28,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [29,] 0 0 0 0 0 0 0 0 -999 -999 -999 -999 -999
## [30,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [2,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [3,] 0 0 0 0 0 0 0 0 0 0 0
## [4,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [5,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [6,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [7,] 0 0 0 0 0 0 0 0 0 -999 -999
## [8,] 0 0 0 0 0 0 0 0 0 0 0
## [9,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 0 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [11,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [12,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [15,] 0 0 0 0 0 0 0 0 0 0 0
## [16,] 0 0 0 0 0 0 0 -999 -999 -999 -999
## [17,] 0 0 0 0 0 0 0 0 -999 -999 -999
## [18,] 0 0 0 0 0 0 0 0 0 0 0
## [19,] 0 0 0 0 0 0 -999 -999 -999 -999 -999
## [20,] 0 0 0 0 0 0 0 0 0 -999 -999
## [21,] 0 0 0 0 0 0 0 0 0 0 0
## [22,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] 0 0 0 0 0 -999 -999 -999 -999 -999 -999
## [25,] 0 0 0 0 0 0 0 0 0 0 0
## [26,] 0 0 0 0 0 0 0 0 0 0 0
## [27,] 0 0 0 0 0 0 0 0 -999 -999 -999
## [28,] 0 0 0 0 0 0 0 0 0 0 0
## [29,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [,25] [,26] [,27] [,28] [,29]
## [1,] -999 -999 -999 -999 -999
## [2,] -999 -999 -999 -999 -999
## [3,] 0 0 0 0 0
## [4,] -999 -999 -999 -999 -999
## [5,] -999 -999 -999 -999 -999
## [6,] -999 -999 -999 -999 -999
## [7,] -999 -999 -999 -999 -999
## [8,] 0 0 0 0 -999
## [9,] -999 -999 -999 -999 -999
## [10,] -999 -999 -999 -999 -999
## [11,] -999 -999 -999 -999 -999
## [12,] -999 -999 -999 -999 -999
## [13,] -999 -999 -999 -999 -999
## [14,] -999 -999 -999 -999 -999
## [15,] 0 0 0 -999 -999
## [16,] -999 -999 -999 -999 -999
## [17,] -999 -999 -999 -999 -999
## [18,] 0 0 0 0 -999
## [19,] -999 -999 -999 -999 -999
## [20,] -999 -999 -999 -999 -999
## [21,] 0 0 -999 -999 -999
## [22,] -999 -999 -999 -999 -999
## [23,] -999 -999 -999 -999 -999
## [24,] -999 -999 -999 -999 -999
## [25,] -999 -999 -999 -999 -999
## [26,] -999 -999 -999 -999 -999
## [27,] -999 -999 -999 -999 -999
## [28,] 0 0 -999 -999 -999
## [29,] -999 -999 -999 -999 -999
## [30,] -999 -999 -999 -999 -999
##
## $t_noLyme
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [2,] 0 0 0 0 0 0 0 0 -999 -999 -999 -999 -999
## [3,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [4,] 0 0 0 0 0 0 0 0 0 -999 -999 -999 -999
## [5,] 0 0 0 0 0 0 0 0 0 -999 -999 -999 -999
## [6,] 0 0 0 0 0 0 0 0 0 0 0 -999 -999
## [7,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [8,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [9,] 0 0 0 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [11,] 0 0 0 0 0 0 0 0 0 -999 -999 -999 -999
## [12,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] 0 0 0 0 0 0 0 -999 -999 -999 -999 -999 -999
## [14,] 0 0 0 0 0 0 0 0 0 0 0 -999 -999
## [15,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [16,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [17,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [18,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [19,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [20,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [21,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [22,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [23,] 0 0 0 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [24,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [25,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [26,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [27,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [28,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [29,] 0 0 0 0 0 0 0 0 -999 -999 -999 -999 -999
## [30,] 0 0 0 0 0 0 0 0 0 0 0 0 0
## [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [2,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [3,] 0 0 0 0 0 0 0 0 0 0 0
## [4,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [5,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [6,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [7,] 0 0 0 0 0 0 0 0 0 -999 -999
## [8,] 0 0 0 0 0 0 0 0 0 0 0
## [9,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 0 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [11,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [12,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [15,] 0 0 0 0 0 0 0 0 0 0 0
## [16,] 0 0 0 0 0 0 0 -999 -999 -999 -999
## [17,] 0 0 0 0 0 0 0 0 -999 -999 -999
## [18,] 0 0 0 0 0 0 0 0 0 0 0
## [19,] 0 0 0 0 0 0 -999 -999 -999 -999 -999
## [20,] 0 0 0 0 0 0 0 0 0 -999 -999
## [21,] 0 0 0 0 0 0 0 0 0 0 0
## [22,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] 0 0 0 0 0 -999 -999 -999 -999 -999 -999
## [25,] 0 0 0 0 0 0 0 0 0 0 0
## [26,] 0 0 0 0 0 0 0 0 0 0 0
## [27,] 0 0 0 0 0 0 0 0 -999 -999 -999
## [28,] 0 0 0 0 0 0 0 0 0 0 0
## [29,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [,25] [,26] [,27] [,28] [,29]
## [1,] -999 -999 -999 -999 -999
## [2,] -999 -999 -999 -999 -999
## [3,] 0 0 0 0 0
## [4,] -999 -999 -999 -999 -999
## [5,] -999 -999 -999 -999 -999
## [6,] -999 -999 -999 -999 -999
## [7,] -999 -999 -999 -999 -999
## [8,] 0 0 0 0 -999
## [9,] -999 -999 -999 -999 -999
## [10,] -999 -999 -999 -999 -999
## [11,] -999 -999 -999 -999 -999
## [12,] -999 -999 -999 -999 -999
## [13,] -999 -999 -999 -999 -999
## [14,] -999 -999 -999 -999 -999
## [15,] 0 0 0 -999 -999
## [16,] -999 -999 -999 -999 -999
## [17,] -999 -999 -999 -999 -999
## [18,] 0 0 0 0 -999
## [19,] -999 -999 -999 -999 -999
## [20,] -999 -999 -999 -999 -999
## [21,] 0 0 -999 -999 -999
## [22,] -999 -999 -999 -999 -999
## [23,] -999 -999 -999 -999 -999
## [24,] -999 -999 -999 -999 -999
## [25,] -999 -999 -999 -999 -999
## [26,] -999 -999 -999 -999 -999
## [27,] -999 -999 -999 -999 -999
## [28,] 0 0 -999 -999 -999
## [29,] -999 -999 -999 -999 -999
## [30,] -999 -999 -999 -999 -999
##
## $n_RLB
## 601 602 603 604 605
## 4 2 12 1 3
## 606 607 608 609 610
## 7 11 3 3 14
## 611 612 613 614 615
## 7 0 4 6 4
## 616 617 618 619 620
## 14 10 13 0 7
## 621 622 623 624 625
## 2 3 3 13 1
## 626 627 628 629 630
## 8 6 2 2 2
##
## $z_RLB
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] 1 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [2,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [3,] 1 1 1 1 1 1 1 1 1 1 1 1 -999
## [4,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [5,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [6,] 1 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999
## [7,] 1 1 1 1 1 1 1 1 1 1 1 -999 -999
## [8,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [9,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [11,] 1 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999
## [12,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] 1 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [15,] 1 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [16,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [17,] 1 1 1 1 1 1 1 1 1 1 -999 -999 -999
## [18,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [19,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [20,] 1 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999
## [21,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [22,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [25,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [26,] 1 1 1 1 1 1 1 1 -999 -999 -999 -999 -999
## [27,] 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [28,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [29,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [,14]
## [1,] -999
## [2,] -999
## [3,] -999
## [4,] -999
## [5,] -999
## [6,] -999
## [7,] -999
## [8,] -999
## [9,] -999
## [10,] 1
## [11,] -999
## [12,] -999
## [13,] -999
## [14,] -999
## [15,] -999
## [16,] 1
## [17,] -999
## [18,] -999
## [19,] -999
## [20,] -999
## [21,] -999
## [22,] -999
## [23,] -999
## [24,] -999
## [25,] -999
## [26,] -999
## [27,] -999
## [28,] -999
## [29,] -999
## [30,] -999
##
## $v_RLB
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] 1 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [2,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [3,] 1 1 1 1 1 1 1 1 1 1 1 1 -999
## [4,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [5,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [6,] 1 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999
## [7,] 1 1 1 1 1 1 1 1 1 1 1 -999 -999
## [8,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [9,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [11,] 1 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999
## [12,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] 1 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [15,] 1 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [16,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [17,] 1 1 1 1 1 1 1 1 1 1 -999 -999 -999
## [18,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [19,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [20,] 1 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999
## [21,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [22,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] 1 1 1 1 1 1 1 1 1 1 1 1 1
## [25,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [26,] 1 1 1 1 1 1 1 1 -999 -999 -999 -999 -999
## [27,] 1 1 1 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [28,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [29,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [,14]
## [1,] -999
## [2,] -999
## [3,] -999
## [4,] -999
## [5,] -999
## [6,] -999
## [7,] -999
## [8,] -999
## [9,] -999
## [10,] 1
## [11,] -999
## [12,] -999
## [13,] -999
## [14,] -999
## [15,] -999
## [16,] 1
## [17,] -999
## [18,] -999
## [19,] -999
## [20,] -999
## [21,] -999
## [22,] -999
## [23,] -999
## [24,] -999
## [25,] -999
## [26,] -999
## [27,] -999
## [28,] -999
## [29,] -999
## [30,] -999
##
## $t_RLB
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## [1,] 1 1 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [2,] 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [3,] 1 0 0 1 1 1 1 1 1 1 0 0 -999
## [4,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [5,] 0 1 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [6,] 0 0 1 0 1 1 0 -999 -999 -999 -999 -999 -999
## [7,] 0 1 1 1 1 1 1 0 0 1 1 -999 -999
## [8,] 1 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [9,] 0 1 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 1 1 0 0 0 1 1 1 0 1 1 1 1
## [11,] 0 1 0 0 0 0 1 -999 -999 -999 -999 -999 -999
## [12,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] 0 1 1 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] 0 0 0 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [15,] 1 1 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [16,] 0 1 1 1 0 1 0 1 1 1 0 1 1
## [17,] 0 1 1 1 1 0 1 0 0 1 -999 -999 -999
## [18,] 1 1 1 0 1 0 0 0 0 1 1 0 1
## [19,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [20,] 0 0 0 0 0 1 1 -999 -999 -999 -999 -999 -999
## [21,] 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [22,] 0 1 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] 1 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] 1 1 1 0 0 1 0 1 0 1 0 1 1
## [25,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [26,] 0 0 0 0 0 0 1 0 -999 -999 -999 -999 -999
## [27,] 0 1 1 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [28,] 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [29,] 0 1 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] 0 0 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [,14]
## [1,] -999
## [2,] -999
## [3,] -999
## [4,] -999
## [5,] -999
## [6,] -999
## [7,] -999
## [8,] -999
## [9,] -999
## [10,] 1
## [11,] -999
## [12,] -999
## [13,] -999
## [14,] -999
## [15,] -999
## [16,] 1
## [17,] -999
## [18,] -999
## [19,] -999
## [20,] -999
## [21,] -999
## [22,] -999
## [23,] -999
## [24,] -999
## [25,] -999
## [26,] -999
## [27,] -999
## [28,] -999
## [29,] -999
## [30,] -999
##
## $n_noRLB
## 601 602 603 604 605
## 4 4 3 3 4
## 606 607 608 609 610
## 4 3 1 1 1
## 611 612 613 614 615
## 1 1 0 5 0
## 616 617 618 619 620
## 5 3 5 1 2
## 621 622 623 624 625
## 5 0 1 10 3
## 626 627 628 629 630
## 3 1 2 1 1
##
## $z_noRLB
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] 1 1 1 1 -999 -999 -999 -999 -999 -999
## [2,] 1 1 1 1 -999 -999 -999 -999 -999 -999
## [3,] 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [4,] 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [5,] 1 1 1 1 -999 -999 -999 -999 -999 -999
## [6,] 1 1 1 1 -999 -999 -999 -999 -999 -999
## [7,] 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [8,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [9,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [11,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [12,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] 1 1 1 1 1 -999 -999 -999 -999 -999
## [15,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [16,] 1 1 1 1 1 -999 -999 -999 -999 -999
## [17,] 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [18,] 1 1 1 1 1 -999 -999 -999 -999 -999
## [19,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [20,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999
## [21,] 1 1 1 1 1 -999 -999 -999 -999 -999
## [22,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] 1 1 1 1 1 1 1 1 1 1
## [25,] 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [26,] 1 1 1 -999 -999 -999 -999 -999 -999 -999
## [27,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [28,] 1 1 -999 -999 -999 -999 -999 -999 -999 -999
## [29,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] 1 -999 -999 -999 -999 -999 -999 -999 -999 -999
##
## $v_noRLB
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] 0 0 0 0 -999 -999 -999 -999 -999 -999
## [2,] 0 0 0 0 -999 -999 -999 -999 -999 -999
## [3,] 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [4,] 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [5,] 0 0 0 0 -999 -999 -999 -999 -999 -999
## [6,] 0 0 0 0 -999 -999 -999 -999 -999 -999
## [7,] 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [8,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [9,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [11,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [12,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] 0 0 0 0 0 -999 -999 -999 -999 -999
## [15,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [16,] 0 0 0 0 0 -999 -999 -999 -999 -999
## [17,] 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [18,] 0 0 0 0 0 -999 -999 -999 -999 -999
## [19,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [20,] 0 0 -999 -999 -999 -999 -999 -999 -999 -999
## [21,] 0 0 0 0 0 -999 -999 -999 -999 -999
## [22,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] 0 0 0 0 0 0 0 0 0 0
## [25,] 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [26,] 0 0 0 -999 -999 -999 -999 -999 -999 -999
## [27,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [28,] 0 0 -999 -999 -999 -999 -999 -999 -999 -999
## [29,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] 0 -999 -999 -999 -999 -999 -999 -999 -999 -999
##
## $t_noRLB
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] NA NA NA NA -999 -999 -999 -999 -999 -999
## [2,] NA NA NA NA -999 -999 -999 -999 -999 -999
## [3,] NA NA NA -999 -999 -999 -999 -999 -999 -999
## [4,] NA NA NA -999 -999 -999 -999 -999 -999 -999
## [5,] NA NA NA NA -999 -999 -999 -999 -999 -999
## [6,] NA NA NA NA -999 -999 -999 -999 -999 -999
## [7,] NA NA NA -999 -999 -999 -999 -999 -999 -999
## [8,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [9,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [10,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [11,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [12,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [13,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [14,] NA NA NA NA NA -999 -999 -999 -999 -999
## [15,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [16,] NA NA NA NA NA -999 -999 -999 -999 -999
## [17,] NA NA NA -999 -999 -999 -999 -999 -999 -999
## [18,] NA NA NA NA NA -999 -999 -999 -999 -999
## [19,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [20,] NA NA -999 -999 -999 -999 -999 -999 -999 -999
## [21,] NA NA NA NA NA -999 -999 -999 -999 -999
## [22,] -999 -999 -999 -999 -999 -999 -999 -999 -999 -999
## [23,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [24,] NA NA NA NA NA NA NA NA NA NA
## [25,] NA NA NA -999 -999 -999 -999 -999 -999 -999
## [26,] NA NA NA -999 -999 -999 -999 -999 -999 -999
## [27,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [28,] NA NA -999 -999 -999 -999 -999 -999 -999 -999
## [29,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
## [30,] NA -999 -999 -999 -999 -999 -999 -999 -999 -999
jags.script.c <- "
model{ # realistic, RLB, alpha_2=gamma_2=0 (ignore emptyVariable)
########################### NOTE ##########################
##
## To reflect conditional binomials, partition n_i for
## each i into
##
## n_i = n_i_noLyme + n_i_RLB + n_i_noRLB
##
## and similarly for the associated data vectors z_i, t_i, v_i.
## Thus, if the partition is irrelevant to the model statement
## (e.g. Eq. [2.2a]), then must use same distribution (with
## same parameters) over all loop partitions under likelihood.
##
##############################################################
# ---------- definitions
tau <- 1/sqrt(tausq.inv) # SD in eq 2.3
omega <- 1/sqrt(omsq.inv) # SD in eq 2.5
alph[2] <- 0
gam[2] <- 0
for(i in 1:S){
pB[i] <- ilogit(logitpB[i])
pC[i] <- ilogit(logitpC[i])
pS[i] <- (1-pC[i]/pFH[i])/(1-pSH[i]/pFH[i]) # eq 2.7
logitpS[i] <- logit(pS[i])
logitpSH[i] <- logit(pSH[i])
logitpFH[i] <- logit(pFH[i])
nuL[i] <- alph0 + alph[1] * x[i,1] + inprod(alph[3:5], x[i,3:5]) # mean in eq 2.3
nuH[i] <- gam0 + gam[1] * x[i,1] + inprod(gam[3:5], x[i,3:5]) # mean in eq 2.5
}
# ---------- likelihood
for(i in 1:S){
logitpB[i] ~ dnorm(nuL[i], tausq.inv) # eq 2.3
logitpC[i] ~ dnorm(nuH[i], omsq.inv) # eq 2.5
for(j in 1:n_noLyme[i]){ # z=0
z_noLyme[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR-
}
}
for(i in 1:12){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pFH[i]) # eq 2.4c1
}
}
for(i in 14:14){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pFH[i]) # eq 2.4c1
}
}
for(i in 16:21){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pFH[i]) # eq 2.4c1
}
}
for(i in 23:S){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pFH[i]) # eq 2.4c1
}
}
for(i in 1:11){ # z=v=1
for(j in 1:n_RLB[i]){
z_RLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 1
v_RLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 1
t_RLB[i,j] ~ dbern(pSH[i]) # eq 2.4c
}
}
for(i in 13:18){ # z=v=1
for(j in 1:n_RLB[i]){
z_RLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 1
v_RLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 1
t_RLB[i,j] ~ dbern(pSH[i]) # eq 2.4c
}
}
for(i in 20:S){ # z=v=1
for(j in 1:n_RLB[i]){
z_RLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 1
v_RLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 1
t_RLB[i,j] ~ dbern(pSH[i]) # eq 2.4c
}
}
# ---------- priors
tausq.inv ~ dgamma(1, .01)
omsq.inv ~ dgamma(1, .01)
alph0 ~ dnorm(0, .001)
gam0 ~ dnorm(0, .001)
alph[1] ~ dnorm(0, .001)
gam[1] ~ dnorm(0, .001)
for(k in 3:5){
alph[k] ~ dnorm(0, .001)
gam[k] ~ dnorm(0, .001)
}
for(i in 1:S){
pSH[i] ~ dunif(0, pC[i])
pFH[i] ~ dunif(pC[i], 1)
}
}
"
fit.c <- run.jags(jags.script.c, data=dat.c, n.chains=2,
inits=list(tausq.inv=1, omsq.inv=1),
adapt=10000, burnin=5000, sample=5000, thin=10,
monitor=c(
"t_noRLB[1,1]","t_noRLB[1,2]","t_noRLB[1,3]","t_noRLB[1,4]",
"t_noRLB[2,1]","t_noRLB[2,2]","t_noRLB[2,3]","t_noRLB[2,4]",
"t_noRLB[3,1]","t_noRLB[3,2]","t_noRLB[3,3]",
"t_noRLB[4,1]","t_noRLB[4,2]","t_noRLB[4,3]",
"t_noRLB[5,1]","t_noRLB[5,2]","t_noRLB[5,3]","t_noRLB[5,4]",
"t_noRLB[6,1]","t_noRLB[6,2]","t_noRLB[6,3]","t_noRLB[6,4]",
"t_noRLB[7,1]","t_noRLB[7,2]","t_noRLB[7,3]",
"t_noRLB[8,1]",
"t_noRLB[9,1]",
"t_noRLB[10,1]",
"t_noRLB[11,1]",
"t_noRLB[12,1]",
"t_noRLB[14,1]","t_noRLB[14,2]","t_noRLB[14,3]","t_noRLB[14,4]","t_noRLB[14,5]",
"t_noRLB[16,1]","t_noRLB[16,2]","t_noRLB[16,3]","t_noRLB[16,4]","t_noRLB[16,5]",
"t_noRLB[17,1]","t_noRLB[17,2]","t_noRLB[17,3]",
"t_noRLB[18,1]","t_noRLB[18,2]","t_noRLB[18,3]","t_noRLB[18,4]","t_noRLB[18,5]",
"t_noRLB[19,1]",
"t_noRLB[20,1]","t_noRLB[20,2]",
"t_noRLB[21,1]","t_noRLB[21,2]","t_noRLB[21,3]","t_noRLB[21,4]","t_noRLB[21,5]",
"t_noRLB[23,1]",
"t_noRLB[24,1]","t_noRLB[24,2]","t_noRLB[24,3]","t_noRLB[24,4]","t_noRLB[24,5]",
"t_noRLB[24,6]","t_noRLB[24,7]","t_noRLB[24,8]","t_noRLB[24,9]","t_noRLB[24,10]",
"t_noRLB[25,1]","t_noRLB[25,2]","t_noRLB[25,3]",
"t_noRLB[26,1]","t_noRLB[26,2]","t_noRLB[26,3]",
"t_noRLB[27,1]",
"t_noRLB[28,1]","t_noRLB[28,2]",
"t_noRLB[29,1]",
"t_noRLB[30,1]",
"logitpB","logitpC","logitpS","logitpSH","logitpFH",
"alph0","alph","gam0","gam","tau","omega","deviance",
"pd","dic"))
## module dic loaded
## Compiling rjags model...
## Calling the simulation using the rjags method...
## Adapting the model for 10000 iterations...
## |++++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Burning in the model for 5000 iterations...
## |**************************************************| 100%
## Running the model for 50000 iterations...
## |**************************************************| 100%
## Extending 50000 iterations for pD/DIC estimates...
## |**************************************************| 100%
## Simulation complete
## Calculating summary statistics...
## Note: The monitored variables 'alph[2]' and 'gam[2]' appear to be non-stochastic; they will not be included in the
## convergence diagnostic
## Calculating the Gelman-Rubin statistic for 243 variables....
## Finished running the simulation
## Warning messages:
## 1: The length of the initial values argument supplied found does not correspond to the number of chains specified. Some initial values were recycled or ignored.
## 2: In rjags::jags.model(model, data = dataenv, inits = inits, n.chains = length(runjags.object$end.state), :
## Unused variable "t_noLyme" in data
## 3: In rjags::jags.samples(rjags, variable.names = monitor, n.iter = extra.options$sample, :
## Failed to set trace monitor for pD
## pD is infinite because at least one observed node does not have fixed support
See this for discussion on infinite pD
.
scans.c <- as.mcmc.list(fit.c)
scans.c.pooled <- rbind(scans.c[[1]], scans.c[[2]])
fit.c$runjags.version
## [1] "2.0.2-8" "R version 3.2.2 (2015-08-14)"
## [3] "unix" "RStudio"
## [5] "mac.binary.mavericks" "2015-09-20 17:07:51"
fit.c$psrf$mpsrf # Gelman-Rubin convergence check
## [1] 1.03492
fit.c.dic.alt <- mean(scans.c.pooled[,"deviance"]) + var(scans.c.pooled[,"deviance"])/2
fit.c.dic.alt
## [1] 1511.262
pval <- apply(scans.c.pooled[,c(230,232:234,236,238:240)], 2, ecdf) # placeholder
pval <- sapply(pval,do.call,args=list(0))
pval <- data.frame(lefttail=pval,righttail=1-pval,
median=apply(scans.cNoS.pooled[,c(230,232:234,236,238:240)], 2, median))
tmp <- subset(pval,lefttail<.5)
pval <- rbind(tmp, subset(pval,righttail<.5))
print(pval) # posterior probs of < 0 (lefttail) and > 0 (righttail) -- tails sum to 1
## lefttail righttail median
## alph[3] 0.0370 0.9630 0.52465413
## alph[4] 0.1062 0.8938 0.09940828
## alph[5] 0.0993 0.9007 0.12994497
## gam[1] 0.2579 0.7421 0.20047632
## gam[5] 0.0461 0.9539 0.25656229
## alph[1] 0.5721 0.4279 -0.04478082
## gam[3] 0.9614 0.0386 -0.72719620
## gam[4] 0.6976 0.3024 -0.06117828
par(mfrow=c(4,3))
traceplot(scans.c)
Note with dgamma(1, .001)
then larger DIC and poorer mixing (i.e., not our model of choice):
## > fit.c.dic.alt # with dgamma(1, .001)
## [1] 1558.504
\[ \begin{aligned} \text{[2.2a]} && \left. z_{ij} \right| p_i^B \sim \text{(ind) Bernoulli}(p_i^B) \\ \text{[2.3]} && \left. \text{logit } p_i^B \right| \alpha_0, \boldsymbol{\alpha}, \tau^2, \boldsymbol{x}_i \sim \text{(ind) } N(\alpha_0 + \boldsymbol{x}_i ' \boldsymbol{\alpha}, \tau^2) \\ \text{[2.6]} && \left. v_{ij} \right| \{z_{ij}=1\}, p_i^S \sim \text{(ind) Bernoulli}(p_i^S) \\ \text{[3.1a]} && \left. t_{ij} \right| p_i^B, p_i^c \sim \text{(ind) Bernoulli}(p_i^B p_i^c) \\ \text{[2.7a]} && p_i^S = \frac{1-p_i^c/p_i^{FH}}{1-p_i^{SH}/p_i^{FH}} \\ && p_i^{SH} < p_i^c < p_i^{FH} \\ \text{[2.5]} && \text{logit } p_i^c \left| \gamma_0, \boldsymbol{\gamma}, \omega^2, \boldsymbol{x}_i \right. \sim \text{(ind) } N(\gamma_0 + \boldsymbol{x}_i ' \boldsymbol{\gamma}, \omega^2) \\ \end{aligned} \]
jags.script.cc <- "
model{ # hypothetical, RLB, alpha_2=gamma_2=0 (ignore emptyVariable)
########################### NOTE ##########################
##
## To reflect conditional binomials, partition n_i for
## each i into
##
## n_i = n_i_noLyme + n_i_RLB + n_i_noRLB
##
## and similarly for the associated data vectors z_i, t_i, v_i.
## Thus, if the partition is irrelevant to the model statement
## (e.g. Eq. [3.1a]), then must use same distribution (with
## same parameters) over all loop partitions under likelihood.
##
##############################################################
# ---------- definitions
tau <- 1/sqrt(tausq.inv) # SD in eq 2.3
omega <- 1/sqrt(omsq.inv) # SD in eq 2.5
alph[2] <- 0
gam[2] <- 0
for(i in 1:S){
pB[i] <- ilogit(logitpB[i])
pC[i] <- ilogit(logitpC[i])
pS[i] <- (1-pC[i]/pFH[i])/(1-pSH[i]/pFH[i]) # eq 2.7
logitpS[i] <- logit(pS[i])
pH[i] <- pB[i] * pC[i] # inside eq. 3.1a
logitpSH[i] <- logit(pSH[i])
logitpFH[i] <- logit(pFH[i])
nuL[i] <- alph0 + alph[1] * x[i,1] + inprod(alph[3:5], x[i,3:5]) # mean in eq 2.3
nuH[i] <- gam0 + alph[1] * x[i,1] + inprod(gam[3:5], x[i,3:5]) # mean in eq 2.5
}
# ---------- likelihood
for(i in 1:S){
logitpB[i] ~ dnorm(nuL[i], tausq.inv) # eq 2.3
logitpC[i] ~ dnorm(nuH[i], omsq.inv) # eq 2.5
for(j in 1:n_noLyme[i]){ # z=0
z_noLyme[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR-
t_noLyme[i,j] ~ dbern(pH[i]) # eq 3.1a for PCR-
}
}
for(i in 1:12){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pH[i]) # eq 3.1a for PCR+, v[i,j] = 0
}
}
for(i in 14:14){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pH[i]) # eq 3.1a for PCR+, v[i,j] = 0
}
}
for(i in 16:21){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pH[i]) # eq 3.1a for PCR+, v[i,j] = 0
}
}
for(i in 23:S){ # z=1, v=0
for(j in 1:n_noRLB[i]){
z_noRLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 0
v_noRLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 0
t_noRLB[i,j] ~ dbern(pFH[i]) # eq 3.1a for PCR+, v[i,j] = 0
}
}
for(i in 1:11){ # z=v=1
for(j in 1:n_RLB[i]){
z_RLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 1
v_RLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 1
t_RLB[i,j] ~ dbern(pSH[i]) # eq 3.1a for PCR+, v[i,j] = 1
}
}
for(i in 13:18){ # z=v=1
for(j in 1:n_RLB[i]){
z_RLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 1
v_RLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 1
t_RLB[i,j] ~ dbern(pSH[i]) # eq 3.1a for PCR+, v[i,j] = 1
}
}
for(i in 20:S){ # z=v=1
for(j in 1:n_RLB[i]){
z_RLB[i,j] ~ dbern(pB[i]) # eq 2.2 for PCR+, v[i,j] = 1
v_RLB[i,j] ~ dbern(pS[i]) # eq 2.6 for PCR+, v[i,j] = 1
t_RLB[i,j] ~ dbern(pSH[i]) # eq 3.1a for PCR+, v[i,j] = 1
}
}
# ---------- priors
tausq.inv ~ dgamma(1, .01)
omsq.inv ~ dgamma(1, .01)
alph0 ~ dnorm(0, .001)
gam0 ~ dnorm(0, .001)
alph[1] ~ dnorm(0, .001)
gam[1] ~ dnorm(0, .001)
for(k in 3:5){
alph[k] ~ dnorm(0, .001)
gam[k] ~ dnorm(0, .001)
}
for(i in 1:S){
pSH[i] ~ dunif(0, pC[i])
pFH[i] ~ dunif(pC[i], 1)
}
}
"
fit.cc <- run.jags(jags.script.cc, data=dat.c, n.chains=2,
inits=list(tausq.inv=1, omsq.inv=1),
adapt=10000, burnin=10000, sample=5000, thin=10,
monitor=c(
"t_noRLB[1,1]","t_noRLB[1,2]","t_noRLB[1,3]","t_noRLB[1,4]",
"t_noRLB[2,1]","t_noRLB[2,2]","t_noRLB[2,3]","t_noRLB[2,4]",
"t_noRLB[3,1]","t_noRLB[3,2]","t_noRLB[3,3]",
"t_noRLB[4,1]","t_noRLB[4,2]","t_noRLB[4,3]",
"t_noRLB[5,1]","t_noRLB[5,2]","t_noRLB[5,3]","t_noRLB[5,4]",
"t_noRLB[6,1]","t_noRLB[6,2]","t_noRLB[6,3]","t_noRLB[6,4]",
"t_noRLB[7,1]","t_noRLB[7,2]","t_noRLB[7,3]",
"t_noRLB[8,1]",
"t_noRLB[9,1]",
"t_noRLB[10,1]",
"t_noRLB[11,1]",
"t_noRLB[12,1]",
"t_noRLB[14,1]","t_noRLB[14,2]","t_noRLB[14,3]","t_noRLB[14,4]","t_noRLB[14,5]",
"t_noRLB[16,1]","t_noRLB[16,2]","t_noRLB[16,3]","t_noRLB[16,4]","t_noRLB[16,5]",
"t_noRLB[17,1]","t_noRLB[17,2]","t_noRLB[17,3]",
"t_noRLB[18,1]","t_noRLB[18,2]","t_noRLB[18,3]","t_noRLB[18,4]","t_noRLB[18,5]",
"t_noRLB[19,1]",
"t_noRLB[20,1]","t_noRLB[20,2]",
"t_noRLB[21,1]","t_noRLB[21,2]","t_noRLB[21,3]","t_noRLB[21,4]","t_noRLB[21,5]",
"t_noRLB[23,1]",
"t_noRLB[24,1]","t_noRLB[24,2]","t_noRLB[24,3]","t_noRLB[24,4]","t_noRLB[24,5]",
"t_noRLB[24,6]","t_noRLB[24,7]","t_noRLB[24,8]","t_noRLB[24,9]","t_noRLB[24,10]",
"t_noRLB[25,1]","t_noRLB[25,2]","t_noRLB[25,3]",
"t_noRLB[26,1]","t_noRLB[26,2]","t_noRLB[26,3]",
"t_noRLB[27,1]",
"t_noRLB[28,1]","t_noRLB[28,2]",
"t_noRLB[29,1]",
"t_noRLB[30,1]",
"logitpB","logitpC","logitpS","logitpSH","logitpFH",
"alph0","alph","gam0","gam","tau","omega","deviance","pd","dic"))
## module dic loaded
## Compiling rjags model...
## Calling the simulation using the rjags method...
## Adapting the model for 10000 iterations...
## |++++++++++++++++++++++++++++++++++++++++++++++++++| 100%
## Burning in the model for 10000 iterations...
## |**************************************************| 100%
## Running the model for 50000 iterations...
## |**************************************************| 100%
## Extending 50000 iterations for pD/DIC estimates...
## |**************************************************| 100%
## Simulation complete
## Calculating summary statistics...
## Note: The monitored variables 'alph[2]' and 'gam[2]' appear to be non-stochastic; they will not be
## included in the convergence diagnostic
## Calculating the Gelman-Rubin statistic for 243 variables....
## Finished running the simulation
## Warning messages:
## 1: The length of the initial values argument supplied found does not correspond to the number of chains specified. Some initial values were recycled or ignored.
## 2: In rjags::jags.samples(rjags, variable.names = monitor, n.iter = extra.options$sample, :
## Failed to set trace monitor for pD
## pD is infinite because at least one observed node does not have fixed support
scans.cc <- as.mcmc.list(fit.cc)
scans.cc.pooled <- rbind(scans.cc[[1]], scans.cc[[2]])
fit.cc$psrf$mpsrf # Gelman-Rubin convergence check
## [1] 1.032797
fit.cc.dic.alt <- mean(scans.cc.pooled[,"deviance"]) + var(scans.cc.pooled[,"deviance"])/2
fit.cc.dic.alt
## [1] 1660.277
par(mfrow=c(4,3))
traceplot(scans.cc)