Stanford University, Spring 2016, STATS 205

## Question

Does small dose of aspirin prevent heart attacks in healthy middle-aged men?

## Experiment

• A randomized double-blind study was designed to collect data.
• The subjects were randomly assigned to the aspirin and placebo groups.
• Doctors and subjects didn't know whether they treated or received aspirin or placebo substance.
labels = c("nattacks","nsubjects")
aspirin = c(104,11037)
placebo = c(189,11034)
data = data.frame(aspirin,placebo)
rownames(data) = labels
data
##           aspirin placebo
## nattacks      104     189
## nsubjects   11037   11034

## Statistic

Ratio of the rates:

rate = function(v) v[1]/v[2]
theta.hat = rate(data$aspirin)/rate(data$placebo)
theta.hat
## [1] 0.550115

This means that in this sample aspirin-takers only have 55% as many heart attacks as placebo-takers.

## Computations

• Is this due to chance?
• Or can this results be reproduced in a repetition of the same experiments?
• Let's use the bootstrap method to find out:
population.one = c( rep(1,data["nattacks","aspirin"]),
rep(0,data["nsubjects","aspirin"]-data["nattacks","aspirin"]) )
population.two = c( rep(1,data["nattacks","placebo"]),
rep(0,data["nsubjects","placebo"]-data["nattacks","placebo"]) )

draw.bootstrap.sample = function() {
boot.pop.one = sample(population.one,replace = TRUE)
boot.pop.two = sample(population.two,replace = TRUE)
rate.one = sum(boot.pop.one)/length(boot.pop.one)
rate.two = sum(boot.pop.two)/length(boot.pop.two)
return(rate.one/rate.two)
}

## Computations

and now simulate:

nrep = 10000
theta.boot = replicate(nrep,draw.bootstrap.sample())
hist(theta.boot,breaks=100)

# sample estimate
abline(v=theta.hat,col = "red",lwd = 4)

# bootstrap confidence interval
confidence.lower = sort(theta.boot)[nrep*.025]
confidence.upper = sort(theta.boot)[nrep*.975]
abline(v=c(confidence.lower,confidence.upper),col = "blue",lwd = 4)

## Conclusion

We can conclude that aspirin was found to be significantly beneficial for preventing heart attacks.