2024-06-05

Understanding Hypothesis Testing

  • When conducting research, there is a possibility that the results are due to chance
  • Methods have been developed to determine if a result is significant, meaning the results support the hypothesis
  • Hypothesis testing is utilizing sample data about a population to determine whether the result is too extreme or the variation is reasonable

Types of Hypotheses

  • Null Hypothesis: claim that there is not an effect, relationship, or difference between a population and a variable. It is the statement believed to be true unless it can be proven wrong beyond a reasonable doubt. It contains the condition of equality
  • Null Hypothesis: \(H_0: \mu = \mu_0\)
  • Example: There is no relationship between height and shoe size
  • Research Hypothesis (Alternative Hypothesis): claim that a variable has an effect on a population
  • Alternative Hypothesis: \(H_1: \mu \ne \mu_0\)
  • Example: There is a positive relationship between height and shoe size

Values

  • Critical Value: the number needed to reject the null hypothesis
  • Probability Value (p-value): a number used to determine the significance of the test
  • Usually, a p-value less than .05 is considered statistically significant

Data Set ‘Bechdel_IMDB’ Visualizations

  • The visual shows the relationship between the length of the movies and the IMDb rating

Data Set ‘Bechdel_IMDB’ Investigation Through Visualization

-The visual shows the amount of movies released each year for data investigation

Dataset ‘Bechdel_IMDB’ Visualization For Test

  • This is a data set about movies and their Bechdel rating
  • First we create a hypothesis: The later years have more movies with higher average Bechdel ratings.
  • Second we create a visualization
df2 = df%>%
  group_by(year)%>%
  summarise(avgbechdelrating = mean(bechdelRating, na.rm = TRUE))

## Visualize Data
df%>%
ggplot(aes(x = year, y = bechdelRating))+
  geom_point(alpha = .1)+
  geom_smooth(method = 'lm',color = "red", se = FALSE) +
  labs(title = "The Average Bechdel Rating of Movies for Each Year",
       x = "Year", y="Bechdel Rating")
## `geom_smooth()` using formula = 'y ~ x'

Hypothesis Test

  • The linear regression model: \[ \text{Bechdel Rating} = \beta_0 + \beta_1 \cdot \text{Year} + \epsilon \]
model <- lm(bechdelRating ~ year, data = df)
summary(model)
## 
## Call:
## lm(formula = bechdelRating ~ year, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.3234 -1.1346  0.7080  0.7898  1.3500 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.041e+01  9.533e-01  -10.92   <2e-16 ***
## year         6.294e-03  4.772e-04   13.19   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.063 on 9716 degrees of freedom
## Multiple R-squared:  0.01759,    Adjusted R-squared:  0.01749 
## F-statistic:   174 on 1 and 9716 DF,  p-value: < 2.2e-16

Conclusion

  • Since the p-value is less than .05, the null hypothesis is rejected, and the alternative hypothesis is supported
  • This means there is a statistical significance between the years and the Bechdel ratings