Skip to main content

Section B.3 One proportion

Subsection B.3.1 Problem statement

The CEO of a large electric utility claims that 80 percent of his 1,000,000 customers are satisfied with the service they receive. To test this claim, the local newspaper surveyed 100 customers, using simple random sampling. 73 were satisfied and the remaining were unsatisfied. Based on these findings from the sample, can we reject the CEO’s hypothesis that 80% of the customers are satisfied? (Tweaked a bit from https://stattrek.com/hypothesis-test/proportion.aspx?Tutorial=AP.)

Subsection B.3.2 Competing hypotheses

  • Null hypothesis: The proportion of all customers satisfied with service they receive is equal to 0.80.
  • Alternative hypothesis: The proportion of all customers satisfied with service they receive is different from 0.80.
  • \(H_0: \pi = p_0\text{,}\) where \(\pi\) represents the proportion of satisfied customers and \(p_0 = 0.8\text{.}\)
  • \(\displaystyle H_A: \pi \ne 0.8\)
Significance level: \(\alpha = 0.05\text{.}\)

Subsection B.3.3 Exploring the sample data

elec <- c(rep("satisfied", 73), rep("unsatisfied", 27)) |>
  enframe() |>
  rename(satisfy = value)

ggplot(data = elec, aes(x = satisfy)) +
  geom_bar()

p_hat <- elec |>
  specify(response = satisfy, success = "satisfied") |>
  calculate(stat = "prop")
p_hat

Subsection B.3.4 Simulation-based methods

set.seed(2018)
null_distn_one_prop <- elec |>
  specify(response = satisfy, success = "satisfied") |>
  hypothesize(null = "point", p = 0.8) |>
  generate(reps = 10000) |>
  calculate(stat = "prop")
null_distn_one_prop |>
  visualize() +
  shade_p_value(obs_stat = p_hat, direction = "both")

pvalue <- null_distn_one_prop |>
  get_pvalue(obs_stat = p_hat, direction = "both")
pvalue
The \(p\)-value is greater than 0.05 and we fail to reject the null hypothesis.
boot_distn_one_prop <- elec |>
  specify(response = satisfy, success = "satisfied") |>
  generate(reps = 10000) |>
  calculate(stat = "prop")

ci <- boot_distn_one_prop |>
  get_ci()
ci

boot_distn_one_prop |>
  visualize() +
  shade_ci(endpoints = ci)
We see that 0.80 is contained in this confidence interval as a plausible value of \(\pi\text{.}\) This matches with our hypothesis test results of failing to reject the null hypothesis.

Subsection B.3.5 Theory-based methods

Check conditions.

Remember that in order to use the shortcut (formula-based, theoretical) approach, we need to check that some conditions are met.
  1. Independent observations: The observations are collected independently. This condition is met via random sampling.
  2. Approximately normal: The number of expected successes (73) and failures (27) are both at least 10, so this condition is met.

Test statistic.

If conditions are met and \(H_0\) is true, we can standardize \(\hat{P}\) into a \(Z\) statistic:
\begin{equation*} Z = \frac{\hat{P} - p_0}{\sqrt{\dfrac{p_0(1-p_0)}{n}}} \sim N(0,1) \end{equation*}
Observed test statistic.
While one could compute this observed test statistic by "hand", the focus here is on the set-up of the problem and in understanding which formula for the test statistic applies.
p_hat_val <- 0.73
p0 <- 0.8
n <- 100
z_obs <- (p_hat_val - p0) / sqrt((p0 * (1 - p0)) / n)
z_obs

Visualize and compute \(p\)-value.

2 * pnorm(z_obs)
[1] 0.08011831
prop.test(
  x = table(elec$satisfy),
  n = length(elec$satisfy),
  alternative = "two.sided",
  p = 0.8,
  correct = FALSE
)
1-sample proportions test without continuity correction

data:  table(elec$satisfy), null probability 0.8
X-squared = 3.0625, df = 1, p-value = 0.08012
alternative hypothesis: true p is not equal to 0.8
95 percent confidence interval:
 0.6356788 0.8073042
sample estimates:
   p 
0.73

State conclusion.

We do not have sufficient evidence to reject the null hypothesis. Based on this sample, we do not have evidence that the proportion of all satisfied customers differs from 0.80.

Subsection B.3.6 Comparing results

Observing the bootstrap distribution and the null distribution that were created, it makes quite a bit of sense that the results are so similar for traditional and non-traditional methods in terms of the \(p\)-value and the confidence interval since these distributions look very similar to normal distributions. The conditions also being met leads us to better guess that using any of the methods whether they are traditional (formula-based) or non-traditional (computational-based) will lead to similar results.