Load data
population <- read.csv("C:/Users/Bhawna/Documents/blog/data/world-population.csv", sep=",", header=TRUE)
Default plot
plot(population$Year, population$Population, type="l")
Adjust axis
plot(population$Year, population$Population, type="l", ylim=c(0, 7000000000), xlab="Year", ylab="Population")
Reference: world_population.csv was obtained from Flowdata.com
Question of the day?
Suppose we have a normal population with a mean of 3 and a standard deviation of 1, how would we illustrate the bootstrap method here?
set.seed(1)
srs <- rnorm(25, mean=3)
resamps <- replicate(1000, sample(srs, 25, TRUE), simplify = FALSE)
x_bar_star <- sapply(resamps, mean, simplify =TRUE)
Let’s create a histogram here and fit normal curve.
hist(x_bar_star, breaks = 40, prob = TRUE)
curve(dnorm(x, 3, 0.2), add = TRUE)
We can calculate the difference now.