Introduction:

The Olympic Games, held every four years, are not only the pinnacle of athletic competition but also a significant global event closely followed worldwide. This report explores three key questions related to the Olympics, examining how these games reflect various socio-economic factors and trends. 1.The relationship between GDP per capita and the number of athletes and medals a country wins. 2.The impact of being the host country on medal counts. 3.The correlation between life expectancy and the number of medals won in the Summer Olympics.

To answer these questions, we utilized data from the Olympic Games History, Gapminder, and Host Cities datasets.Our findings provide insights into the socio-economic dynamics that influence a country’s success in the Olympics.

Analysis Approach: 1.GDP per Capita and Olympic Success: Examined the correlation between GDP per capita and athletes per capita, as well as the proportion of medals won. 2.Host Country Effect: Analyzed medal counts for host countries over three Olympic Games (before, during, and after hosting). 3.Life Expectancy and Olympic Success: Explored the relationship between life expectancy and the number of medals won in the Summer Olympics.

Q1

(i)

olympic_data <- athlete_events %>%
  left_join(noc_regions, by = "NOC") %>%
  mutate(nearest_year = sapply(Year, function(olympic_year) {
    gapminder_years <- seq(1952, 2007, by = 5)
    gapminder_years[which.min(abs(gapminder_years - olympic_year))]
  })) %>%
  left_join(gapminder, by = c("region" = "country", "nearest_year" = "year"))

summer_olympics <- olympic_data %>% filter(Season == "Summer")
winter_olympics <- olympic_data %>% filter(Season == "Winter")

calculate_stats <- function(data) {
  stats <- data %>%
    group_by(region, nearest_year) %>%
    summarize(
      total_athletes = n_distinct(ID),
      avg_population = mean(pop, na.rm = TRUE),
      avg_gdp = first(gdpPercap)
    ) %>%
    mutate(athletes_per_capita = total_athletes / avg_population)
  
  data %>% left_join(stats, by = c("region", "nearest_year"))
}

summer_data <- calculate_stats(summer_olympics)
winter_data <- calculate_stats(winter_olympics)

The code merges athlete_events with noc_regions to add region names, matches Olympic years with the closest gapminder years, and then merges the result with gapminder to include GDP per capita and population data.

I use log-scale to make the plots more easy to read.

The plots show a positive correlation between GDP per capita and athletes per capita for both summer and winter Olympics, indicating wealthier countries(have the higher GDP) tend to send more athletes to the games.

(ii)

For the Summer Olympics, the analysis indicates that there is a general trend where countries with higher GDP per capita tend to win a higher proportion of medals. Additionally, a great number of countries with varying economic standings are able to achieve success in the Summer Games due to the vast dispersion.

In the Winter Olympics, the relationship between GDP per capita and the proportion of medals won is also positive. However, the distribution shows greater variability, indicating that while wealthier countries tend to win more medals, there are significant exceptions. The outliers identified in the graph suggest that some countries excel in winter sports despite having lower GDP, possibly due to a strong tradition and infrastructure for winter sports.

Q2

host_cities <- host_cities %>%
  mutate(iso3 = countrycode(country, "country.name", "iso3c"))

print(head(host_cities))
##          city        country iso3
## 1 Albertville         France  FRA
## 2   Amsterdam    Netherlands  NLD
## 3   Antwerpen        Belgium  BEL
## 4      Athina         Greece  GRC
## 5     Atlanta  United States  USA
## 6   Barcelona          Spain  ESP

china_medals <- medal_counts %>%
  filter(iso3 == "CHN") %>%
  select(Year, total_medals, prev_medals, next_medals) %>%
  filter(Year %in% c(2004, 2008, 2012))

print(china_medals)
## # A tibble: 1,871 × 4
##     Year total_medals prev_medals next_medals
##    <int>        <int>       <int>       <int>
##  1  2004           96          16          13
##  2  2004           96          16          13
##  3  2004           96          16          13
##  4  2004           96          16          13
##  5  2004           96          16          13
##  6  2004           96          16          13
##  7  2004           96          16          13
##  8  2004           96          16          13
##  9  2004           96          16          13
## 10  2004           96          16          13
## # ℹ 1,861 more rows

The plot illustrates the medal counts for each host country over three Olympic Games (before, during, and after hosting). The lines indicate trends, and points highlight the number of medals in each of the three Games.

China took home 100 medals in 2008, a substantial increase from the 63 it won in 2004 and the 88 it won in 2012. This significant rise that occurred during the year of hosting points to a significant host country effect.

Our data clearly demonstrates the host country effect, which states that nations who host the Olympics typically bring home more medals than they did in the previous and succeeding Games. The combined data and the particular instance of China in 2008 both demonstrate this tendency. The advantage of hosting the Olympics seems to come from familiarity with the surroundings, support from the local crowd, and increased national investment in sports infrastructure and training.

This analysis highlights the significance of taking context and prior performance into account when assessing Olympic results. The fundamental causes of this effect and whether it continues in subsequent Olympic Games might be investigated in more detail.

Q3: How does life expectancy relate to the number of medals won by a country in the Summer Olympics?

Life expectancy is a critical indicator of a country’s overall health and development. It reflects the average number of years a person can expect to live and is influenced by factors such as healthcare, nutrition, and living conditions. This question aims to explore whether there is a correlation between life expectancy and Olympic success

Data Wrangling: To address this question, the athlete events data was filtered to include only the Summer Olympics.

summer_olympics <- athlete_events %>% 
  filter(Season == "Summer")

The data was then grouped by year and country (NOC) to count the total number of medals won by each country per year.

medals_per_country <- summer_olympics %>%
  filter(!is.na(Medal)) %>%
  group_by(Year, NOC) %>%
  summarise(Total_Medals = n(), .groups = 'drop')

Summarization: The gapminder data was used to get life expectancy values for each country and year. The gapminder data was filtered to include only the years that correspond to Olympic years. The total number of medals won by each country for each Olympic year was calculated, and this data was merged with the life expectancy data from gapminder.

A scatter plot is created to visualize the relationship between life expectancy and the number of medals won. A trend line is added to the plot to highlight the correlation between these two variables.

Conclusion for Q3: The plot reveals a positive correlation between a country’s life expectancy and the number of medals won in the Summer Olympics. Countries with higher life expectancy tend to win more medals, indicating better health and development contribute to improved athletic performance. This is often linked to better healthcare systems, living standards, and early sports participation.

Conclusion: The Olympics is more than just a competition, it also provides insights into the socio-economic factors, which influences a country’s success. Generally, wealthier nations send more athletes and win more medals, although there are some exceptions. Hosting the Olympics often gives countries a significant economic boost due to factors like increased investments. Moreover, higher life expectancy is associated with greater success in the Games because it reflects better health and development. These findings explained the relationship between a country’s economics, health standards, and performance.