Comparing two proportions (2)
Now we have calculated the pooled estimate \(\hat{p}\), we can move on to calculate the standard error. The formula for the standard error is the following:
$$se = \sqrt{\hat{p} * (1 - \hat{p}) * (\frac{1}{n1} + \frac{1}{n2})}$$
This exercise is part of the course
Inferential Statistics
Exercise instructions
- The pooled estimate is given in the sample code. It is named
pooled
. Use this variable to calculate the standard error and store this in the variable calledse
. Remeber that the sample sizes n1 = 100 and n2 = 150
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# calculate the difference in sample proportions and store it in a variable called difference
difference <- 0.6 - 0.42
# calculate the pooled estimate and store it in a variable called pooled
pooled <- ((0.6 * 100) + (0.42 * 150)) / (100 + 150)
# calculate the standard error and store it in a variable called se