You're working as a sports journalist at a major online sports media company, specializing in soccer analysis and reporting. You've been watching both men's and women's international soccer matches for a number of years, and your gut instinct tells you that more goals are scored in women's international football matches than men's. This would make an interesting investigative article that your subscribers are bound to love, but you'll need to perform a valid statistical hypothesis test to be sure!
While scoping this project, you acknowledge that the sport has changed a lot over the years, and performances likely vary a lot depending on the tournament, so you decide to limit the data used in the analysis to only official FIFA World Cup matches (not including qualifiers) after 2002-01-01.
You create two datasets containing the results of every official men's and women's international football match since the 19th century, which you scraped from a reliable online source. This data is stored in two CSV files: women_results.csv and men_results.csv.
The question you are trying to determine the answer to is:
Are more goals scored in women's international soccer matches than men's?
You assume a 10% significance level, and use the following null and alternative hypotheses:
1 hidden cell
# Start your code here!
# Use as many cells as you need
# load data
data_men <- read.csv("men_results.csv")
data_women <- read.csv("women_results.csv")
# Load the necessary library
library(dplyr)
# Correct the function name
glimpse(data_men)
glimpse(data_women)
unique(data_men$tournament)
# Filter the data to only include official FIFA World Cup matches that took place after 2002-01-01
data_men_w <- data_men %>%
filter(tournament == "FIFA World Cup", date > "2002-01-01")
data_women_w <- data_women %>%
filter(tournament == "FIFA World Cup", date > "2002-01-01")
# calculating the goals scored for men
data_men_w <- data_men_w %>%
mutate(n_goals = home_score + away_score)
# calculating the goals scored for women
data_women_w <- data_women_w %>%
mutate(n_goals = home_score + away_score)
library(ggplot2)
ggplot(data_men_w, aes(n_goals)) + geom_histogram(bins = 30)
ggplot(data_women_w, aes(n_goals)) + geom_histogram(bins = 30)
# Perform Shapiro-Wilk test on the n_goals column
shapiro.test(data_women_w$n_goals)
shapiro.test(data_men_w$n_goals)
# Perform Wilcoxon test on the n_goals column
test_results <- wilcox.test(data_women_w$n_goals, data_men_w$n_goals, alternative = "greater")
# Extract the p-value
p_val <- test_results$p.value
# Determine the result based on a 10% significance level
result <- ifelse(p_val < 0.10, "reject", "fail to reject")
result
# Store in a data frame
result_df <- data.frame(p_val = p_val, result = result)
result_df