Followers of my blog who haven’t already seen it might enjoy this opinion piece I wrote for Quillette magazine. I have wanted to write something like that for a while, but never thought I’d get around to it. I’m glad I proved myself wrong!
For both the Bayesian and frequentist calculations I used a binomial conditional prior for the data (aka likelihood) for the number of recoveries :
For the Bayesian analysis the prior for was a 50/50 mixture of a uniform prior from 0 to 1, and a delta function at (the old drug’s effectiveness):
where . Is this prior debatable? Yes, just like the prior for the data. The conclusion of an argument can change if you change the premises.
Here’s R code to calculate the posterior:
# Theta values, prior, and likelihood function # theta is basically 0.7 theta = seq(0, 1, length.out=10001) likelihood = dbinom(83, prob=theta, size=100) # Prior (discrete approx) prior = rep(0.5/10000, 10001) prior = 0.5 # Posterior posterior = prior*likelihood/sum(prior*likelihood) # Probability new drug is worse, same, better print(sum(posterior[1:6999])) print(posterior) print(sum(posterior[7001:10001]))
Here is R code for the (two-sided) p-value:
# Possible data sets x = seq(0, 100) # p(x | H0) p = dbinom(x, prob=0.7, size=100) # P(x <= 57 | H0) prob1 = sum(p[x <= 57]) # P(x >= 83 | H0) prob2 = sum(p[x >= 83]) # Print p-value print(prob1 + prob2)