Skip to content

Who score more goals in the game of football? Men or Women

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) since 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:

: The mean number of goals scored in women's international soccer matches is the same as men's.

: The mean number of goals scored in women's international soccer matches is greater than men's.

# Start your code here!
library(tidyverse)
library(gridExtra)

# Load the data
men_df <- read_csv("men_results.csv")
head(men_df)
glimpse(men_df)


women_df <- read_csv("women_results.csv")
head(women_df)
glimpse(women_df)
# Filtering for world cup matches that took place after "2002-01-01"
men_df <- men_df  %>% 
	filter(date > "2002-01-01" & tournament == 'FIFA World Cup')
dim(men_df)
women_df <- women_df  %>% 
	filter(date > "2002-01-01" & tournament == 'FIFA World Cup')
dim(women_df)
# Calculating the test values
men_df <- men_df  %>% mutate(total_goals = away_score + home_score)
head(men_df)

women_df <- women_df  %>% mutate(total_goals = away_score + home_score)
head(women_df)

Determining the type of hypothesis test

The two groups indicating the total number of goals scored by men and women are independent of each other. This sceneario requires an unpaired two-sample test.

An unpaired t-test and a Wilcoxon-Mann-Whitney tests are two common two-sample tests. But, the latter is a non-parametric version while the former is parameteric.

library(ggplot2)
library(gridExtra)

# Choosing the correct hypothesis test
# Determine normality using histograms
men_plot <- ggplot(men_df, aes(x = total_goals)) + 
	geom_histogram(color = "blue", bins = 30) +
	ggtitle("Goals Scored (Men's)") +
	xlab("Goals Scored") + ylab("Frequency")

women_plot <- ggplot(women_df, aes(x = total_goals)) + 
	geom_histogram(color = "blue", bins = 30) +
	ggtitle("Goals Scored (Women's)") +
	xlab("Goals Scored") + ylab("Frequency")

grid.arrange(men_plot, women_plot, nrow = 1)

Performing the test

# Run a wilcoxon-Mann-Withney test on total_goals
test_results <- wilcox.test(x = women_df$total_goals, 
						   y = men_df$total_goals,
							alternative = "greater")
# Determine hypothesis test result using significant level
p_val <- round(test_results$p.value, 4)
result <- ifelse(p_val <= 0.01, "reject", "fail to reject")
#Create the resut data frame
result_df <- data.frame(p_val, result)