Chapter 3 A Basic Introduction to Statistical Inference

Key Definitions:

Statistical inference is the process of constructing confidence intervals or testing hypotheses about a parameter.

3.1 The Two Major Tasks in Statistics

3.1. 1. Estimating a Parameter

Involves using sample statistics to: - Calculate point estimates (single best guess) - Construct confidence intervals (range of plausible values)

A level \(1-\alpha\) confidence interval for a population proportion is given by:
\[\hat{p} \pm z\cdot \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\] where \(\hat{p}\) is the sample proportion, \(n\) is the sample size, and \(z\) is the critical value dependent on \(\alpha\). If \(\alpha=0.05%\), \(z=1.96\).

3.1.2 Testing Hypotheses About a Parameter

Involves assessing evidence against a null hypothesis (\(H_0\)) using:

  • Test statistics
  • P-values (probability of observed or more extreme results if \(H_0\) is true)

When testing a population proportion \(p\), the null hypothesis is always written as:
\[H_0: p = p_0\] and the alternative hypothesis can take one of the following three forms:

\[H_a: p < p_0\] \[H_a: p > p_0\]

or

\[H_a: p \neq p_0\] They are called the left-sided, right-sided, or two-sided alternative, respectively.

Note: Sometimes, \(H_a\) might be written as \(H_1\).

3.2 The Inference Process

Source: https://wisc.pb.unizin.org/biocorestatistics/chapter/statistical-inference/

  1. Population exists with some unknown parameter
  2. Sample is collected randomly from population
  3. Statistic is calculated from sample
  4. Inference made about population parameter

3.3 Why This Matters

  • We rarely can measure entire populations
  • Proper sampling and inference allows us to:
    • Generalize findings
    • Quantify uncertainty
    • Make data-driven decisions

3.4 Examples of Constructing a Confidence Interval for a Single Population Proportion

A confidence interval provides a range of plausible values for the true population proportion based on sample data. The general form is:

\[ \hat{p} \pm z \cdot \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]

Where: - \(\hat{p}\) = sample proportion - \(z\) = critical value from standard normal distribution. For the 95% confidence level, \(z\) is 1.96. For the 90% confidence level, \(z\) is 1.645. - \(n\) = sample size - The part \(\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\) is called the standard error of the sample proportion \(\hat{p}\), usually denoted \(se\). - The part after \(pm\) is called the margin of error (\(m\)), which is the product of the critical value and the standard error.

3.4.1 Example 1: Political Poll

Scenario: In a survey of 500 voters, 280 support Candidate A. Construct a 95% confidence interval for the true proportion of supporters.

prop.test(x=280, n=500, conf.level = 0.95, correct = FALSE)

    1-sample proportions test without continuity correction

data:  280 out of 500, null probability 0.5
X-squared = 7.2, df = 1, p-value = 0.00729
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
 0.5161969 0.6028882
sample estimates:
   p 
0.56 
  • The R output shows that the 95% confidence interval for the population proportion is between 0.5162 and 0.6029.
  • Note: ignore the p-value output, since it is for testing whether the population proportion is 0.5, and thus is irrelevant.
  • If we do it by hand using the formula in section 3.4, we have \(n = 500, \hat{p}=280/500=0.56\), \(z=1.96\) and \(se=0.0222\) (try to keep 4 decimal places), and \(m=(1.96)\cdot (0.0222)=0.0435\). So, the 95% Confidence interval is from \(0.56-0.0435\) to \(0.56+0.0435\) or from 0.5165 to 0.6035. The results are almost the same as those of R. The difference is due to rounding error.

Interpretation: We are 95% confident that the true proportion of voters supporting Candidate A is between 51.62% and 60.28%.

3.4.2 Example 2: Quality Control

Scenario: A factory tests 200 products and finds 12 defective. Construct a 90% CI for the defect rate.

prop.test(x=12, n=200, conf.level = 0.90, correct = FALSE)

    1-sample proportions test without continuity correction

data:  12 out of 200, null probability 0.5
X-squared = 154.88, df = 1, p-value < 2.2e-16
alternative hypothesis: true p is not equal to 0.5
90 percent confidence interval:
 0.03781444 0.09393107
sample estimates:
   p 
0.06 

Interpretation: We are 90% confident the true defect proportion is between 3.78% and 9.39%.

3.4.3 Key Considerations:

  1. Sample Size Requirements:

    • For accurate confidence intervals, need both \(x\) and \(n-x\) to be at least 10.
  2. Margin of Error depends on:

    • Confidence level (higher level → wider interval)
    • Sample size (larger n → narrower interval)
  3. Assumptions:

    • Random sampling: observations are selected at random
    • Independence: observations are independent of each other

3.5 Examples of Testing Hypotheses about a Single Population Proportion

Hypothesis testing evaluates whether sample data provides sufficient evidence to reject a claim about a population proportion.

The general procedure:

  1. State hypotheses:

    • Null (\(H_0: p = p_0\))
    • Alternative (\(H_1: p < p_0\) or \(H_1: p > p_0\) or \(H_1: p \ne p_0\) )
  2. Calculate test statistic:
    \[ z = \frac{\hat{p} - p_0}{\sqrt{\frac{p_0(1-p_0)}{n}}} \]

  3. Determine p-value based on alternative hypothesis. We will use R code to find the p-value, as the next section shows.

  4. Compare p-value to the significance level \(\alpha\) (typically 0.05). If the p-value is no greater than the significance level, reject the null hypothesis. Otherwise, fail to reject it or don’t reject it.

