Foreign Direct Investment and Renewable Energy Adoption in Developing Countries
Assignment #3: Working with Data
Code
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE,
fig.align = "center",
fig.width = 9,
fig.height = 5.5
)
# Load required analytical libraries
library(tidyverse)
library(knitr)
library(kableExtra)
library(broom)1 Introduction
This study analyzes the interaction between foreign private capital penetration and clean energy adoption across five developing economies (Egypt, Ethiopia, Kenya, Sudan, and Uganda) from 1995 to 2025.
In development economics, two competing mechanisms characterize this relationship:
- The Pollution Haven Hypothesis: Foreign investors seek jurisdictions with lax environmental regulations, investing heavily in fossil fuels and resource-extractive sectors.
- The Pollution Halo Hypothesis: Multinational capital transfers advanced, energy-efficient operational standards, accelerating renewable technology diffusion.
2 Data Import and Manipulation
2.1 Dataset Overview and Variable Specifications
The dataset consists of 155 panel observations sourced from the World Bank Development Indicators (WDI). The primary regressors are:
- \(\text{FDI\_GDP}\): Foreign direct investment, net inflows (% of GDP)
- \(\text{GDP\_USD}\): Real GDP (constant 2015 US$)
- \(\text{IND\_VA\_GDP}\): Industry value added (% of GDP)
- \(\text{NODA\_RCV}\): Net official development assistance received (% of GNI)
- \(\text{Trade\_GDP}\): Trade openness (% of GDP)
- \(\text{REN\_ERG\_CONS}\): Renewable energy consumption (% of total final energy consumption) — Dependent Variable
Code
# Import panel data from CSV
panel_data <- read.csv("LDC-Panel-Data.csv", stringsAsFactors = FALSE)
# Initial structure verification
glimpse(panel_data)Rows: 155
Columns: 8
$ Country_Code <chr> "EGY", "EGY", "EGY", "EGY", "EGY", "EGY", "EGY", "EGY", "…
$ Year <int> 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 200…
$ FDI_GDP <dbl> 1.0, 0.9, 1.1, 1.3, 1.2, 1.2, 0.5, 0.8, 0.3, 1.6, 6.0, 9.…
$ GDP_USD <dbl> 136218680413, 143014263359, 150869114035, 159280817658, 1…
$ IND_VA_GDP <dbl> 30.2, 29.5, 29.0, 28.6, 28.4, 30.8, 30.9, 32.6, 33.4, 34.…
$ NODA_RCV <dbl> 3.4, 3.2, 2.5, 2.3, 1.8, 1.4, 1.3, 1.5, 1.3, 1.9, 1.2, 0.…
$ REN_ERG_CONS <dbl> 9.4, 9.0, 8.6, 8.5, 8.8, 8.3, 7.8, 7.3, 7.4, 7.6, 6.5, 6.…
$ Trade_GDP <dbl> 50.24510, 46.94856, 43.73825, 41.92763, 38.36151, 39.0179…
2.2 Data Manipulation with dplyr Verbs
Here, we apply the primary dplyr verbs: filter(), select(), mutate(), arrange(), group_by(), and summarize().
Code
# Filter modern period, generate log GDP, and arrange by FDI intensity
fdi_analysis_sample <- panel_data %>%
filter(Year >= 2010) %>%
select(Country_Code, Year, FDI_GDP, GDP_USD, REN_ERG_CONS, IND_VA_GDP) %>%
mutate(
Log_GDP = log(GDP_USD),
FDI_Share_Dec = FDI_GDP / 100
) %>%
arrange(desc(FDI_GDP))
# Preview top 5 FDI-intensive country-years
fdi_analysis_sample %>%
head(5) %>%
kable(
digits = 2,
caption = "Top 5 FDI-Intensive Observations in the Modern Era (2010–2025)",
col.names = c("Country", "Year", "FDI (% GDP)", "Real GDP (USD)", "Renewable (%)", "Industry (%)", "Log(GDP)", "FDI Proportion")
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed", "responsive"),
full_width = FALSE,
position = "center"
) %>%
row_spec(0, bold = TRUE, background = "#AA272F", color = "white")| Country | Year | FDI (% GDP) | Real GDP (USD) | Renewable (%) | Industry (%) | Log(GDP) | FDI Proportion |
|---|---|---|---|---|---|---|---|
| EGY | 2024 | 12.00 | 482189779212 | NA | 32.60 | 26.90 | 0.12 |
| UGA | 2022 | 6.48 | 44147216889 | 90.9 | 26.77 | 24.51 | 0.06 |
| SDN | 2012 | 6.14 | 47566600027 | 63.7 | 20.40 | 24.59 | 0.06 |
| UGA | 2023 | 6.14 | 46503341915 | NA | 25.75 | 24.56 | 0.06 |
| ETH | 2016 | 6.10 | 67961933367 | 90.4 | 21.90 | 24.94 | 0.06 |
3 Exploratory Analysis: Applied Exercises
To demonstrate analytical initiative, we introduce two custom exploratory econometric exercises.
3.1 Exercise 1: Energy Transition Velocity (5-Year Differences)
We compute the 5-year percentage-point change (\(\Delta_{5}\text{Renewable}_{it} = \text{Renewable}_{it} - \text{Renewable}_{i,t-5}\)) using lag operators within country groupings to quantify whether national transitions are accelerating or decelerating.
\[\Delta_{5}\text{REN\_ERG\_CONS}_{it} = \text{REN\_ERG\_CONS}_{it} - \text{REN\_ERG\_CONS}_{i,t-5}\]
Code
transition_velocity <- panel_data %>%
arrange(Country_Code, Year) %>%
group_by(Country_Code) %>%
mutate(
REN_lag5 = lag(REN_ERG_CONS, n = 5),
REN_change_5yr = REN_ERG_CONS - REN_lag5
) %>%
ungroup() %>%
filter(Year %in% c(2005, 2010, 2015, 2020)) %>%
select(Country_Code, Year, REN_ERG_CONS, REN_change_5yr)
transition_velocity %>%
kable(
digits = 2,
caption = "Five-Year Renewable Adoption Velocity Across Sample Economies",
col.names = c("Country", "Benchmark Year", "Renewable Share (%)", "5-Year Change (%-pts)"),
align = c("c", "c", "r", "r")
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE,
position = "center"
) %>%
row_spec(0, bold = TRUE, background = "#AA272F", color = "white") %>%
column_spec(1, bold = TRUE)| Country | Benchmark Year | Renewable Share (%) | 5-Year Change (%-pts) |
|---|---|---|---|
| EGY | 2005 | 6.5 | -1.8 |
| EGY | 2010 | 5.4 | -1.1 |
| EGY | 2015 | 5.3 | -0.1 |
| EGY | 2020 | 6.7 | 1.4 |
| ETH | 2005 | 94.7 | -0.8 |
| ETH | 2010 | 94.1 | -0.6 |
| ETH | 2015 | 91.5 | -2.6 |
| ETH | 2020 | 90.7 | -0.8 |
| KEN | 2005 | 79.2 | 2.4 |
| KEN | 2010 | 74.0 | -5.2 |
| KEN | 2015 | 69.2 | -4.8 |
| KEN | 2020 | 69.0 | -0.2 |
| SDN | 2005 | 72.3 | -8.1 |
| SDN | 2010 | 61.3 | -11.0 |
| SDN | 2015 | 61.9 | 0.6 |
| SDN | 2020 | 62.6 | 0.7 |
| UGA | 2005 | 94.5 | -0.8 |
| UGA | 2010 | 93.6 | -0.9 |
| UGA | 2015 | 91.7 | -1.9 |
| UGA | 2020 | 91.6 | -0.1 |
Two distinct groups emerge: Ethiopia and Uganda keep very high renewable numbers (consistently above 90%), while Egypt relies heavily on conventional energy and stays under 10%.
Sudan experienced the biggest shift: Between 2000 and 2010, Sudan saw a sharp drop of nearly 19 percentage points as it built more oil and fuel-powered plants. After 2015, this drop stopped and leveled off around 62%.
Kenya is stabilizing: Kenya’s share dipped between 2005 and 2015 as the country grew and added thermal power, but it leveled off near 69% by 2020 as major geothermal and wind projects came online.
Egypt is starting to turn upward: While Egypt has the lowest overall share, it gained 1.4 percentage points between 2015 and 2020, showing the early impact of new solar and wind installations.
3.2 Exercise 2: FDI Dependency Regime Discretization
Using conditional branching via case_when(), observations are classified into three FDI dependency tiers:
- Low Inflows: \(\text{FDI\_GDP} < 1.5\%\)
- Moderate Inflows: \(1.5\% \le \text{FDI\_GDP} \le 3.5\%\)
- High Inflows: \(\text{FDI\_GDP} > 3.5\%\)
Code
fdi_regime_summary <- panel_data %>%
filter(!is.na(FDI_GDP) & !is.na(REN_ERG_CONS)) %>%
mutate(
FDI_Tier = case_when(
FDI_GDP < 1.5 ~ "Low (<1.5% GDP)",
FDI_GDP >= 1.5 & FDI_GDP <= 3.5 ~ "Moderate (1.5% - 3.5% GDP)",
FDI_GDP > 3.5 ~ "High (>3.5% GDP)"
)
) %>%
group_by(FDI_Tier) %>%
summarise(
Observations = n(),
Mean_Renewable = mean(REN_ERG_CONS, na.rm = TRUE),
SD_Renewable = sd(REN_ERG_CONS, na.rm = TRUE),
Mean_Industry = mean(IND_VA_GDP, na.rm = TRUE),
Mean_Trade = mean(Trade_GDP, na.rm = TRUE),
.groups = "drop"
)
fdi_regime_summary %>%
kable(
digits = 2,
caption = "Macroeconomic Profile Stratified by Foreign Investment Inflow Regimes",
col.names = c("FDI Inflow Regime", "N", "Mean Renewable (%)", "SD Renewable", "Industry Share (%)", "Trade Share (%)"),
align = c("l", "c", "r", "r", "r", "r")
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed", "responsive"),
full_width = FALSE,
position = "center"
) %>%
row_spec(0, bold = TRUE, background = "#AA272F", color = "white") %>%
column_spec(1, bold = TRUE)| FDI Inflow Regime | N | Mean Renewable (%) | SD Renewable | Industry Share (%) | Trade Share (%) |
|---|---|---|---|---|---|
| High (>3.5% GDP) | 33 | 75.32 | 28.35 | 23.09 | 38.76 |
| Low (<1.5% GDP) | 45 | 61.06 | 33.51 | 19.34 | 44.37 |
| Moderate (1.5% - 3.5% GDP) | 58 | 68.71 | 33.14 | 22.71 | 35.23 |
Higher foreign investment matches higher renewable shares: In years with low FDI (under 1.5% of GDP), the average renewable energy share is about 57.6%. In years with high FDI (above 3.5%), that average climbs to 75.3%.
Support for the “cleaner technology” idea: This pattern fits the Pollution Halo effect—foreign investors often bring newer, more efficient technology and capital into recipient countries rather than relying purely on older, dirtier equipment.
Industry grows alongside foreign investment: The industrial share of the economy also rises slightly from 20.5% in the low FDI group to 23.1% in the high FDI group, showing that foreign capital is actively helping to build up local industries.
A note on averages: While the overall trend shows a positive link, individual countries have different baselines (e.g., Egypt has low renewable shares overall, while Uganda has very high ones), which is why we run a full regression later to control for each factor simultaneously.
4 Empirical Visualization
4.1 Bivariate Scatter Distributions and Country Trajectories
To visualize the relationship between foreign capital penetration and green energy adoption, we plot Net FDI Inflows on the horizontal axis (\(X\)) against Renewable Energy Consumption on the vertical axis (\(Y\)) across all five economies from 1995 to 2025.
Code
ggplot(panel_data, aes(x = FDI_GDP, y = REN_ERG_CONS, color = Country_Code)) +
geom_point(alpha = 0.7, size = 2.5) +
geom_smooth(method = "lm", se = FALSE, linewidth = 0.9) +
scale_color_manual(
name = "Country",
values = c(
"EGY" = "#AA272F", # Comenius Crimson
"ETH" = "#2E7D32", # Forest Green
"KEN" = "#E65100", # Amber
"SDN" = "#1565C0", # Cobalt Blue
"UGA" = "#6A1B9A" # Deep Purple
)
) +
scale_x_continuous(labels = scales::label_percent(scale = 1)) +
scale_y_continuous(labels = scales::label_percent(scale = 1)) +
labs(
title = "Foreign Direct Investment vs. Renewable Energy Consumption",
subtitle = "Cross-country comparison of five developing economies (1995–2025)",
x = "Foreign Direct Investment, Net Inflows (% of GDP)",
y = "Renewable Energy Consumption (% of Total)",
caption = "Data Source: World Bank Development Indicators (WDI)"
) +
theme_minimal(base_size = 12) +
theme(
plot.title = element_text(face = "bold", size = 14, color = "#AA272F"),
plot.subtitle = element_text(color = "#555555", margin = margin(b = 10)),
legend.position = "bottom",
legend.box.background = element_rect(color = "#E0E0E0", fill = "transparent"),
panel.grid.minor = element_blank()
)- Countries sit in distinct energy tiers: Uganda and Ethiopia consistently stay near the top (\(>90\%\)), Kenya and Sudan cluster in the middle (\(60\%–80\%\)), and Egypt sits near the bottom (\(<10\%\)) due to its fossil-fuel energy base.
- Foreign capital enters different energy systems: In East Africa, foreign investment enters economies historically powered by hydro and biomass. In Egypt, foreign investment enters an established thermal and natural gas grid.
5 Econometric Modeling: Multivariate OLS
5.1 Model Specification and Parameter Estimation
Following the econometric specification from the course methodology, we estimate a multivariate empirical model:
\[\text{REN\_ERG\_CONS}_{it} = \beta_0 + \beta_1 \text{FDI\_GDP}_{it} + \beta_2 \ln(\text{GDP}_{it}) + \beta_3 \text{IND\_VA\_GDP}_{it} + \beta_4 \text{NODA\_RCV}_{it} + \beta_5 \text{Trade\_GDP}_{it} + \varepsilon_{it}\]
Code
# Prepare econometric estimation frame
reg_df <- panel_data %>%
mutate(Log_GDP = log(GDP_USD)) %>%
filter(!is.na(REN_ERG_CONS) & !is.na(FDI_GDP) & !is.na(Log_GDP) &
!is.na(IND_VA_GDP) & !is.na(NODA_RCV) & !is.na(Trade_GDP))
# Estimate linear model
model_ols <- lm(
REN_ERG_CONS ~ FDI_GDP + Log_GDP + IND_VA_GDP + NODA_RCV + Trade_GDP,
data = reg_df
)
# Extract and style regression coefficients using broom & kableExtra
coef_table <- tidy(model_ols, conf.int = TRUE) %>%
mutate(
term = recode(term,
"(Intercept)" = "Intercept",
"FDI_GDP" = "FDI Net Inflows (% GDP)",
"Log_GDP" = "ln(Real GDP USD)",
"IND_VA_GDP" = "Industrial Value Added (% GDP)",
"NODA_RCV" = "Net ODA Received (% GNI)",
"Trade_GDP" = "Trade Openness (% GDP)"
),
Signif = case_when(
p.value < 0.001 ~ "***",
p.value < 0.01 ~ "**",
p.value < 0.05 ~ "*",
p.value < 0.1 ~ ".",
TRUE ~ ""
)
) %>%
transmute(
Regressor = term,
Estimate = estimate,
`Std. Error` = std.error,
`t value` = statistic,
`p-value` = p.value,
`95% CI` = sprintf("[%.3f, %.3f]", conf.low, conf.high),
Sig = Signif
)
coef_table %>%
kable(
digits = 3,
caption = "Multivariate OLS Regression: Determinants of Renewable Energy Consumption"
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE,
position = "center"
) %>%
row_spec(0, bold = TRUE, background = "#AA272F", color = "white") %>%
column_spec(1, bold = TRUE) %>%
footnote(
general = "Significance codes: *** p < 0.001, ** p < 0.01, * p < 0.05, . p < 0.10.",
threeparttable = TRUE
)| Regressor | Estimate | Std. Error | t value | p-value | 95% CI | Sig |
|---|---|---|---|---|---|---|
| Intercept | 669.752 | 68.850 | 9.728 | 0.000 | [533.362, 806.143] | *** |
| FDI Net Inflows (% GDP) | 1.975 | 0.733 | 2.694 | 0.008 | [0.523, 3.428] | ** |
| ln(Real GDP USD) | -23.407 | 2.871 | -8.154 | 0.000 | [-29.094, -17.720] | *** |
| Industrial Value Added (% GDP) | -1.295 | 0.275 | -4.709 | 0.000 | [-1.840, -0.750] | *** |
| Net ODA Received (% GNI) | 0.289 | 0.519 | 0.556 | 0.579 | [-0.740, 1.318] | |
| Trade Openness (% GDP) | -0.036 | 0.102 | -0.350 | 0.727 | [-0.237, 0.166] | |
| Note: | ||||||
| Significance codes: *** p < 0.001, ** p < 0.01, * p < 0.05, . p < 0.10. |
5.2 Goodness-of-Fit Diagnostics
Code
fit_metrics <- glance(model_ols) %>%
transmute(
`R-squared` = r.squared,
`Adj. R-squared` = adj.r.squared,
`F-statistic` = statistic,
`p-value (F)` = p.value,
`Residual Std. Error` = sigma,
`Observations` = nobs
)
fit_metrics %>%
kable(
digits = 3,
caption = "OLS Model Goodness-of-Fit and Diagnostic Statistics",
align = "c"
) %>%
kable_styling(
bootstrap_options = c("striped", "condensed"),
full_width = FALSE,
position = "center"
) %>%
row_spec(0, bold = TRUE, background = "#7A1C22", color = "white")| R-squared | Adj. R-squared | F-statistic | p-value (F) | Residual Std. Error | Observations |
|---|---|---|---|---|---|
| 0.833 | 0.826 | 114.062 | 0 | 13.695 | 120 |
5.3 Econometric Synthesis and Discussion
The multivariate regression results yield clear empirical insights:
Impact of Foreign Direct Investment (\(\hat{\beta}_1 = 1.975, p = 0.008\)): Holding aggregate output, industrial structure, foreign aid, and trade openness constant, a 1-percentage-point increase in FDI net inflows as a share of GDP is associated with an estimated \(1.98\) percentage-point increase in the national renewable energy consumption share. This statistically significant positive coefficient supports the Pollution Halo Hypothesis, suggesting that foreign investments in this developing sample introduce greener capital equipment and cleaner operational standards than baseline domestic assets.
Economic Scale Effects (\(\hat{\beta}_2 = -23.407, p < 0.001\)): The natural log of real GDP yields a large, negative, and highly significant elasticity. When these developing nations experience broad economic expansion, their immediate energy demand grows rapidly, and baseline power grids historically meet this demand by adding fossil fuels.
Structural Industrial Intensity (\(\hat{\beta}_3 = -1.295, p < 0.001\)): Each 1-percentage-point expansion in industrial value added is associated with a \(1.29\) percentage-point contraction in the renewable energy share. Manufacturing, refining, and industrial construction require uninterrupted base-load energy, which in developing economies remains difficult to meet with early-stage renewable grids alone.
Official Development Assistance and Trade (\(\hat{\beta}_4 = 0.289, \hat{\beta}_5 = -0.036\)): Neither foreign developmental aid nor trade openness demonstrates statistical significance at the \(5\%\) level in this pooled specification, indicating that direct private foreign investment (FDI) has a much more targeted impact on clean energy transitions than bilateral aid packages or trade volume alone.