This page was last updated on October 04, 2019.


Activity 2:

  • The proportion of males in a population of 100000 people is known to be 0.52
  • Using the sample function as above, sample 20 individuals at random from this population
  • Calculate the sample-based estimate of the proportion of males, and the Agresti-Coull 95% confidence interval
  • Set your seed with number 133 at the beginning of your code

SOLUTION

Set the population parameters.

The population comprises 52% males and 48% females.


Generate the population

Set the random value seed to 133 and build the population.

## sex.pop
##  female    male 
## 0.48111 0.51889

Sample the population

Use the sample() to randomly draw 20 individuals from the population generated above (sex.pop.prop).


Calculate observed proportion of males

calculate the sample-based estimate of the proportion of males “successes” (male, in this case) to get the sample

## [1] 0.5

The sample-based estimate of the proportion of males in this population is 0.5.


Calculate the Agresti-Coull 95% confidence interval of the proportion of males in the population.

##          method  x  n mean    lower    upper
## 1 agresti-coull 10 20  0.5 0.299298 0.700702

Our 95% confidence interval is 0.299 \(\leq\) p \(\leq\) 0.701. This interval does include the known proportion of males of 0.519