Fernando Thiruthanathil Joby (s4193431)
Last updated: 19 October, 2025
read_csv("dataset.csv") %>%
filter(`Series Code` %in% c("NY.GDP.MKTP.KD", "EN.ATM.PM25.MC.M3")) %>%
mutate(v2020 = readr::parse_number(na_if(`2020 [YR2020]`, ".."))) %>%
select(`Country Name`, `Country Code`, `Series Code`, v2020) %>%
pivot_wider(names_from = `Series Code`, values_from = v2020) %>%
filter(!is.na(`Country Code`) & grepl("^[A-Z]{3}$", `Country Code`)) ->
data2020_readyFiltered Dataset to 2020: Focused analysis on data from the year 2020 only.
Selected Key Indicators: Retained GDP (constant 2015 US$) and PM2.5 air pollution (µg/m³).
Removed Irrelevant Columns: Dropped unused year columns (2018–2024) and metadata.
Handled Missing Values: Replaced “..” with NA and removed incomplete records.
Converted Data Types: Transformed 2020 values from text to numeric.
Reshaped Data using pivot_wider(): Created one row per country with GDP and PM2.5 as separate columns.
Removed Aggregates and Duplicates: Excluded regional aggregates (e.g., “World”) and kept unique country entries.
GDP_mean <- mean(data2020_ready$NY.GDP.MKTP.KD, na.rm = TRUE)
PM25_mean <- mean(data2020_ready$EN.ATM.PM25.MC.M3, na.rm = TRUE)
GDP_median <- median(data2020_ready$NY.GDP.MKTP.KD, na.rm = TRUE)
PM25_median <- median(data2020_ready$EN.ATM.PM25.MC.M3, na.rm = TRUE)
GDP_sd <- sd(data2020_ready$NY.GDP.MKTP.KD, na.rm = TRUE)
PM25_sd <- sd(data2020_ready$EN.ATM.PM25.MC.M3, na.rm = TRUE)
GDP_min <- min(data2020_ready$NY.GDP.MKTP.KD, na.rm = TRUE)
PM25_min <- min(data2020_ready$EN.ATM.PM25.MC.M3, na.rm = TRUE)
GDP_max <- max(data2020_ready$NY.GDP.MKTP.KD, na.rm = TRUE)
PM25_max <- max(data2020_ready$EN.ATM.PM25.MC.M3, na.rm = TRUE)
descriptive_stats <- data.frame(
Statistic = c("Mean", "Median", "Min", "Max", "Range", "Standard Deviation"),
GDP_2015_USD = c(GDP_mean, GDP_median, GDP_min, GDP_max, GDP_max - GDP_min, GDP_sd),
PM25_ug_m3 = c(PM25_mean, PM25_median, PM25_min, PM25_max, PM25_max - PM25_min, PM25_sd)
)
knitr::kable(descriptive_stats, digits = 3)| Statistic | GDP_2015_USD | PM25_ug_m3 |
|---|---|---|
| Mean | 3.962742e+11 | 23.533 |
| Median | 2.393679e+10 | 20.028 |
| Min | 4.401916e+07 | 4.895 |
| Max | 1.972358e+13 | 85.122 |
| Range | 1.972354e+13 | 80.227 |
| Standard Deviation | 1.786756e+12 | 14.993 |
op <- par(mfrow = c(1, 2), mar = c(4, 4, 2, 1)) # 1 row, 2 plots; tidy margins
hist(data2020_ready$EN.ATM.PM25.MC.M3,
main = "PM2.5 (µg/m³), 2020",
xlab = "PM2.5 (µg/m³)",
breaks = 20)
hist(log10(data2020_ready$NY.GDP.MKTP.KD),
main = "log10(GDP, 2015 US$), 2020",
xlab = "log10(GDP)",
breaks = 20)plot(EN.ATM.PM25.MC.M3 ~ log10(NY.GDP.MKTP.KD),
data = data2020_ready,
xlab = "log10(GDP, 2015 US$)",
ylab = "PM2.5 (µg/m³)",
main = "PM2.5 vs log10(GDP), 2020")pm25 <- na.omit(data2020_ready$EN.ATM.PM25.MC.M3)
par(mfrow = c(1,2))
hist(pm25, main = "PM2.5 Distribution", xlab = "µg/m³")
qqnorm(pm25); qqline(pm25, col = 2)##
## One Sample t-test
##
## data: pm25
## t = 8.049, df = 199, p-value = 7.443e-14
## alternative hypothesis: true mean is not equal to 15
## 95 percent confidence interval:
## 21.44257 25.62372
## sample estimates:
## mean of x
## 23.53315
model_pm25 <- lm(EN.ATM.PM25.MC.M3 ~ log10(NY.GDP.MKTP.KD),
data = data2020_ready)
plot(EN.ATM.PM25.MC.M3 ~ log10(NY.GDP.MKTP.KD),
data = data2020_ready,
xlab = "log10(GDP, 2015 US$)",
ylab = "PM2.5 (µg/m³)",
main = "PM2.5 vs log10(GDP)")
abline(model_pm25,col = "red")##
## Call:
## lm(formula = EN.ATM.PM25.MC.M3 ~ log10(NY.GDP.MKTP.KD), data = data2020_ready)
##
## Residuals:
## Min 1Q Median 3Q Max
## -18.450 -11.436 -3.408 5.273 61.693
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 24.09276 11.06626 2.177 0.0307 *
## log10(NY.GDP.MKTP.KD) -0.06564 1.04756 -0.063 0.9501
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 15.16 on 193 degrees of freedom
## (22 observations deleted due to missingness)
## Multiple R-squared: 2.034e-05, Adjusted R-squared: -0.005161
## F-statistic: 0.003926 on 1 and 193 DF, p-value: 0.9501
## 2.5 % 97.5 %
## (Intercept) 2.266428 45.919087
## log10(NY.GDP.MKTP.KD) -2.131771 2.000489
[1] “markdown - add local image file in R presentation,” Stack Overflow, May 24, 2022. [Online]. Available: https://stackoverflow.com/questions/31886610/add-local-image-file-in-r-presentation . [Accessed: 18-Oct-2025].
[2] “Polluted Air May Pollute Our Morality,” Association for Psychological Science, [Online]. Available: https://www.psychologicalscience.org/news/releases/polluted-air-may-pollute-our-morality.html . [Accessed: 18-Oct-2025].
[3] “PM2.5 particles in the air,” EPA Victoria, [Online]. Available: https://www.epa.vic.gov.au/pm25-particles-air . [Accessed: 18-Oct-2025].
[4] “Gross domestic product,” Wikipedia, [Online]. Available: https://en.wikipedia.org/wiki/Gross_domestic_product . [Accessed: 18-Oct-2025].
[5] M. Cheng, “How to Calculate the GDP of a Country,” Investopedia, May 14, 2015. [Online]. Available: https://www.investopedia.com/articles/investing/051415/how-calculate-gdp-country.asp . [Accessed: 18-Oct-2025].
[6] “World Development Indicators,” The World Bank DataBank, [Online]. Available: https://databank.worldbank.org/source/world-development-indicators# . [Accessed: 16-Oct-2025].
[7] “Hypothesis Testing: Types, Steps, Formula, and Examples,” Simplilearn, [Online]. Available: https://www.simplilearn.com/tutorials/statistics-tutorial/hypothesis-testing-in-statistics . [Accessed: 17-Oct-2025].
[8] R. Bevans, “Simple Linear Regression | An Easy Introduction & Examples,” Scribbr, Feb. 19, 2020. [Online]. Available: https://www.scribbr.com/statistics/simple-linear-regression/ . [Accessed: 17-Oct-2025].
[9] “ChatGPT Shared Links FAQ,” OpenAI Help Center, [Online]. Available: https://chatgpt.com/share/68f4a405-a8d4-8013-b6f1-c0cdd6844f20 . [Accessed: 17-Oct-2025].