One-Sample Variances

Introduction

  • In the last module, we discussed describing data.

  • In this module, we are discussing statistical inference on one sample.

    • Mean / median

    • Proportion

    • Variance / standard deviation

  • In this lecture, we are focusing on one-sample variances and standard deviations.

R Setup

library(tidyverse)
library(ssstats)
  • Recall our Zootopia data,
zootopia <- read_csv("https://raw.githubusercontent.com/samanthaseals/SDSI/refs/heads/main/files/data/lectures/1-zootopia.csv")
resident_name department district academy_status academy_exam_score sleep_hours hustle_earnings district_temp_f
Sable Jones Desk Rainforest District Fail 65 5.5 14.72 72.2
Kevin Frostwhisker Patrol Downtown Fail 69 7.4 45.66 66.2
Jasper Duskrunner Patrol Sahara Square Pass 79 8.7 30.91 89.8

Confidence Interval for \sigma^2

  • (1–\alpha)100% CI for a population variance, \sigma^2

\left( \frac{(n-1)s^2}{\chi^2_{1-\alpha/2, n-1}}, \ \frac{(n-1)s^2}{\chi^2_{\alpha/2, n-1}} \right)

  • where

    • n is the sample size

    • s^2 is the sample variance

    • \chi^2_{1-\alpha/2} and \chi^2_{\alpha/2} are critical values from the \chi^2 distribution with n-1 degrees of freedom

  • Note! This CI does not take the usual form of point estimate \pm margin of error.

Confidence Interval for \sigma

  • (1–\alpha)100% CI for a population standard deviation, \sigma

\left( \sqrt{\frac{(n-1)s^2}{\chi^2_{1-\alpha/2, n-1}}}, \ \sqrt{\frac{(n-1)s^2}{\chi^2_{\alpha/2, n-1}}} \ \right)

  • This is just the \sqrt{} of the interval for \sigma^2.

Hypothesis Test for \sigma^2

  • Hypotheses

Two-Tailed

H_0: \sigma^2 = \sigma^2_0

H_1: \sigma^2 \ne \sigma^2_0

Left-Tailed

H_0: \sigma^2 \ge \sigma^2_0

H_1: \sigma^2 < \sigma^2_0

Right-Tailed

H_0: \sigma^2 \le \sigma^2_0

H_1: \sigma^2 > \sigma^2_0

  • where

    • \sigma^2 is the population variance,

    • \sigma^2_0 is the hypothesized value of \sigma^2.

Hypothesis Test for \sigma^2

  • Test Statistic

\chi^2_0=\frac{(n-1)s^2}{\sigma^2_0}

  • where

    • n is the sample size,

    • \sigma^2 is the population variance,

    • \sigma^2_0 is the hypothesized value of \sigma^2.

Statistical Inference on One Variance (R)

  • We will use the one_variance() function from library(ssstats) to perform statistical inference.
dataset_name %>% one_variance(outcome = variable_name,
                              sigma2 = hypothesized_value,
                              alternative = "two" | "less" | "greater",
                              alpha = alpha_level)
  • where

    • outcome is the variable name of the outcome variable

    • sigma2 is the hypothesized value of the population variance (default = 1)

    • alternative is the alternative hypothesis (default = “two”)

    • alpha is the significance level (default = 0.05)

Example 1

  • The Academy promises that its exam is calibrated with a target standard deviation of no more than 11 points. ZPD believes that the variability of their officer’s exam scores is actually smaller. As Zootopia’s data analyst, you’ve been asked to check that claim. We will use the zootopia dataset to answer:

    • Is the consistency in ZPD officer exam scores better than \sigma = 11 points?
  • First, we need to describe the data.

    • We start with point and interval estimates.
  • Then, we will perform a hypothesis test to answer the question.

Example 1

  • Point and interval estimates:
zootopia %>% one_variance(outcome = academy_exam_score)
One-sample variance

s² = 64.3678 (s = 8.023)

95% CI for σ²: (40.8262, 116.3244)

Hypotheses:
H₀: σ² = 1
H₁: σ² ≠ 1
Test statistic: χ²(29) = 1866.666
p-value: < 0.001
Conclusion: Reject the null hypothesis (p = < 0.001 < α = 0.050)
  • The estimated variance is s^2 = 64.4 with standard deviation s = 8.0. The 95% CI for \sigma^2 is (40.8, 116.3), and the 95% CI for the population standard deviation is (6.4, 10.8).

Example 1

  • Then, we will perform a hypothesis test to answer the question.

    • Is the consistency in ZPD officer exam scores better than \sigma = 11 points?
  • How do we translate this into hypotheses?

    • H_0: \sigma^2 \ge 121 – note that they gave us \sigma, not \sigma^2
    • H_1: \sigma^2 < 121
  • For the one_variance() function, we will set

    • sigma2 = 121
    • alternative = "less".
    • alpha = 0.05

Example 1

  • Is the consistency in ZPD officer exam scores better than \sigma = 11 points?
zootopia %>% one_variance(outcome = academy_exam_score,
                          sigma2 = 121,
                          alternative = "less",
                          alpha = 0.05)
One-sample variance

s² = 64.3678 (s = 8.023)

95% CI for σ²: (40.8262, 116.3244)

Hypotheses:
H₀: σ² ≥ 121
H₁: σ² < 121
Test statistic: χ²(29) = 15.427
p-value: 0.019
Conclusion: Reject the null hypothesis (p = 0.019 < α = 0.050)

Example 1

  • Hypotheses

    • H_0: \sigma^2 \ge 121
    • H_1: \sigma^2 < 121
  • Test Statistic and p-Value

    • \chi^2_0 = 1.1
    • p = 0.019
  • Rejection Region

    • Reject H_0 if p < \alpha; \alpha = 0.05
  • Conclusion and Interpretation

    • Reject H_0. There is sufficient evidence to suggest that the current standard deviation is smaller than 11 points.

Example 2

  • The Zootopia Department of Commerce tracks side-hustle income across the city as part of its small-business reporting. In its most recent public report, the Department states that side-hustle earnings citywide typically show a standard deviation of about $25. We now want to check whether ZPD recruits’ side-hustle earnings look different from the citywide benchmark. We will use the zootopia dataset to answer:

    • Is the standard deviation of recruit side-hustle earnings actually $25, or does it differ from the citywide benchmark?
  • First, we need to describe the data.

    • We start with point and interval estimates.
  • Then, we will perform a hypothesis test to answer the question.

Example 2

  • Point and interval estimates:
zootopia %>% one_variance(outcome = hustle_earnings)
One-sample variance

s² = 518.8429 (s = 22.7781)

95% CI for σ²: (329.0834, 937.6442)

Hypotheses:
H₀: σ² = 1
H₁: σ² ≠ 1
Test statistic: χ²(29) = 15046.444
p-value: < 0.001
Conclusion: Reject the null hypothesis (p = < 0.001 < α = 0.050)
  • The estimated variance is s^2 = 518.84 with standard deviation s = 22.780. The 95% CI for \sigma^2 is (329.08, 937.64), and the 95% CI for the population standard deviation is (18.14, 30.62).

Example 2

  • Then, we will perform a hypothesis test to answer the question.

    • Is the standard deviation of recruit side-hustle earnings different from $25?
  • How do we translate this into hypotheses?

    • H_0: \sigma^2 = 625 – note that they gave us \sigma, not \sigma^2
    • H_1: \sigma^2 \ne 625
  • For the one_variance() function, we will set

    • sigma2 = 225
    • alternative = "two".
    • alpha = 0.05

Example 2

  • Is the standard deviation of recruit side-hustle earnings different from $25?
zootopia %>% one_variance(outcome = hustle_earnings,
                          sigma2 = 625,
                          alternative = "two",
                          alpha = 0.05)
One-sample variance

s² = 518.8429 (s = 22.7781)

95% CI for σ²: (329.0834, 937.6442)

Hypotheses:
H₀: σ² = 625
H₁: σ² ≠ 625
Test statistic: χ²(29) = 24.074
p-value: 0.549
Conclusion: Fail to reject the null hypothesis (p = 0.549 ≥ α = 0.050)

Example 2

  • Hypotheses

    • H_0: \sigma^2 = 625
    • H_1: \sigma^2 \ne 625
  • Test Statistic and p-Value

    • \chi^2_0 = 24.074
    • p = 0.549
  • Rejection Region

    • Reject H_0 if p < \alpha; \alpha = 0.05
  • Conclusion and Interpretation

    • Fail to reject H_0. There is not sufficient evidence to suggest that the current standard deviation is different from $25.

Wrap Up

  • In this lecture, we discussed statistical inference on one variance or standard deviation

  • In this module, we have covered one-sample tests.

  • In the next module, we will learn two-sample tests.