# Testing for visual cheating with RndTexExams

## Testing for cheating in exams

If you are still not convinced that students arenâ€™t cheating, you can use function rte.test.cheating to statistically test this hypothesis and detect suspicious pairs of students that may have copied their answers from each other. All of the tests performed by rte.test.cheating are based on package CopyDetect. The statistical tests available in CopyDetect are:

• Omega index (Wollack, 1996)
• Generalized Binomial Test ([GBT], van der Linden & Sotaridona (2006)
• K index (Holland, 1996)
• K1 and K2 indices (Sotaridona & Meijer, 2002)
• S1 and S2 indices (Sotaridona & Meijer, 2003) }

The mathematical details regarding the tests can be found here

The function rte.test.cheating will test the hypothesis of cheating using all seven approaches and for all unique pairwise combination of the students. The output of the function presents all the results of the tests as a dataframe and all the suspicious pairs of students, if found any. Next I present an example with simulated data.

library(RndTexExams, quietly = TRUE, warn.conflicts = TRUE)

n.sim.questions <- 15

first.names <- c('John', 'Marcelo','Ricardo', 'Tarcizio')
last.names <- c('Smith', 'Johnson', 'P.')

name.grid <- expand.grid(first.names,last.names)

# Create names with all combinations of first and last name
my.names <- paste(name.grid[,1], name.grid[,2])

set.seed(15)

# A simulated grade of students (TRUE = correct, FALSE = wrong)
correction.mat <- matrix(sample(c(TRUE,FALSE),
size = length(my.names)*n.sim.questions,
replace = TRUE),nrow = length(my.names))

# Simulate some cheating
idx.cheater.1 <- 5 # std 5 and 10 will have similar correct answers
idx.cheater.2 <- 10
proportion.to.cheat <- 0.5  # proportion of same correct answers
q.to.cheat <- floor(proportion.to.cheat*n.sim.questions)
correction.mat[idx.cheater.1, ] <-  c(rep(TRUE,q.to.cheat),
rep(FALSE,n.sim.questions-q.to.cheat))
correction.mat[idx.cheater.2, ] <- correction.mat[idx.cheater.1, ]

# bind names and correction matrix

# test for cheating
test.cheating.out <- rte.test.cheating(df.grade)
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
##
## [1|144] - John Smith | John Smith - No need for this run (repeated case). Skipping..
## [2|144] - Marcelo Smith | John Smith - No need for this run (repeated case). Skipping..
## [3|144] - Ricardo Smith | John Smith - No need for this run (repeated case). Skipping..
## [4|144] - Tarcizio Smith | John Smith - No need for this run (repeated case). Skipping..
## [5|144] - John Johnson | John Smith - No need for this run (repeated case). Skipping..
## [6|144] - Marcelo Johnson | John Smith - No need for this run (repeated case). Skipping..
## [7|144] - Ricardo Johnson | John Smith - No need for this run (repeated case). Skipping..
## [8|144] - Tarcizio Johnson | John Smith - No need for this run (repeated case). Skipping..
## [9|144] - John P. | John Smith - No need for this run (repeated case). Skipping..
## [10|144] - Marcelo P. | John Smith - No need for this run (repeated case). Skipping..
## [11|144] - Ricardo P. | John Smith - No need for this run (repeated case). Skipping..
## [12|144] - Tarcizio P. | John Smith - No need for this run (repeated case). Skipping..
## [13|144] - John Smith | Marcelo Smith | Proportion of failed tests cheating 0%
## [14|144] - Marcelo Smith | Marcelo Smith - No need for this run (repeated case). Skipping..
## [15|144] - Ricardo Smith | Marcelo Smith - No need for this run (repeated case). Skipping..
## [16|144] - Tarcizio Smith | Marcelo Smith - No need for this run (repeated case). Skipping..
## [17|144] - John Johnson | Marcelo Smith - No need for this run (repeated case). Skipping..
## [18|144] - Marcelo Johnson | Marcelo Smith - No need for this run (repeated case). Skipping..
## [19|144] - Ricardo Johnson | Marcelo Smith - No need for this run (repeated case). Skipping..
## [20|144] - Tarcizio Johnson | Marcelo Smith - No need for this run (repeated case). Skipping..
## [21|144] - John P. | Marcelo Smith - No need for this run (repeated case). Skipping..
## [22|144] - Marcelo P. | Marcelo Smith - No need for this run (repeated case). Skipping..
## [23|144] - Ricardo P. | Marcelo Smith - No need for this run (repeated case). Skipping..
## [24|144] - Tarcizio P. | Marcelo Smith - No need for this run (repeated case). Skipping..
## [25|144] - John Smith | Ricardo Smith | Proportion of failed tests cheating 0%
## [26|144] - Marcelo Smith | Ricardo Smith | Proportion of failed tests cheating 0%
## [27|144] - Ricardo Smith | Ricardo Smith - No need for this run (repeated case). Skipping..
## [28|144] - Tarcizio Smith | Ricardo Smith - No need for this run (repeated case). Skipping..
## [29|144] - John Johnson | Ricardo Smith - No need for this run (repeated case). Skipping..
## [30|144] - Marcelo Johnson | Ricardo Smith - No need for this run (repeated case). Skipping..
## [31|144] - Ricardo Johnson | Ricardo Smith - No need for this run (repeated case). Skipping..
## [32|144] - Tarcizio Johnson | Ricardo Smith - No need for this run (repeated case). Skipping..
## [33|144] - John P. | Ricardo Smith - No need for this run (repeated case). Skipping..
## [34|144] - Marcelo P. | Ricardo Smith - No need for this run (repeated case). Skipping..
## [35|144] - Ricardo P. | Ricardo Smith - No need for this run (repeated case). Skipping..
## [36|144] - Tarcizio P. | Ricardo Smith - No need for this run (repeated case). Skipping..
## [37|144] - John Smith | Tarcizio Smith | Proportion of failed tests cheating 0%
## [38|144] - Marcelo Smith | Tarcizio Smith | Proportion of failed tests cheating 0%
## [39|144] - Ricardo Smith | Tarcizio Smith | Proportion of failed tests cheating 0%
## [40|144] - Tarcizio Smith | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [41|144] - John Johnson | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [42|144] - Marcelo Johnson | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [43|144] - Ricardo Johnson | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [44|144] - Tarcizio Johnson | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [45|144] - John P. | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [46|144] - Marcelo P. | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [47|144] - Ricardo P. | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [48|144] - Tarcizio P. | Tarcizio Smith - No need for this run (repeated case). Skipping..
## [49|144] - John Smith | John Johnson | Proportion of failed tests cheating 0%
## [50|144] - Marcelo Smith | John Johnson | Proportion of failed tests cheating 0%
## [51|144] - Ricardo Smith | John Johnson | Proportion of failed tests cheating 0%
## [52|144] - Tarcizio Smith | John Johnson | Proportion of failed tests cheating 0%
## [53|144] - John Johnson | John Johnson - No need for this run (repeated case). Skipping..
## [54|144] - Marcelo Johnson | John Johnson - No need for this run (repeated case). Skipping..
## [55|144] - Ricardo Johnson | John Johnson - No need for this run (repeated case). Skipping..
## [56|144] - Tarcizio Johnson | John Johnson - No need for this run (repeated case). Skipping..
## [57|144] - John P. | John Johnson - No need for this run (repeated case). Skipping..
## [58|144] - Marcelo P. | John Johnson - No need for this run (repeated case). Skipping..
## [59|144] - Ricardo P. | John Johnson - No need for this run (repeated case). Skipping..
## [60|144] - Tarcizio P. | John Johnson - No need for this run (repeated case). Skipping..
## [61|144] - John Smith | Marcelo Johnson | Proportion of failed tests cheating 0%
## [62|144] - Marcelo Smith | Marcelo Johnson | Proportion of failed tests cheating 0%
## [63|144] - Ricardo Smith | Marcelo Johnson | Proportion of failed tests cheating 0%
## [64|144] - Tarcizio Smith | Marcelo Johnson | Proportion of failed tests cheating 0%
## [65|144] - John Johnson | Marcelo Johnson | Proportion of failed tests cheating 0%
## [66|144] - Marcelo Johnson | Marcelo Johnson - No need for this run (repeated case). Skipping..
## [67|144] - Ricardo Johnson | Marcelo Johnson - No need for this run (repeated case). Skipping..
## [68|144] - Tarcizio Johnson | Marcelo Johnson - No need for this run (repeated case). Skipping..
## [69|144] - John P. | Marcelo Johnson - No need for this run (repeated case). Skipping..
## [70|144] - Marcelo P. | Marcelo Johnson - No need for this run (repeated case). Skipping..
## [71|144] - Ricardo P. | Marcelo Johnson - No need for this run (repeated case). Skipping..
## [72|144] - Tarcizio P. | Marcelo Johnson - No need for this run (repeated case). Skipping..
## [73|144] - John Smith | Ricardo Johnson | Proportion of failed tests cheating 0%
## [74|144] - Marcelo Smith | Ricardo Johnson | Proportion of failed tests cheating 0%
## [75|144] - Ricardo Smith | Ricardo Johnson | Proportion of failed tests cheating 0%
## [76|144] - Tarcizio Smith | Ricardo Johnson | Proportion of failed tests cheating 0%
## [77|144] - John Johnson | Ricardo Johnson | Proportion of failed tests cheating 0%
## [78|144] - Marcelo Johnson | Ricardo Johnson | Proportion of failed tests cheating 0%
## [79|144] - Ricardo Johnson | Ricardo Johnson - No need for this run (repeated case). Skipping..
## [80|144] - Tarcizio Johnson | Ricardo Johnson - No need for this run (repeated case). Skipping..
## [81|144] - John P. | Ricardo Johnson - No need for this run (repeated case). Skipping..
## [82|144] - Marcelo P. | Ricardo Johnson - No need for this run (repeated case). Skipping..
## [83|144] - Ricardo P. | Ricardo Johnson - No need for this run (repeated case). Skipping..
## [84|144] - Tarcizio P. | Ricardo Johnson - No need for this run (repeated case). Skipping..
## [85|144] - John Smith | Tarcizio Johnson | Proportion of failed tests cheating 0%
## [86|144] - Marcelo Smith | Tarcizio Johnson | Proportion of failed tests cheating 0%
## [87|144] - Ricardo Smith | Tarcizio Johnson | Proportion of failed tests cheating 0%
## [88|144] - Tarcizio Smith | Tarcizio Johnson | Proportion of failed tests cheating 0%
## [89|144] - John Johnson | Tarcizio Johnson | Proportion of failed tests cheating 0%
## [90|144] - Marcelo Johnson | Tarcizio Johnson | Proportion of failed tests cheating 0%
## [91|144] - Ricardo Johnson | Tarcizio Johnson | Proportion of failed tests cheating 0%
## [92|144] - Tarcizio Johnson | Tarcizio Johnson - No need for this run (repeated case). Skipping..
## [93|144] - John P. | Tarcizio Johnson - No need for this run (repeated case). Skipping..
## [94|144] - Marcelo P. | Tarcizio Johnson - No need for this run (repeated case). Skipping..
## [95|144] - Ricardo P. | Tarcizio Johnson - No need for this run (repeated case). Skipping..
## [96|144] - Tarcizio P. | Tarcizio Johnson - No need for this run (repeated case). Skipping..
## [97|144] - John Smith | John P. | Proportion of failed tests cheating 0%
## [98|144] - Marcelo Smith | John P. | Proportion of failed tests cheating 0%
## [99|144] - Ricardo Smith | John P. | Proportion of failed tests cheating 0%
## [100|144] - Tarcizio Smith | John P. | Proportion of failed tests cheating 0%
## [101|144] - John Johnson | John P. | Proportion of failed tests cheating 0%
## [102|144] - Marcelo Johnson | John P. | Proportion of failed tests cheating 0%
## [103|144] - Ricardo Johnson | John P. | Proportion of failed tests cheating 0%
## [104|144] - Tarcizio Johnson | John P. | Proportion of failed tests cheating 0%
## [105|144] - John P. | John P. - No need for this run (repeated case). Skipping..
## [106|144] - Marcelo P. | John P. - No need for this run (repeated case). Skipping..
## [107|144] - Ricardo P. | John P. - No need for this run (repeated case). Skipping..
## [108|144] - Tarcizio P. | John P. - No need for this run (repeated case). Skipping..
## [109|144] - John Smith | Marcelo P. | Proportion of failed tests cheating 0%
## [110|144] - Marcelo Smith | Marcelo P. | Proportion of failed tests cheating 0%
## [111|144] - Ricardo Smith | Marcelo P. | Proportion of failed tests cheating 0%
## [112|144] - Tarcizio Smith | Marcelo P. | Proportion of failed tests cheating 0%
## [113|144] - John Johnson | Marcelo P. | Proportion of failed tests cheating 50%
## [114|144] - Marcelo Johnson | Marcelo P. | Proportion of failed tests cheating 0%
## [115|144] - Ricardo Johnson | Marcelo P. | Proportion of failed tests cheating 0%
## [116|144] - Tarcizio Johnson | Marcelo P. | Proportion of failed tests cheating 0%
## [117|144] - John P. | Marcelo P. | Proportion of failed tests cheating 0%
## [118|144] - Marcelo P. | Marcelo P. - No need for this run (repeated case). Skipping..
## [119|144] - Ricardo P. | Marcelo P. - No need for this run (repeated case). Skipping..
## [120|144] - Tarcizio P. | Marcelo P. - No need for this run (repeated case). Skipping..
## [121|144] - John Smith | Ricardo P. | Proportion of failed tests cheating 0%
## [122|144] - Marcelo Smith | Ricardo P. | Proportion of failed tests cheating 0%
## [123|144] - Ricardo Smith | Ricardo P. | Proportion of failed tests cheating 0%
## [124|144] - Tarcizio Smith | Ricardo P. | Proportion of failed tests cheating 0%
## [125|144] - John Johnson | Ricardo P. | Proportion of failed tests cheating 0%
## [126|144] - Marcelo Johnson | Ricardo P. | Proportion of failed tests cheating 0%
## [127|144] - Ricardo Johnson | Ricardo P. | Proportion of failed tests cheating 0%
## [128|144] - Tarcizio Johnson | Ricardo P. | Proportion of failed tests cheating 0%
## [129|144] - John P. | Ricardo P. | Proportion of failed tests cheating 0%
## [130|144] - Marcelo P. | Ricardo P. | Proportion of failed tests cheating 0%
## [131|144] - Ricardo P. | Ricardo P. - No need for this run (repeated case). Skipping..
## [132|144] - Tarcizio P. | Ricardo P. - No need for this run (repeated case). Skipping..
## [133|144] - John Smith | Tarcizio P. | Proportion of failed tests cheating 0%
## [134|144] - Marcelo Smith | Tarcizio P. | Proportion of failed tests cheating 0%
## [135|144] - Ricardo Smith | Tarcizio P. | Proportion of failed tests cheating 0%
## [136|144] - Tarcizio Smith | Tarcizio P. | Proportion of failed tests cheating 0%
## [137|144] - John Johnson | Tarcizio P. | Proportion of failed tests cheating 0%
## [138|144] - Marcelo Johnson | Tarcizio P. | Proportion of failed tests cheating 0%
## [139|144] - Ricardo Johnson | Tarcizio P. | Proportion of failed tests cheating 0%
## [140|144] - Tarcizio Johnson | Tarcizio P. | Proportion of failed tests cheating 0%
## [141|144] - John P. | Tarcizio P. | Proportion of failed tests cheating 0%
## [142|144] - Marcelo P. | Tarcizio P. | Proportion of failed tests cheating 0%
## [143|144] - Ricardo P. | Tarcizio P. | Proportion of failed tests cheating 0%
## [144|144] - Tarcizio P. | Tarcizio P. - No need for this run (repeated case). Skipping..

##
## List of Suspects:
##
## John Johnson <-> Marcelo P. Proportion of failed tests:71%