To construct a confidence interval estimate for population proportions we need to identify values for the following arguments:
- x, the number of successes
- n, the sample size
- conf.level, the confidence level for our estimate (expressed as a decimal)
1-Sample
Example: In the 2012 Summer Olympic Games 85 countries competed. Of the countries who competed, 50 won at least one gold medal. Construct a 95% confidence interval estimate for the population proportion of countries who win at least one gold medal in the Summer Olympics.
Source: wikipedia.org
> prop.test(x = 50, n = 85, conf.level = .95)
1-sample proportions test with continuity correction
data: 50 out of 85, null probability 0.5
X-squared = 2.3059, df = 1, p-value = 0.1289
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.4761797 0.6922411
sample estimates:
p
0.5882353
A fair amount of information is being output, but in this instance we are only concerned with the lines that tell us the 95 percent confidence interval estimate is 0.476797 to 0.6922411.
2-Sample
For a 2-sample confidence interval we will use the same arguments as above, but we will have two values for both x and n. To properly enter these arguments we write x = c(x1, x2) and n = c(n1, n2) so that x and n are both lists composed of two values.
Example: In 2005 there were 28,534 total infant deaths in America (ages 0-1). Of these, 6.3% were due to maternal complications, and 4% were due to accidents or unintentional injuries. Construct a 93% confidence interval estimate for the difference in the population proportions.
Source: www.nhpco.org
In this case we are not given values for x1 and x2 so we will have to calculate them as x1 = n1 · p̂1 and x2 = n2 · p̂2, with both values rounded to the nearest whole number. We can use the round command to complete these calculations in one step.
> x.one = round(28534 * 0.063)
> x.one
[1] 1798
> x.two = round(28534 * 0.04)
> x.two
[1] 1141
> prop.test(x = c(1798, 1141), n = c(28534, 28534), conf.level = .93)
2-sample test for equality of proportions with continuity correction
data: c(1798, 1141) out of c(28534, 28534)
X-squared = 154.3728, df = 1, p-value < 2.2e-16
alternative hypothesis: two.sided
93 percent confidence interval:
0.01964198 0.02640834
sample estimates:
prop 1 prop 2
0.06301255 0.03998738
So the 93 percent confidence interval estimate for p1 - p2 is 0.01964198 to 0.02640834. Thus, the data suggests that p1 > p2.
No comments:
Post a Comment