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| 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 |
\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.
\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)
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.
\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.
R)one_variance() function from library(ssstats) to perform statistical inference.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)
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:
First, we need to describe the data.
Then, we will perform a hypothesis test to answer the question.
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)
Then, we will perform a hypothesis test to answer the question.
How do we translate this into hypotheses?
For the one_variance() function, we will set
sigma2 = 121alternative = "less".alpha = 0.05zootopia %>% 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)
Hypotheses
Test Statistic and p-Value
Rejection Region
Conclusion and Interpretation
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:
First, we need to describe the data.
Then, we will perform a hypothesis test to answer the question.
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)
Then, we will perform a hypothesis test to answer the question.
How do we translate this into hypotheses?
For the one_variance() function, we will set
sigma2 = 225alternative = "two".alpha = 0.05zootopia %>% 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)
Hypotheses
Test Statistic and p-Value
Rejection Region
Conclusion and Interpretation
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.