2024-10-21

<style type="text/css">
body p, div, h1, h2, h3, h4, h5 {
  color: black;
  font-family: "Modern Computer Roman";
}
slides > slide.title-slide hgroup h1 {
  color: #8C1D40; /* the maroon color */
}
h2 {
  color: #8C1D40; /* the maroon color */
}
</style>

R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Slide 1: Introduction to Hypothesis Testing

Hypothesis testing is a statistical method used to make decisions or inferences about population parameters based on sample data. It helps determine whether the observed effect is statistically significant or occurred by chance.

Slide 2: Null and Alternative Hypotheses

In hypothesis testing, we compare two hypotheses:

  • Null Hypothesis (H₀): Assumes no effect or no difference in the population. It is the hypothesis we aim to test.
  • Alternative Hypothesis (H₁): Represents an effect or a difference. It contradicts the null hypothesis.

Example: - H₀: The new drug has no effect on recovery time. - H₁: The new drug reduces recovery time.

We test: \[ H_0: \mu_1 = \mu_2 \quad \text{vs.} \quad H_1: \mu_1 \neq \mu_2 \]

Slide 3: Types of Errors in Hypothesis Testing

  • Type I Error (False Positive): Rejecting the null hypothesis when it is true.
    • Probability: α (Significance level)
  • Type II Error (False Negative): Failing to reject the null hypothesis when it is false.
    • Probability: β

Example: In drug testing: - Type I error: Concluding the drug works when it doesn’t. - Type II error: Concluding the drug doesn’t work when it actually does.

Slide 4: P-value and Significance Level

  • P-value: Is used to help us determine whether to reject the null hypothesis.The probability of observing the data, or something more extreme, assuming the null hypothesis is true.
  • Significance Level (α): A threshold set by the researcher (commonly 0.05) for determining whether the p-value is small enough to reject the null hypothesis.

Decision Rule: - If p-value < α, reject the null hypothesis. - If p-value ≥ α, fail to reject the null hypothesis.

We reject H₀ when:

\[ p \leq \alpha \] Where α is the significance level, commonly set to 0.05.

Slide 5: Example of Hypothesis Testing (T-Test)

Consider a study measuring the effect of two teaching methods on student performance.

Hypotheses: - H₀: The mean score of students is the same for both teaching methods. - H₁: The mean score differs between the two teaching methods.

We can perform a two-sample t-test to determine if there’s a significant difference between the methods.

Slide 6: Visualization of the Normal Distribution and Critical Region

In this slide, we visualize the normal distribution, which is commonly used in hypothesis testing. The critical region, shaded in blue, represents the range of values where we would reject the null hypothesis. This visualization helps us understand how extreme outcomes (those in the critical region) are unlikely under the null hypothesis and provide evidence for rejecting it.

Slide 7: Visualization of the Normal Distribution and Critical Region

Slide 8: We will see actual examples now

Hypothesis testing for Test Scores based on study methods

Description of Study Methods:

Group A: Traditional Study Method - Students in Group A followed a traditional study method, focusing on individual learning through textbooks and lecture notes. They studied on their own, without external resources or collaboration.

Group B: Interactive Study Method - Students in Group B used an interactive study method, which involved group discussions, peer collaboration, online tutorials, and video lectures. This method encouraged active learning through multimedia and peer interaction.

Slide 9: ggplot Visualization of Test Scores

ggplot visualization that compares the test scores of two groups of students who used different study methods

Slide 10: Code used to create the boxplot above

# Simulating a dataset of test scores based on study method
set.seed(123)
data <- data.frame(
  study_method = factor(rep(c("Group A", "Group B"), each = 50)),
  score = c(rnorm(50, mean = 85, sd = 5), rnorm(50, mean = 90, sd = 5))
)

# Creating the boxplot
ggplot(data, aes(x = study_method, y = score, fill = study_method)) +
  geom_boxplot() +
  labs(x = "Study Method", y = "Test Scores") +
  theme_minimal() +
  scale_fill_manual(values = c("#D55E00", "#0072B2"))

Slide 11: Inference

The boxplot shows that Group B (interactive study method) has higher and more consistent test scores compared to Group A (traditional study method).

While the visualization suggests a difference, further statistical analysis, such as a t-test, is needed to determine if this difference is statistically significant.

Slide 12: Two-Sample T-Test on Test Scores

Hypothesis Testing:

Null Hypothesis (H₀):

There is no difference in test scores between Group A (traditional study) and Group B (interactive study).

Alternative Hypothesis (H₁):

There is a significant difference in test scores, with Group B expected to perform better due to the interactive method.

Slide 13: Two-Sample T-Test on Test Scores

This suggests that the interactive study method (Group B) results in higher average scores than the traditional method (Group A).

## 
##  Welch Two Sample t-test
## 
## data:  score by study_method
## t = -6.0718, df = 97.951, p-value = 2.406e-08
## alternative hypothesis: true difference in means between group Group A and group Group B is not equal to 0
## 95 percent confidence interval:
##  -7.377243 -3.742805
## sample estimates:
## mean in group Group A mean in group Group B 
##              85.17202              90.73204

Slide 14: Here is Another Example

Weight Differences by Gender

In this case, we are comparing the weight distributions of males and females to determine if there is a statistically significant difference between the two groups.

Null Hypothesis (H₀): The average weight of males and females is the same.

Alternative Hypothesis (H₁): There is a significant difference in the average weight between males and females.

Slide 15: ggplot visualization for comparing the weight differences

The boxplot is useful for visually assessing the distribution and spread of weights for both genders.

Slide 16: Inference

The boxplot shows the weight distribution for males and females. The median weight for males appears to be higher than that for females, with a wider spread of data. This suggests that males generally weigh more than females, but further statistical testing is needed to confirm if this difference is significant.

Slide 17: Two-Sample T-Test on Test Scores

Null Hypothesis (H₀): There is no significant difference in the average weight between males and females.

Alternative Hypothesis (H₁): There is a significant difference in the average weight between males and females.

Slide 18: Two-Sample T-Test on Test Scores

## 
##  Welch Two Sample t-test
## 
## data:  weight by gender
## t = -5.5175, df = 92.636, p-value = 3.104e-07
## alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
## 95 percent confidence interval:
##  -12.474308  -5.871231
## sample estimates:
## mean in group Female   mean in group Male 
##             61.17127             70.34404

we can reject the null hypothesis and conclude that the difference in weights is statistically significant.