In the last module, we reviewed statistical inference for one sample.
In this module, we will focus on tests for two samples.
In this lecture: two-sample variances (\sigma^2_1/\sigma^2_2)
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(\dfrac{s_1^2}{s_2^2}\cdot\dfrac{1}{F_{\alpha/2,\,n_1-1,\,n_2-1}}, \ \ \dfrac{s_1^2}{s_2^2}\cdot F_{\alpha/2,\,n_2-1,\,n_1-1}\right)
\left(\sqrt{\dfrac{s_1^2}{s_2^2}\cdot\dfrac{1}{F_{\alpha/2,\,n_1-1,\,n_2-1}}}, \ \ \sqrt{\dfrac{s_1^2}{s_2^2}\cdot F_{\alpha/2,\,n_2-1,\,n_1-1}}\right)
Two-Tailed
H_0: \ \sigma_1^2 = \sigma_2^2
H_1: \ \sigma_1^2 \ne \sigma_2^2
Left-Tailed
H_0: \ \sigma_1^2 \ge \sigma_2^2
H_1: \ \sigma_1^2 < \sigma_2^2
Right-Tailed
H_0: \ \sigma_1^2 \le \sigma_2^2
H_1: \ \sigma_1^2 > \sigma_2^2
R)We will use the two_variances() function from library(ssstats) to perform statistical inference.
Generic syntax:
dataset_name |> two_variances(outcome = continuous_variable,
grouping = grouping_variable,
first = "first_group_in_ratio",
alternative = "two" | "less" | "greater",
alpha = specified_alpha)"two".
0.05.
Deputy Chief is concerned that patrol officers experience less variability in their side hustle incomes.
We will use the zootopia dataset to answer the following question:
We’ll work with hustle_earnings and department.
Two-sample variances
s²[Patrol] = 346.664 (s = 18.6189)
s²[Desk] = 785.4795 (s = 28.0264)
Ratio: s²[Patrol] / s²[Desk] = 0.4413
95% CI for σ²[Patrol] / σ²[Desk]: (0.1345, 1.2665)
Hypotheses:
H₀: σ²[Patrol] / σ²[Desk] = 1
H₁: σ²[Patrol] / σ²[Desk] ≠ 1
Test statistic: F(17, 11) = 0.441
p-value: 0.126
Conclusion: Fail to reject the null hypothesis (p = 0.126 ≥ α = 0.050)
Is there evidence that side-hustle income variability is smaller for patrol officers?
How do we translate this into hypotheses?
Hypotheses:
For the two_variances() function, we will set
first = "Patrol"alternative = "less".zootopia |> two_variances(outcome = hustle_earnings,
grouping = department,
first = "Patrol",
alternative = "less")Two-sample variances
s²[Patrol] = 346.664 (s = 18.6189)
s²[Desk] = 785.4795 (s = 28.0264)
Ratio: s²[Patrol] / s²[Desk] = 0.4413
95% CI for σ²[Patrol] / σ²[Desk]: (0.1345, 1.2665)
Hypotheses:
H₀: σ²[Patrol] / σ²[Desk] ≥ 1
H₁: σ²[Patrol] / σ²[Desk] < 1
Test statistic: F(17, 11) = 0.441
p-value: 0.063
Conclusion: Fail to reject the null hypothesis (p = 0.063 ≥ α = 0.050)
Hypotheses
Test Statistic and p-Value
Rejection Region
Conclusion and Interpretation
Today, Deputy Chief wants to look into the amount of sleep between the two departments. In particular, Deputy chief believes that patrol’s sleep habits are less predictable than those on desk duty.
We will use the zootopia dataset to answer the following question:
We’ll work with sleep_hours and department.
Two-sample variances
s²[Patrol] = 1.5579 (s = 1.2482)
s²[Desk] = 2.0242 (s = 1.4228)
Ratio: s²[Patrol] / s²[Desk] = 0.7696
95% CI for σ²[Patrol] / σ²[Desk]: (0.2345, 2.2085)
Hypotheses:
H₀: σ²[Patrol] / σ²[Desk] = 1
H₁: σ²[Patrol] / σ²[Desk] ≠ 1
Test statistic: F(17, 11) = 0.77
p-value: 0.608
Conclusion: Fail to reject the null hypothesis (p = 0.608 ≥ α = 0.050)
Is there evidence that Patrol officers’ sleep hours are more variable than Desk officers’?
How do we translate this into hypotheses?
Hypotheses:
For the two_variances() function, we will set
first = "Patrol"alternative = "greater".zootopia |> two_variances(outcome = sleep_hours,
grouping = department,
first = "Patrol",
alternative = "less")Two-sample variances
s²[Patrol] = 1.5579 (s = 1.2482)
s²[Desk] = 2.0242 (s = 1.4228)
Ratio: s²[Patrol] / s²[Desk] = 0.7696
95% CI for σ²[Patrol] / σ²[Desk]: (0.2345, 2.2085)
Hypotheses:
H₀: σ²[Patrol] / σ²[Desk] ≥ 1
H₁: σ²[Patrol] / σ²[Desk] < 1
Test statistic: F(17, 11) = 0.77
p-value: 0.304
Conclusion: Fail to reject the null hypothesis (p = 0.304 ≥ α = 0.050)
Hypotheses
Test Statistic and p-Value
Rejection Region
Conclusion and Interpretation
In this lecture, we discussed statistical inference on two variances or standard deviations
In this module, we have covered two-sample tests.
In the next module, we will learn one-way ANOVA.