Skip to content

Instantly share code, notes, and snippets.

@jeffreypullin
Created March 8, 2024 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreypullin/eab57ccd47d02961afc056aed423b1e1 to your computer and use it in GitHub Desktop.
Save jeffreypullin/eab57ccd47d02961afc056aed423b1e1 to your computer and use it in GitHub Desktop.
library(rater)
# We have 'Unsure' ratings for the first three patients.
# We encode 'Unsure' = category 5.
anesthesia_w_unsure <- anesthesia
anesthesia_w_unsure[anesthesia$item %in% 1:3, "rating"] <- 5
# Taken from the rater() function's code.
J <- 5
K <- 4 + 1
N <- 8
p <- 0.6
on_diag <- N * p
off_diag <- N * (1 - p) / (K - 1)
beta_slice <- matrix(off_diag, nrow = K, ncol = K)
diag(beta_slice) <- on_diag
beta <- array(dim = c(J,K,K))
for (j in 1:5) {
beta[j, , ] <- beta_slice
}
for (j in 1:5) {
for (k in 1:5) {
# Value will need tweaking!
beta[j, k, ] <- rep(2, 5)
}
}
fit_w_unsure <- rater(anesthesia_w_unsure,
dawid_skene(beta = beta))
fit <- rater(anesthesia, "dawid_skene")
plot(fit, "theta")
plot(fit_w_unsure, "theta")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment