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GHT", "NIGHT", "DAY", "NIGHT", "NIGHT", "NIGHT",
"NIGHT", "DAY", "NIGHT", "DAY", "DAY", "NIGHT", "NIGHT",
"DAY", "DAY", "DAY", "DAY")
incident_dates <- c("08/06/2015", "09/06/2015", "13/06/2015",
"21/06/2015", "03/08/2015", "04/08/2015", "06/09/2015",
"21/09/2015", "25/09/2015", "26/09/2015", "30/09/2015",
"12/10/2015", "13/10/2015", "22/10/2015", "26/10/2015", "17/12/2015",
"16/02/2016", "09/04/2016", "09/04/2016", "02/06/2016", "14/06/2016",
"23/06/2016", "23/06/2016", "24/06/2016", "25/06/2016")
incident_babies <- c("A", "B", "C", "D", "E", "F", "G", "G",
"H", "H", "I", "I", "I", "I", "J", "J", "K", "M", "L",
"N", "N", "O", "P", "P", "Q")
nurse_names <- c("Ailsa SIMPSON", NA, "Angela McSHANE", "Ashleigh HUDSON",
"Belinda SIMCOCK", "Bernadette BUTTERWORTH", "Caroline BENNION", NA,
"Caroline OAKLEY", "Cheryl CUTHBERTSON-TAYLOR", "Christopher BOOTH",
"Eirian POWELL", "Elizabeth MARSHALL", NA, "Janet COX", "Jean PEERS",
"Jennifer JONES-KEY", "Joanne WILLIAMS", "Kathryn WARD", NA, "Laura EAGLES",
"Lisa WALKER", "Lucy LETBY", "Mary GRIFFITH", "Melanie TAYLOR",
"Minna LAPPALAINEN", "Nicola DENNISON", "Patricia STEELE", "Rebecca MORGAN",
"Samantha O'BRIEN", "Shelley TOMLINS", "Sophie ELLIS", NA, "Valerie PARKES",
"Valerie THOMAS", "Vickie BLAMIRE", "Yvonne FARMER", "Yvonne GRIFFITHS")
nurse_codes <- c("A1", "A2", "A3", "A4", "B1", "B2", "C1", "C2", "C3", "C4",
"C5", "E1", "E2", "E3", "J1", "J2", "J3", "J4", "K1", "K2", "L1", "L2", "L3",
"M1", "M2", "M3", "N1", "P1", "R1", "S1", "S2", "S3", "S4", "V1", "V2", "V3",
"Y1", "Y2")
sum(incidents)
## [1] 169
dim(incidents)
## [1] 25 38
colSums(incidents)[23]
## [1] 25
mean(rowSums(incidents[ , -23])[incident_shifts == "DAY"])
## [1] 7.777778
mean(rowSums(incidents[ , -23])[incident_shifts == "NIGHT"])
## [1] 4.625
sum(rowSums(incidents[ , -23])[incident_shifts == "DAY"])
## [1] 70
sum(rowSums(incidents[ , -23])[incident_shifts == "NIGHT"])
## [1] 74
table(incident_shifts)
## incident_shifts
## DAY NIGHT
## 9 16
set.seed(666)
incidents_sim_day_vec <- c(rep(1, 70), rep(0, 9 * 37 - 70))
incidents_sim_day<- matrix(sample(incidents_sim_day_vec, 9 * 37, replace = FALSE), 9, 37)
incidents_sim_night_vec <- c(rep(1, 74), rep(0, 16 * 37 - 74))
incidents_sim_night <- matrix(sample(incidents_sim_night_vec, 16 * 37, replace = FALSE), 16, 37)
incidents_sim <- matrix(0, 25, 38)
incidents_sim[ , 23] <- 1
incidents_sim[incident_shifts == "NIGHT", -23] <- incidents_sim_night
incidents_sim[incident_shifts == "DAY", -23] <- incidents_sim_day
par(mfrow = c(1, 2))
##
## Now comes a new representation of the famous spreadsheet,
## together with a random spreadsheet constructed in the following fashion:
## It has the same number of nurses (38), and the same number of incidents (25).
## Each incident is either an incident during the day, or at night.
##
## In the pictures below, the rows correspond to 38 nurses, ordered in
## alphabetical order from bottom to top.
##
## The columns correspond to incidents, in order of time, from left to right.
##
## On the left is the spreadsheet presented to the jury at beginning and end
## of trial, and released to the press at the beginning of the trial.
##
## On the right is a spreadsheet filled at random in the following way:
## - Lucy Letby is present at every incident.
## - the night-time nurse x incident cells are filled completely at random
## with the same total number of nurse x incident pairs as in reality.
## - similarly for the day-time cells of the spreadsheet.
##
## The two pictures look rather similar, except in reality we see horizontal
## blocks. This means that the same nurse is present at incidents which follow
## each other directly, in time.
##
## In particular, we see that a number of nurses are present at consecutive
## events involving child O and child P in day-time on two consecutive days:
## 23 and 24 June, 2016
##
image(incidents); image(incidents_sim)

library(MASS)
truehist(colSums(incidents), h = 1, prob = FALSE, ylim = c(0, 12))
truehist(colSums(incidents_sim), h = 1, prob = FALSE, ylim = c(0, 12))
