A market researcher wants to evaluate car insurance savings at a competing company. Based on past studies he is assuming that the standard deviation of savings is $100. He wants to collect data such that he can get a margin of error of no more than $10 at a 95% confidence level. How large of a sample should he collect?
CI = x_bar +/- z_score*(s/sqrt(n))
where x_bar is the mean z_score is the confidence coefficient for 95% CI interval s is stantard deviation n is the population size
The margin of error is equal margin_error = z_score*(s/sqrt(n))
We know that for 95% CI interval the confidence coefficient is 1.96 We also have s = $100 We need to solve for n where z_score*(s/sqrt(n)) <= 10
s = 100
z_score = 1.96
margin_error = 10
Solving for n we get
n = (s*z_score/margin_error)^2
n
## [1] 384.16
So in order for us to get a margin of error less than $10, we would need a sample of at least 385 people (we can’t have .16 of a person).
Let’s double check
for (i in 384:400) {
n = i
z_score = 1.96
s = 100
margin_error = z_score*(s/sqrt(n))
print(paste("n value: ",n, ", ME: ", margin_error))
}
## [1] "n value: 384 , ME: 10.0020831163646"
## [1] "n value: 385 , ME: 9.98908495217746"
## [1] "n value: 386 , ME: 9.97613733176204"
## [1] "n value: 387 , ME: 9.96323992839684"
## [1] "n value: 388 , ME: 9.95039241830947"
## [1] "n value: 389 , ME: 9.93759448064252"
## [1] "n value: 390 , ME: 9.92484579741993"
## [1] "n value: 391 , ME: 9.9121460535138"
## [1] "n value: 392 , ME: 9.89949493661167"
## [1] "n value: 393 , ME: 9.88689213718424"
## [1] "n value: 394 , ME: 9.87433734845362"
## [1] "n value: 395 , ME: 9.8618302663619"
## [1] "n value: 396 , ME: 9.84937058954028"
## [1] "n value: 397 , ME: 9.83695801927851"
## [1] "n value: 398 , ME: 9.82459225949487"
## [1] "n value: 399 , ME: 9.81227301670647"
## [1] "n value: 400 , ME: 9.8"
Notice 384 has a margin error slightly greater than $10.