The BayesODT package is to fit a Bayesian hierarchical model for ordinal classification data. The methods are detailed in the following paper
Kim et al. Measuring Rater Bias in Diagnostic Tests with Ordinal Ratings (submitted).
The citation for this package is
Chanmin Kim (2019). BayesODT: Bayesian Ordinal Diagnostic Test. R package version 1.0.
The BayesODT package can be installed as follows
library(devtools)
install_github("lit777/BayesODT")
Call BayesODT
library(BayesODT)
This package contains a simulated dataset, simdata
, which can be loaded using data() function
data("simdata")
str(simdata)
## List of 2
## $ w: int [1:90, 1:50] 1 1 2 1 2 2 1 1 1 1 ...
## $ D: int [1:90] 1 0 1 0 1 0 0 0 0 0 ...
simdata
has the list format and includes two objects: w
: 90 (patients) by 50 (raters) classification matrix; D
: true disease statuses of 90 patients
Before fitting the BayesODT model, initial values and hyper-prior parameter values need to be set.
m <- dim(simdata$w)[1] # Num. of patients
n <- dim(simdata$w)[2] # Num. of raters
init <- list(z = matrix(1, nrow=m, ncol=n), z0 = rep(0, m), a = rnorm(n, 0, 1), b = rexp(n, 0.1), u = rnorm(m, 0, 1), A = c(-1,0,1,Inf))
prior <- list(mu_a = 0, tau_a = 1, mu_b = 0, tau_b = 1, delta = 5, gamma = 0.1, tau = 0.1, mu_u = 0, tau_u = 1)
When A
is not specified in the init
list, then BayesODT automatically estimates cut-points using the clmm
function from the ordinal R package. Also, when z0
is not specified in the init
list, then the model for true disease status (i.e., Model 1 in the manuscript) is not used.
Run BayesODT
fit <- BayesODT(w = simdata$w, D = simdata$D, init = init, prior = prior, n.iter = 4000, n.burnin = 2000, n.thin = 5, ROC =TRUE)
n.iter
, n.burnin
, n.thin
specify the number of MCMC iterations, the number of burn-in iterations, thinning every n.thin
iterations. ROC=TRUE
when the ROC curve is needed; otherwise, turn off this feature for faster sampling.
Obtain the posterior means and 95% C.I.s of the parameters
summary(fit)
Plot the posterior means and 95% C.I.s of the parameters
plot_ABU(fit)
Plot ROC curves
plot_ROC(fit, method=c("Individual"), ind=1)
One method
needs to be specified from c("Individual", "ROC1", "ROC2", "Smoothed.ROC", "Smoothed.pROC", "pROC")
. For more details, see the manuscript. When method="Individual
is specified, individual ID, ind
, needs to be specified.
plot_ROC(fit, method=c("Smoothed.ROC"))
To check goodness of fit of the model, one can compare the estimated marginal probability of W=k for each k to the corresponding empirical probability
GoF(fit)
## $Estimated.Prob
## [1] 0.57271621 0.31531326 0.05426874 0.05770179
##
## $Estimated.Prob.ci
## [,1] [,2] [,3] [,4]
## 2.5% 0.5634665 0.3067363 0.04951025 0.05462704
## 97.5% 0.5811577 0.3251839 0.05829169 0.06128687
##
## $Empirical.Prob
##
## 1 2 3 4
## 0.57355556 0.31444444 0.05488889 0.05711111