Question 1
Answer the following two questions using the inference function. As always, write out the hypotheses for any tests you conduct and outline the status of the conditions for inference.
spain_12 <- subset(atheism, nationality == "Spain" & year == 2012)
spain_05 <- subset(atheism, nationality == "Spain" & year == 2005)
inference(spain_12$response, est = "proportion", type = "ci", method = "theoretical", success = "atheist")
## Single proportion -- success: atheist
## Summary statistics:
## p_hat = 0.09 ; n = 1145
## Check conditions: number of successes = 103 ; number of failures = 1042
## Standard error = 0.0085
## 95 % Confidence interval = ( 0.0734 , 0.1065 )
inference(spain_05$response, est = "proportion", type = "ci", method = "theoretical", success = "atheist")
## Single proportion -- success: atheist
## Summary statistics:
## p_hat = 0.1003 ; n = 1146
## Check conditions: number of successes = 115 ; number of failures = 1031
## Standard error = 0.0089
## 95 % Confidence interval = ( 0.083 , 0.1177 )
The Confidence Intervals overlap. There doesn't seem to be a significant change in the Atheism Index in Spain from 2005 to 2012.
us_12 <- subset(atheism, nationality == "United States" & year == 2012)
us_05 <- subset(atheism, nationality == "United States" & year == 2005)
inference(us_12$response, est = "proportion", type = "ci", method = "theoretical", success = "atheist")
## Single proportion -- success: atheist
## Summary statistics:
## p_hat = 0.0499 ; n = 1002
## Check conditions: number of successes = 50 ; number of failures = 952
## Standard error = 0.0069
## 95 % Confidence interval = ( 0.0364 , 0.0634 )
inference(us_05$response, est = "proportion", type = "ci", method = "theoretical", success = "atheist")
## Single proportion -- success: atheist
## Summary statistics:
## p_hat = 0.01 ; n = 1002
## Check conditions: number of successes = 10 ; number of failures = 992
## Standard error = 0.0031
## 95 % Confidence interval = ( 0.0038 , 0.0161 )
The Confidence Intervals don't overlap. There seems to be a significant change in the Atheism Index in US from 2005 to 2012. 2012 seems to have more Atheists compared to that of 2005.
Question 2
If in fact there has been no change in the atheism index in the countries listed in Table 4, in how many of those countries would you expect to detect a change (at a significance level of 0.05) simply by chance?
39*0.05
## [1] 1.95
2 countries.
Question 3
Suppose you're hired by the local government to estimate the proportion of residents that attend a religious service on a weekly basis. According to the guidelines, the estimate must have a margin of error no greater than 1% with 95% confidence. You have no idea what to expect for \(p\). How many people would you have to sample to ensure that you are within the guidelines?
e = 0.01
sample.size.prop(e, P = 0.5, N = Inf, level = 0.95)
##
## sample.size.prop object: Sample size for proportion estimate
## Without finite population correction: N=Inf, precision e=0.01 and expected proportion P=0.5
##
## Sample size needed: 9604