Introduction

Overview

This report presents a comprehensive analysis of COVID-19 cumulative incidence data across different countries. The analysis includes data exploration, visualization, and clustering to identify patterns and groupings in COVID-19 incidence rates globally.

Objectives

  • To explore and visualize COVID-19 incidence patterns
  • To identify key trends in global COVID-19 distribution
  • To cluster countries based on their incidence rates
  • To provide actionable insights from the data analysis

Data Analysis

Data Loading and Preparation

# Load required libraries
library(readr)
library(tidyverse)
library(cluster)
library(ggplot2)
library(readr)

# Import COVID-19 data
covid <- read_csv("covid_incidence.csv")

# Display initial structure
str(covid)
## spc_tbl_ [238 × 3] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ ...1                : num [1:238] 1 2 3 4 5 6 7 8 9 10 ...
##  $ Name                : chr [1:238] "Global" "United States of America" "India" "Brazil" ...
##  $ Cumulative_incidence: num [1:238] 11220 64796 7546 37456 23155 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   ...1 = col_double(),
##   ..   Name = col_character(),
##   ..   Cumulative_incidence = col_double()
##   .. )
##  - attr(*, "problems")=<externalptr>
# Clean the data
covid_clean <- covid %>% select(-c('...1'))

# Display summary of clean data
summary(covid_clean)
##      Name           Cumulative_incidence
##  Length:238         Min.   :     0.0    
##  Class :character   1st Qu.:   878.5    
##  Mode  :character   Median :  6853.4    
##                     Mean   : 16482.5    
##                     3rd Qu.: 26727.9    
##                     Max.   :109868.6    
##                     NA's   :1

Missing Values Treatment

# Handle missing values using median imputation
covid_clean$Cumulative_incidence[is.na(covid_clean$Cumulative_incidence)] <- 
  median(covid_clean$Cumulative_incidence, na.rm = TRUE)

# Verify missing values have been handled
cat("Number of missing values after imputation:", sum(is.na(covid_clean$Cumulative_incidence)))
## Number of missing values after imputation: 0

Visualizations

Distribution Analysis

Histogram

ggplot(covid_clean, aes(x=Cumulative_incidence)) +
  geom_histogram(bins = 30, fill="skyblue", color="black") +
  theme_minimal() +
  labs(title ="Distribution of COVID-19 Cumulative Incidence" ,
       x = "Cumulative Incidence",
       y = "Frequency") +
  theme(
    plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
    axis.title = element_text(size = 12)
  )

Boxplot

ggplot(covid_clean, aes(y=Cumulative_incidence)) +
  geom_boxplot(fill="skyblue") +
  theme_minimal() +
  labs(title ="Distribution of COVID-19 Cumulative Incidence" ,
       y = "Cumulative Incidence") +
  theme(
    plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
    axis.title = element_text(size = 12)
  )

Top 20 Countries

# Identify and visualize top 20 countries
top_20 <- covid_clean %>%
  arrange(desc(Cumulative_incidence)) %>%
  head(20)

ggplot(top_20, aes(x = reorder(Name, Cumulative_incidence), 
                   y = Cumulative_incidence)) +
  geom_bar(stat = "identity", fill = "coral") +
  coord_flip() +
  theme_minimal() +
  labs(title = "Top 20 Countries by COVID-19 Cumulative Incidence",
       x = "Country",
       y = "Cumulative Incidence") +
  theme(
    plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
    axis.title = element_text(size = 12),
    axis.text.y = element_text(size = 10)
  )

Clustering Analysis

Elbow Method

# Prepare data for clustering
clustering_data <- scale(covid_clean$Cumulative_incidence)
clustering_data_clean <- na.omit(clustering_data)
clustering_data_scaled <- scale(clustering_data_clean)

# Calculate WSS for different values of k
wss <- sapply(1:10, function(k) {
  kmeans(clustering_data_scaled, centers = k, nstart = 25)$tot.withinss
})

# Plot elbow curve
plot(1:10, wss, type = "b", 
     xlab = "Number of Clusters (k)", 
     ylab = "Within-cluster Sum of Squares",
     main = "Elbow Method for Optimal k")

K-means Clustering

# Perform k-means clustering
set.seed(123)
kmeans_result <- kmeans(clustering_data_scaled, centers = 4, nstart = 25)

# Clean data and add cluster assignments
covid_clean <- covid_clean[complete.cases(covid_clean), ]
covid_clean$cluster <- as.factor(kmeans_result$cluster)

# Visualize clusters
ggplot(covid_clean, aes(x = reorder(Name, Cumulative_incidence), 
                       y = Cumulative_incidence, 
                       color = cluster)) +
  geom_point(size = 3) +
  coord_flip() +
  theme_minimal() +
  labs(title = "COVID-19 Incidence Clusters",
       x = "Country",
       y = "Cumulative Incidence") +
  theme(
    plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
    axis.title = element_text(size = 12),
    legend.title = element_text(size = 12),
    legend.text = element_text(size = 10)
  )

Cluster Summary

# Calculate and display cluster summary statistics
cluster_summary <- covid_clean %>%
  group_by(cluster) %>%
  summarize(
    mean_incidence = mean(Cumulative_incidence),
    median_incidence = median(Cumulative_incidence),
    min_incidence = min(Cumulative_incidence),
    max_incidence = max(Cumulative_incidence),
    n_countries = n()
  )

# Display summary using a formatted table
knitr::kable(cluster_summary, 
             caption = "Summary Statistics by Cluster",
             digits = 2,
             col.names = c("Cluster", "Mean", "Median", "Minimum", "Maximum", "Number of Countries"))
Summary Statistics by Cluster
Cluster Mean Median Minimum Maximum Number of Countries
1 27210.86 26627.14 15822.70 37591.48 56
2 84912.31 79804.11 76264.66 109868.63 6
3 52597.16 54015.47 41084.20 66629.21 26
4 3415.98 1310.15 0.00 15174.06 150

Conclusions

Key Findings

  1. The distribution of COVID-19 incidence shows significant variation across countries
  2. Clear clusters of countries emerged based on their incidence rates
  3. The top 20 analysis revealed the most impacted nations
  4. The clustering analysis identified distinct patterns in global COVID-19 spread

Recommendations

  1. Focus on countries in higher incidence clusters for targeted interventions
  2. Use the identified patterns for future pandemic preparedness
  3. Consider the clustering results for resource allocation planning

Data Export

# Save processed data
write.csv(covid_clean, "covid_processed.csv", row.names = FALSE)

Analysis conducted by Imoudu Micheal
International Centre for Applied Mathematical Modelling and Data Analysis