## Here we draw the empirical distribution of p for ## a samplesize corresponding to the fever data set samplesize <- 11778 simulations <- 1000 true.p <- 0.01 ## simulate observation of fever fever <- rbinom(simulations, samplesize, true.p) ## estimate p from the observation p.hat <- fever/samplesize ## histogram is saved as an object... histogram <- hist(p.hat, ## nice choice of breaks, centered around true.p breaks = seq(0.00525,0.01525,0.0005), plot = FALSE ) ## ..and then frequency is changed to percent histogram$counts <- histogram$counts/simulations*100 ## now we can plot the histogram plot(histogram, main = "", xlab = "Estimate", ylab = "Percent")