Introduction to Our World in Data using R: What is the relation between internet usage and democracy?
Setup
#install.packages("owidR")
#install.packages("plotly")
suppressWarnings(suppressMessages({
library(owidR)
library(dplyr)
library(ggplot2)
library(plm)
library(texreg)
library(ggrepel)
library(stargazer)
library(ExPanDaR)
library(plotly)
}))
options(repr.plot.width = 7, repr.plot.height = 4)
Search data
owid_search("internet")
owid_search("democrac")
Import data
# Use the chart_id and rename the column to a shorter name
internet <- owid("share-of-individuals-using-the-internet", rename = "internet_use")
internet
democracy <- owid("political-regime-updated2016-distinction-democracies-and-full-democracies",
rename = "polity") %>%
filter(year %in% 1960:2020)
democracy
owid_source(internet)
Dataset Name: International Telecommunication Union (via World Bank)
Published By: World Development Indicators - World Bank (2021.07.30)
Link: http://data.worldbank.org/data-catalog/world-development-indicators
owid_source(democracy)
Dataset Name: Political Regime (OWID based on Polity IV and Wimmer & Min)
Published By: Our World In Data combined two datasets: Wimmer and Min (2006) for information on whether a country was colonized; Center for Systemic Peace for a measure of the political regime.
Link:
Polity 2 Measure ranges from -10 (autocracy) to +10 (full democracy). If a country was colonized in a given year is encoded as -20. In cases in which there was data from both Min and Wimmer and also Polity IV the Polity IV data is shown.
Plot evolution of the world
owid_plot(internet, filter = "World") +
labs(title = "Share of the World Population using Internet") +
scale_y_continuous(limits = c(0, 50))
Loading required namespace: showtext
Warning message in theme_owid():
“importing fonts requires the showtext pacakge”
#owid_plot(democracy, filter = "World")
Plot cross-country differences
owid_map(internet, year = 2017, palette = "YlGn") +
labs(title = "Share of Population Using Internet in 2017")
Loading required namespace: showtext
Warning message in theme_owid():
“importing fonts requires the showtext pacakge”
owid_map(democracy, palette = "YlGn") +
labs(title = "Political Regime (Polity IV)")
Loading required namespace: showtext
Warning message in theme_owid():
“importing fonts requires the showtext pacakge”
Plot evolution of selected countries
owid_plot(internet, summarise = FALSE, filter = c("United Kingdom", "Spain", "Russia", "Egypt", "Nigeria")) +
labs(title = "Share of Population with Using Internet") +
scale_y_continuous(limits = c(0, 100), labels = scales::label_number(suffix = "%")) # The labels argument allows you to make it clear that the value is a percentage
Loading required namespace: showtext
Warning message in theme_owid():
“importing fonts requires the showtext pacakge”
Panel regression
Importing control variables
gdp <- owid("gdp-per-capita-worldbank", rename = "gdp")
gov_exp <- owid("total-gov-expenditure-gdp-wdi", rename = "gov_exp")
age_dep <- owid("age-dependency-ratio-of-working-age-population", rename = "age_dep")
unemployment <- owid("unemployment-rate", rename = "unemp")
Merge datasets
data <- internet %>%
left_join(democracy) %>%
left_join(gdp) %>%
left_join(gov_exp) %>%
left_join(age_dep) %>%
left_join(unemployment)
Joining, by = c("entity", "code", "year")
Joining, by = c("entity", "code", "year")
Joining, by = c("entity", "code", "year")
Joining, by = c("entity", "code", "year")
Joining, by = c("entity", "code", "year")
Correlation: Internet and democracy
data %>%
filter(year == 2015) %>%
ggplot(aes(internet_use, polity)) +
geom_point(colour = "#57677D") +
geom_smooth(method = "lm", colour = "#DC5E78") +
labs(title = "Internet Use and Polity IV Score in 2015", x = "Internet Use", y = "Polity IV") +
theme_owid()
Loading required namespace: showtext
Warning message in theme_owid():
“importing fonts requires the showtext pacakge”
`geom_smooth()` using formula 'y ~ x'
Warning message:
“Removed 90 rows containing non-finite values (stat_smooth).”
Warning message:
“Removed 90 rows containing missing values (geom_point).”
Country fixed effects models
fe_model <- plm(polity ~ internet_use, data,
effect = c("individual"), index = "entity")
fe_model_2 <- plm(polity ~ internet_use + gdp + gov_exp + age_dep + unemp, data,
effect = c("individual"), index = "entity")
stargazer(fe_model, fe_model_2, type="text")
==============================================================
Dependent variable:
-------------------------------------------------
polity
(1) (2)
--------------------------------------------------------------
internet_use 0.023*** -0.002
(0.003) (0.003)
gdp 0.00000
(0.00001)
gov_exp 0.034***
(0.012)
age_dep -0.095***
(0.008)
unemp 0.022
(0.018)
--------------------------------------------------------------
Observations 4,144 2,073
R2 0.019 0.090
Adjusted R2 -0.021 0.028
F Statistic 78.805*** (df = 1; 3979) 38.441*** (df = 5; 1940)
==============================================================
Note: *p<0.1; **p<0.05; ***p<0.01