library(tidyverse)
library(mosaic)
library(rio)
library(car)
<- import("https://byuistats.github.io/M221R/Data/quiz/R/helmet_fit.csv") helmet_fit
Paired T-Test Practice
Instructions
Here are several opportunities to practice analyzing dependent samples using R. For each question, you will:
- Read in data
- Create data summaries (numerical and graphical)
- Statistically analyze the data
- Check for the suitability of the statistical test (CLT, Normality)
- State your hypothesis test conclusions and interpret your confidence intervals
Helmet Measurements
After purchasing a batch of flight helmets that did not fit the heads of many pilots, the NZ Airforce decided to measure the head sizes of all recruits. Before this was carried out, information was collected to determine the feasibility of using cheap cardboard calipers to make the measurements, instead of metal ones which were expensive and uncomfortable.
The data lists the head diameters of 18 recruits measured once using cardboard calipers and again using metal calipers. One question is whether there is any systematic difference between the two measurement tools.
NOTE: Define the difference as cardboard - metal.
Use \(\alpha = 0.05\) significance level.
Step 1: Load the Data
Step 2: Explore the Data and Generate Hypotheses
Create histograms and summary statistic tables for the measurements for each type of tool:
Step 3: Prepare the data for analysis
Give the summary statistics (favstats()
) for the differences in the measured head diameters.
Question: What does a negative number mean given the definition of the difference?
Answer:
Create a qqPlot()
of the differences:
Step 4: Perform the Appropriate Analyses
Hypothesis Test
Make the following null and alternative hypothesis correct by deleting what doesn’t belong:
\[H_0: \mu_d > < = \ne 0\]
\[ H_a: \mu_d > < = \ne 0\]
# Perform a t-test for the mean of the differences between cardboard and caliper data
Question: What is the value of the test statistic, \(t\)?
Answer:
Question: How many degrees of freedom does this test statistics have?
Answer:
Question: What is the P-value?
Answer:
Question: Can we trust this P-value? (eg. How many differences in our sample? Check the qqPlot()
of the differences for normality)
Answer:
Question: State your conclusion about the hypothesis test.
Answer:
Confidence Intervals
Create a 95% confidence interval for the true average difference between the cardboard and the metal measurement tools:
Question: Give a one-sentence explanation of your confidence interval.
Answer:
Cholesterol
A study was conducted at a major northeastern American medical center regarding blood cholesterol levels and heart-attack incidents. A total of 28 heart-attack patients had their cholesterol levels measured two days after the heart attack and again four days after the heart attack. Researchers want to see if cholesterol levels reduced significantly four days after the attack versus two days after the attack.
Use the level of significance of 0.05.
Step 1: Load the Data
<- import("https://byuistats.github.io/M221R/Data/quiz/R/cholesterol.csv") cholesterol
Step 2: Review the Data Generate Hypotheses
Create histograms and summary statistics tables for the cholesterol measurements at 2 days and at 4 days.
Step 3: Prepare the data for analysis
Decide how you are going to define the difference (chol_day2 - chol_day4 or chol_day4 - chol_day2).
What does a negative number mean:
What is your null and alternative hypotheses:
\[H_0: \mu_d > < = \ne 0\]
\[ H_a: \mu_d > < = \ne 0\]
Create a qqPlot()
of the differences and determine if you can trust the statistical tests.
Step 4: Perform the appropriate analysis
Hypothesis Test
Perform a t-test for the differences.
Question: What is the value of the test statistic, \(t\)?
Answer:
Question: How many degrees of freedom does this test statistics have?
Answer:
Question: What is the P-value?
Answer:
Question: Can we trust the P-value?
Answer:
Question: State your conclusion about the hypothesis test.
Answer:
Confidence Interval
Create a 95% confidence interval for the difference in cholesterol scores:
Question: Explain your confidence interval in context of the research question
Answer: