Here is a (by no means exhaustive) list of examples for summary statistics.

Technical note: we added put na.rm = T to all the summary statistics. This tells the function to ignore data points that have a non-existing value. Normally, this shouldn’t happen, but unfortunately the deterministic ODE integrators in the deSolve package can run into numerical instabilities when a trajectory stays around 0 for too long and produce very small negative states. Normally this is not a problem, but it will be if we try to take a sample from the Poisson distribution.

# maximum incidence before day 13
ssMax_0_12 <- function(traj) {
  return(max(traj[traj$time < 13, ]$obs, na.rm = T))
}

# maximum incidence between day 13 and day 24
ssMax_13_24 <- function(traj) {
  return(max(traj[traj$time > 12 & traj$time < 25, ]$obs, na.rm = T))
}

# maximum incidence between day 25 and day 36
ssMax_25_36 <- function(traj) {
  return(max(traj[traj$time > 24 & traj$time < 37, ]$obs, na.rm = T))
}

# maximum incidence after day 36
ssMax_37_60 <- function(traj) {
  return(max(traj[traj$time > 36, ]$obs, na.rm = T))
}

# cumulative incidence before day 13
ssSum_0_12 <- function(traj) {
  return(sum(traj[traj$time < 13, ]$obs, na.rm = T))
}

# cumulative incidence between day 13 and day 24
ssSum_13_24 <- function(traj) {
  return(sum(traj[traj$time > 12 & traj$time < 25, ]$obs, na.rm = T))
}

# cumulative incidence between day 25 and day 36
ssSum_25_36 <- function(traj) {
  return(sum(traj[traj$time > 24 & traj$time < 37, ]$obs, na.rm = T))
}

# cumulative incidence after day 36
ssSum_37_60 <- function(traj) {
  return(sum(traj[traj$time > 36, ]$obs, na.rm = T))
}

# maximum incidence along the whole trajectory
ssMax <- function(traj) {
  return(max(traj$obs, na.rm = T))
}

# timing of the epidemic peak
ssMaxTime <- function(traj) {
  return(min(traj[which(traj$obs == max(traj$obs)), ]$time, na.rm = T))
}

# final size of the epidemic
ssSize <- function(traj) {
  return(sum(traj$obs, na.rm = T))
}

Copy and paste any of these you would like to test.

Return to the ABC session.

 

This web site and the material contained in it were originally created in support of an annual short course on Model Fitting and Inference for Infectious Disease Dynamics at the London School of Hygiene & Tropical Medicine. All material is under a MIT license. Please report any issues or suggestions for improvement on the corresponding GitHub issue tracker. We are always keen to hear about any uses of the material here, so please do get in touch using the Discussion board if you have any questions or ideas, or if you find the material here useful or use it in your own teaching.