Independent data: Observations in one group (or sample) do not influence or relate to observations in another group.
Examples:
Comparing the cruising speeds of a random sample of Pegasi vs. a random sample of Unicorns flying a short course.
Measuring friendship lesson quiz scores for a group of Cutie Mark Crusaders vs. a group of Wonderbolts Cadets.
Examining the graduation rates between Unicorns and Pegasi.
Dependent Data
Dependent (paired) data: Each observation in the first sample is paired with exactly one observation in the second sample.
Examples:
Students’ magic‐proficiency scores before and after Princess Celestia’s advanced spell workshop.
Applejack’s apple‐yield (in bushels) from Sweet Apple Acres in Spring vs. Fall for the last 10 years.
Comparing the “Wonderbolts Tryouts” performance scores for Spitfire and Skyflare (twins).
Independent vs. Dependent Data
Are the following dependent or independent?
Rainbow Dash times two separate groups, Pegasi trainees and Unicorn cadets, on the same 200-meter aerial course.
Twilight Sparkle measures her own spell‐casting accuracy before and after attending Princess Celestia’s advanced magic workshop.
Applejack records bushel counts from Sweet Apple Acres in spring this year and compares them to bushel counts from Sugarcube’s orchard over the same period.
The Cutie Mark Crusaders each take a friendship-lesson quiz, and their scores are compared to a completely different group of ponies at the School of Friendship.
Fluttershy records the heart rates of the same group of critters before and after she plays soothing music for them.
Confidence Intervals: Two Independent Means
(1-\alpha)100\% confidence interval for \mu_1-\mu_2:
The Pegasus trainers insist that a healthy Pony munches through 25 apples per day to stay strong and energetic. Looking for differences between those that are above and below target wing-flap rates, a researcher visits the apple stands at Sweet Apple Acres and records the exact number of apples each of the Pegasi in training eats in a typical day.
Use the wing-flap data to estimate the difference in apple consumption (apples) betwen those that are above or below the target rate (target). Estimate using a 95% confidence interval.
The Pegasus trainers insist that a healthy Pony munches through 25 apples per day to stay strong and energetic. Looking for differences between those that are above and below target wing-flap rates, a researcher visits the apple stands at Sweet Apple Acres and records the exact number of apples each of the Pegasi in training eats in a typical day.
Use the wing-flap data to estimate the difference in apple consumption (apples) betwen those that are above or below the target rate (target). Estimate using a 95% confidence interval.
We will use the independent_mean_HT function from library(ssstats) to perform the necessary calculations for the hypothesis test.
Generic syntax:
dataset_name %>%independent_mean_HT(grouping = grouping_variable,continuous = continuous_variable, mu = hypothesized_value, alternative ="alternative_direction", alpha = specified_alpha)
For the entered variable (continuous), we will see:
Hypotheses (based on hypothesized_value and alternative)
Test statistic and p-value
Conclusion
Note! When looking at the grouping variable, R will subtract in alphabetic/numeric order.
Hypothesis Testing: Two Independent Means
Perform the appropriate hypothesis test to determine if the above target pegasi are eating 5 or more apples than the below target pegasi. Test at the \alpha=0.05 level.
What is the direction of the test? How do you know?
What is the hypothesized value? How do you know?
What are the corresponding hypotheses?
Hypothesis Testing: Two Independent Means
Perform the appropriate hypothesis test to determine if the above target pegasi are eating 5 or more apples than the below target pegasi. Test at the \alpha=0.05 level.
How should we change the following code?
dataset_name %>%independent_mean_HT(grouping = grouping_variable,continuous = continuous_variable, mu = hypothesized_value, alternative ="alternative_direction", alpha = specified_alpha)
Hypothesis Testing: Two Independent Means
Perform the appropriate hypothesis test to determine if the above target pegasi are eating 5 or more apples than the below target pegasi. Test at the \alpha=0.05 level.
Our updated code should look like:
wing_flap %>%independent_mean_HT(grouping = target,continuous = apples, mu =5, alternative ="greater", alpha =0.05)
Hypothesis Testing: Two Independent Means
Running the code,
wing_flap %>%independent_mean_HT(grouping = target,continuous = apples, mu =5, alternative ="greater", alpha =0.05)
Two-sample t-test for two independent means and equal variance:
Null: H₀: μ₁ − μ₂ ≤ 5
Alternative: H₁: μ₁ − μ₂ > 5
Test statistic: t(23) = 5.445
p-value: p < 0.001
Conclusion: Reject the null hypothesis (p = < 0.001 < α = 0.05)
Reject H_0 (p \text{ vs } \alpha \to p < 0.001 < 0.05). There is sufficient evidence to suggest that ponies above target, on average, eat 5 more apples than those below target.
Two Dependent Means: Summary Statistics
We are now interested in comparing two dependent groups.
We assume that the two groups come from the same population and are going to examine the difference,
d = y_{i, 1} - y_{i, 2}
After drawing samples, we have the following,
\bar{d} estimates \mu_d,
s^2_d estimates \sigma^2_d, and
n is the sample size.
Two Dependent Means: Summary Statistics (R)
We will use the dependent_mean_median function from library(ssstats) to find the summary statistics for this data.
Note that this will compute summary statistics for:
x_d = x_1-x_2
x_1
x_2
Two Dependent Means: Summary Statistics
Princess Celestia has invited two groups of flyers to take part in a brand-new “SkyStride” aerial training camp. Before the camp begins, each pony perches on a floating platform while a team of Wonderbolt engineers use magical sensors to record their baseline wing-flap rate (flaps per second) as they hover in place (pre_training_wfr).
Over two weeks, trainees attend identical flight drills: precision loops, cloud-weaving obstacle courses, and high-altitude sprints. At camp’s end, each flyer returns to the sensor platforms for post-training measurements (post_training_wfr).
Let’s find the summary statistics. How should this code be edited?
Princess Celestia has invited two groups of flyers to take part in a brand-new “SkyStride” aerial training camp. Before the camp begins, each pony perches on a floating platform while a team of Wonderbolt engineers use magical sensors to record their baseline wing-flap rate (flaps per second) as they hover in place (pre_training_wfr).
Over two weeks, trainees attend identical flight drills: precision loops, cloud-weaving obstacle courses, and high-altitude sprints. At camp’s end, each flyer returns to the sensor platforms for post-training measurements (post_training_wfr).
The point estimate for the mean difference is x̄ = -1.712.
The point estimate for the standard deviation of differences is s = 9.9701.
The 99% confidence interval for the mean difference μ_d is (-7.2891, 3.8651).
The 99% confidence interval for \mu_d is (-7.16, 5.33).
The point estimate for the mean difference is x̄ = 1.712.
The point estimate for the standard deviation of differences is s = 9.9701.
The 99% confidence interval for the mean difference μ_d is (-3.8651, 7.2891).
The 99% confidence interval for \mu_d is (-5.33, 7.16).
Confidence Intervals: Two Dependent Means
When looking at post - pre, the CI was (-7.16, 5.33).
When looking at pre - post, the CI was (-5.33, 7.16).
Paired t-test for the mean of differences:
Null: H₀: μ_d = 0
Alternative: H₁: μ_d ≠ 0
Test statistic: t(24) = -0.859
p-value: p = 0.399
Conclusion: Fail to reject the null hypothesis (p = 0.3991 ≥ α = 0.01)