Figures for hypothetical example of zero causal effect but positive predictive comparison. See Chapter 20 in Regression and Other Stories.


Load packages

library("rprojroot")
root<-has_file(".ROS-Examples-root")$make_fix_file()

Plot figures

bell <- function(filename, mu, sd, lo, hi, ymax){
  if (savefigs) pdf(filename, height = 3, width = 9)
  par(mar = c(4,0,3,0))
  curve(
    dnorm(x, mu, sd),
    from = lo, to = hi,
    ylim = c(0, ymax),
    xlab = "", ylab = "", bty = "n",
    yaxt = "n", yaxs = "i",
    cex.axis = 3.5,
    mgp = c(3,3,0)
  )
  if (savefigs) dev.off()
}

bell("bell1h.pdf", 2, .4, .3, 5.7, 1)

bell("bell1l.pdf", 2, .4, .3, 5.7, 3)

bell("bell2.pdf", 3, .4, .3, 5.7, 2)

bell("bell3l.pdf", 4, .4, .3, 5.7, 3)

bell("bell3h.pdf", 4, .4, .3, 5.7, 1)

bell("bell4l.pdf", 1.5, .4, .3, 5.7, 3)

bell("bell5h.pdf", 2.5, .4, .3, 5.7, 1)

bell("bell5.pdf", 2.5, .4, .3, 5.7, 2)

bell("bell6.pdf", 3.5, .4, .3, 5.7, 2)

bell("bell6h.pdf", 3.5, .4, .3, 5.7, 1)

bell("bell7l.pdf", 4.5, .4, .3, 5.7, 3)

LS0tCnRpdGxlOiAiUmVncmVzc2lvbiBhbmQgT3RoZXIgU3RvcmllczogQmFsYW5jZSIKYXV0aG9yOiAiQW5kcmV3IEdlbG1hbiwgSmVubmlmZXIgSGlsbCwgQWtpIFZlaHRhcmkiCmRhdGU6ICJgciBmb3JtYXQoU3lzLkRhdGUoKSlgIgpvdXRwdXQ6CiAgaHRtbF9kb2N1bWVudDoKICAgIHRoZW1lOiByZWFkYWJsZQogICAgdG9jOiB0cnVlCiAgICB0b2NfZGVwdGg6IDIKICAgIHRvY19mbG9hdDogdHJ1ZQogICAgY29kZV9kb3dubG9hZDogdHJ1ZQotLS0KRmlndXJlcyBmb3IgaHlwb3RoZXRpY2FsIGV4YW1wbGUgb2YgemVybyBjYXVzYWwgZWZ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