library(WDI)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.6
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.1 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.2
## ✔ purrr 1.2.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(broom)
library(scales)
##
## Attaching package: 'scales'
##
## The following object is masked from 'package:purrr':
##
## discard
##
## The following object is masked from 'package:readr':
##
## col_factor
theme_set(theme_minimal())
Economy & Growth
indicators: 1. GDP growth (annual %) — NY.GDP.MKTP.KD.ZG 2. Inflation, GDP deflator (annual %) — NY.GDP.DEFL.KD.ZG 3. Foreign direct investment, net inflows (BoP, current US$) — BX.KLT.DINV.CD.WD
Country: Turkey (TUR). Period: 1990–2023.
indicators <- c(
gdp_growth = "NY.GDP.MKTP.KD.ZG",
inflation = "NY.GDP.DEFL.KD.ZG",
fdi = "BX.KLT.DINV.CD.WD"
)
df <- WDI(country = "TUR", indicator = indicators, start = 1990, end = 2023) %>%
as_tibble() %>%
mutate(year = as.integer(year)) %>%
arrange(year)
df_clean <- df %>%
select(country, iso2c, iso3c, year, gdp_growth, inflation, fdi)
How did GDP growth change in Turkey between 1990 and 2023?
ggplot(df_clean, aes(year, gdp_growth)) +
geom_line(linewidth = 1) +
labs(title = "Q1. Turkey: GDP growth (annual %)", x="Year", y="%")
Answer: The graph shows the evolution of GDP growth over time and highlights years with strong expansions and contractions.
In which years did Turkey experience negative economic growth?
df_clean %>%
filter(!is.na(gdp_growth), gdp_growth < 0) %>%
select(year, gdp_growth)
## # A tibble: 4 × 2
## year gdp_growth
## <int> <dbl>
## 1 1994 -4.67
## 2 1999 -3.05
## 3 2001 -5.46
## 4 2009 -4.88
Answer: The table lists recession years where GDP growth was below zero.
What is the average GDP growth rate in Turkey over the period?
df_clean %>%
summarise(
mean_gdp_growth = mean(gdp_growth, na.rm=TRUE),
min_gdp_growth = min(gdp_growth, na.rm=TRUE),
max_gdp_growth = max(gdp_growth, na.rm=TRUE)
)
## # A tibble: 1 × 3
## mean_gdp_growth min_gdp_growth max_gdp_growth
## <dbl> <dbl> <dbl>
## 1 4.81 -5.46 11.8
Answer: Average, minimum and maximum values summarize the overall growth performance.
Is GDP growth volatile over time?
df_clean %>% summarise(sd_gdp_growth = sd(gdp_growth, na.rm=TRUE))
## # A tibble: 1 × 1
## sd_gdp_growth
## <dbl>
## 1 4.44
Answer: A higher standard deviation indicates higher volatility.
How did inflation (GDP deflator) change over time?
ggplot(df_clean, aes(year, inflation)) +
geom_line(linewidth = 1) +
labs(title = "Q5. Turkey: Inflation (GDP deflator, annual %)", x="Year", y="%")
Answer: The graph shows inflation dynamics and periods of spikes.
In which periods was inflation highest?
df_clean %>%
filter(!is.na(inflation)) %>%
arrange(desc(inflation)) %>%
select(year, inflation) %>%
head(10)
## # A tibble: 10 × 2
## year inflation
## <int> <dbl>
## 1 1995 158.
## 2 1994 105.
## 3 2022 95.5
## 4 1997 83.1
## 5 1996 76.8
## 6 1998 76.3
## 7 1993 68.4
## 8 2023 68.3
## 9 1992 65.2
## 10 1991 59.2
Answer: The table reports the top inflation years.
Is there a relationship between inflation and GDP growth?
df_clean %>%
drop_na(gdp_growth, inflation) %>%
ggplot(aes(inflation, gdp_growth)) +
geom_point() +
geom_smooth(method="lm", se=TRUE) +
labs(title="Q7. GDP growth vs Inflation (Turkey)", x="Inflation %", y="GDP growth %")
## `geom_smooth()` using formula = 'y ~ x'
df_clean %>%
drop_na(gdp_growth, inflation) %>%
summarise(correlation = cor(gdp_growth, inflation))
## # A tibble: 1 × 1
## correlation
## <dbl>
## 1 -0.106
Answer: The scatter plot and correlation indicate the direction and strength of the relationship.
How did FDI inflows change in Turkey?
ggplot(df_clean, aes(year, fdi)) +
geom_line(linewidth = 1) +
scale_y_continuous(labels = scales::label_number(scale_cut = scales::cut_si(""))) +
labs(title = "Q8. Turkey: FDI net inflows (current US$)", x = "Year", y = "US$")
Answer: FDI inflows increased after 2000 but declined during global crises.
Is there a relationship between FDI and GDP growth?
df_clean %>%
drop_na(fdi, gdp_growth) %>%
ggplot(aes(fdi, gdp_growth)) +
geom_point() +
geom_smooth(method = "lm", se = TRUE) +
scale_x_continuous(
labels = scales::label_number(
scale_cut = scales::cut_si("")
)
) +
labs(
title = "Q9. GDP growth vs FDI (Turkey)",
x = "FDI (current US$)",
y = "GDP growth (%)"
)
## `geom_smooth()` using formula = 'y ~ x'
Answer: A weak positive relationship is observed.
Does inflation and FDI significantly affect GDP growth?
reg_df <- df_clean %>% drop_na(gdp_growth, inflation, fdi)
model <- lm(gdp_growth ~ inflation + fdi, data = reg_df)
summary(model)
##
## Call:
## lm(formula = gdp_growth ~ inflation + fdi, data = reg_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.818 -2.152 0.597 3.252 6.576
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.189e+00 2.136e+00 1.961 0.0589 .
## inflation -2.386e-03 2.704e-02 -0.088 0.9303
## fdi 8.809e-11 1.434e-10 0.614 0.5435
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.524 on 31 degrees of freedom
## Multiple R-squared: 0.02311, Adjusted R-squared: -0.03991
## F-statistic: 0.3667 on 2 and 31 DF, p-value: 0.696
tidy(model, conf.int = TRUE)
## # A tibble: 3 × 7
## term estimate std.error statistic p.value conf.low conf.high
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 4.19e+ 0 2.14e+ 0 1.96 0.0589 -1.68e- 1 8.55e+ 0
## 2 inflation -2.39e- 3 2.70e- 2 -0.0882 0.930 -5.75e- 2 5.28e- 2
## 3 fdi 8.81e-11 1.43e-10 0.614 0.544 -2.04e-10 3.81e-10
Answer: Regression results indicate that inflation has a negative effect, while FDI has a limited impact on GDP growth.