3.5.1 Example 1: Two-Sided Test (Market Research)

Scenario: A company claims 30% of customers prefer their product. In a survey of 150 customers, 36 prefer it. Test if the true proportion differs from 30% (\(\alpha = 0.05\)).

prop.test(x=36, n=150, p = 0.30, alternative = "two.sided", correct = FALSE)

    1-sample proportions test without continuity correction

data:  36 out of 150, null probability 0.3
X-squared = 2.5714, df = 1, p-value = 0.1088
alternative hypothesis: true p is not equal to 0.3
95 percent confidence interval:
 0.1786931 0.3142914
sample estimates:
   p 
0.24 

Results:

  • Conclusion: Since p-value 0.1088 > 0.05, we fail to reject \(H_0\). There is insufficient evidence to conclude that the true proportion differs from 30%.

Note: Always use the R function prop.test and set correct = FALSE when using the code above.

3.5.2 Example 2: Right-Sided Test (Quality Control)

Scenario: A factory claims at most 5% of products are defective. In a batch of 300, 22 are defective. Test if the defect rate exceeds the claim (\(\alpha = 0.05\)).

prop.test(x=22, n=300, p = 0.05, alternative = "greater", correct = FALSE)

    1-sample proportions test without continuity correction

data:  22 out of 300, null probability 0.05
X-squared = 3.4386, df = 1, p-value = 0.03184
alternative hypothesis: true p is greater than 0.05
95 percent confidence interval:
 0.05220849 1.00000000
sample estimates:
         p 
0.07333333 

Results:

  • Conclusion: Since p-value 0.0318 < 0.05, we reject \(H_0\). There is significant evidence that the defect rate exceeds 5%.

3.5.3 Example 3: Left-Sided Test (Quality Control)

Scenario: A manufacturer claims more than 95% defect-free parts. A sample of 50 parts gives 44 defect-free parts. Test if the defect-free rate is below the claim (\(\alpha = 0.05\)).

prop.test(x=46, n=50, p = 0.95, alternative = "less", correct = FALSE)

    1-sample proportions test without continuity correction

data:  46 out of 50, null probability 0.95
X-squared = 0.94737, df = 1, p-value = 0.1652
alternative hypothesis: true p is less than 0.95
95 percent confidence interval:
 0.000000 0.963578
sample estimates:
   p 
0.92 

Results:

  • Conclusion: Since p-value 0.1652 > 0.05, we fail to reject \(H_0\). There is NOT significant evidence that the defect rate is below 5%.

3.5.3 Key Considerations:

  1. Assumptions:
    • Random sampling
  2. Type I vs. Type II errors:
    • Type I error: Rejecting \(H_0\) when it is actually true.
    • Type II error: Failing to reject \(H_0\) when it is actually false.
    • If \(H_0\) is rejected (p-value \(\le\) \(\alpha\)), a type I error might have been committed.
    • If \(H_0\) is not rejected (p-value > \(\alpha\)), a type II error might have been committed.
  3. Power of a hypothesis test:
  • Statistical power is the chance a study will correctly detect a real effect, like a drug working. High power (e.g., 80%) means you’re likely to spot it; low power means you might miss it. It depends on sample size, effect size, and significance level. Bigger samples or stronger effects increase power.

3.5.4 Important Notes

  1. Always report exact p-values, not just “p < 0.05”
  2. Consider practical significance in addition to statistical significance

3.6 Sample Size Determination

When estimating a 95% confidence interval for a population proportion, the maximum sample size \(n\) to achieve margin of error \(m\) is approximately \((\frac{1}{m})^2\).

Example: The maximum sample size \(n\) to achieve margin of error 0.12 at confidence level 95% is \((\frac{1}{0.12})^2=69.44\), or 70 (always rounded up).

A practical constraint limiting large sample size n is cost and time.

3.7 Exercises: Statistical Inference for a Single Proportion

  1. Definitions
    Match each term to its correct definition:

    Term Definition
    Population A) A numerical characteristic of a sample
    Sample B) The complete set of items of interest
    Parameter C) A subset of the population that is observed
    Statistic D) A numerical characteristic of a population
  2. True or False:

    • A 95% confidence interval means there’s a 95% probability the true parameter is in the interval
    • For the same data, a 99% CI will be wider than a 95% CI
    • The p-value is the probability that the null hypothesis is true
    • When p-value < α, we reject the null hypothesis
  3. Calculation Practice
    In a survey of 400 students, 160 reported using public transportation daily.

    1. Calculate the sample proportion
    2. Construct a 90% confidence interval manually
    3. Verify using R’s prop.test()
# Your R code here
  1. Interpretation
    For the above CI (0.360, 0.440), explain what “90% confident” means in context.

  2. Test Setup
    A medication claims to be effective for 70% of patients. In a trial of 50 patients, 32 found it effective.

    1. Formulate appropriate null and alternative hypotheses
    2. Explain whether this should be one-tailed or two-tailed
  3. R Analysis
    Conduct the test in R at α = 0.05 and interpret:

# Your test code here
  1. Case Study
    A website claims its conversion rate is 8%. In a sample of 200 visitor, 22 converted.

    1. Construct a 95% CI for the true conversion rate
    2. Test whether the actual rate differs from 8%
    3. Discuss any discrepancies between CI and test results
  2. Error Analysis
    If you reject H₀ when α = 0.05:

    1. What type of error might you have made?
    2. How could you reduce the chance of this error?
  3. Sample Size Impact
    Holding everything else constant, what happens to:

    1. Confidence interval width if n increases?
    2. P-value if n increases?