Paquetes
# Packages ----------------------------------------------------------------
#### Loading Necessary Packages
library(leaflet)## for geographical maps
library(ggplot2) ## for graphs and plots
library(readr) ## for reading data in R
library(tidyverse) ## for tidying data
library(ggmap) ## for plotting maps
library(wordcloud) ## for making word cloud
library(tm) ## text mining package
library(treemapify) ## for making Tree maps
library(gridExtra) ## for showing graphs in grids
#library(ggplotly) ## For Interactive plots
library(DT) ## For rendering R objects as HTML
library(readxl)
library(dplyr)
library(maps)
library(vdemdata)
library(corrplot)
library(corrr)
library(ggcorrplot)
library(GGally)
library(PerformanceAnalytics)
library(stargazer)
library(foreign)
library(MASS)
library(dplyr)
library(plotly)
library(survival)
library(remotes)
library(jtools)
library(huxtable)
library(ggstance)
library(broom.mixed)
library(webshot2)
library(broom)
library(gt)
library(gtsummary)
library(gtable)
library(gtools)
library(gt)
library(survival)
library(flextable)
library(webshot)
library(kableExtra)
library(magick)
library(glue)
library(webshot)
library(Hmisc)
setwd("C:/Users/santi/Downloads/Terrorism/GTD_Data_Anlalysis")
##Para evitar conflictos con otros paquetes
select <- dplyr::select
mutate <- dplyr::mutate
filter <- dplyr::filter
group_by <- dplyr::group_by
summarise <- dplyr::summarise
#http://rstudio-pubs-static.s3.amazonaws.com/336829_1097dfdfc03345c4aeb47081653ac1bb.html
Directories
# Directories -------------------------------------------------------------
dir.create("Correlation_Matrices_html")
dir.create("Summary_Tables")
dir.create("Summary_Tables/First_check")
dir.create("Summary_Tables/Final_check")
dir.create("Correlation_Plots")
dir.create("Correlation_Plots/All_attacks")
dir.create("Correlation_Plots/Domestic_attacks")
dir.create("Bases_CSV")
dir.create("Graficas_Definitivas")
#Subdirectories for plots
dir.create("Graficas_Definitivas/Freedom of expression")
dir.create("Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources")
dir.create("Graficas_Definitivas/Freedom of expression/Freedom of expression")
dir.create("Graficas_Definitivas/Freedom of expression/Alternative sources")
dir.create("Graficas_Definitivas/Online information flow")
dir.create("Graficas_Definitivas/Online information flow/Defamation protection")
dir.create("Graficas_Definitivas/Online information flow/Online media perspectives")
dir.create("Graficas_Definitivas/Online information flow/Online media existence")
dir.create("Graficas_Definitivas/Online information flow/social media to organize violence")
dir.create("Graficas_Definitivas/Online information flow/Government false information")
dir.create("Graficas_Definitivas/Online information flow/Party false information")
dir.create("Graficas_Definitivas/NA_graphs")
dir.create("Graficas_Definitivas/Variables suggested on previous studies")
dir.create("Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion")
dir.create("Graficas_Definitivas/Variables suggested on previous studies/Physical violence")
dir.create("Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints")
dir.create("Graficas_Definitivas/Variables suggested on previous studies/Polarization")
dir.create("Graficas_Definitivas/Control variables")
dir.create("Graficas_Definitivas/Control variables/education")
dir.create("Graficas_Definitivas/Control variables/GDP")
dir.create("Graficas_Definitivas/Control variables/Population")
dir.create("Graficas_Definitivas/Control variables/Civil society participation index")
#scatter polot dependent vs independet
dir.create("Graficas_Definitivas/Scatter_Dependent_vs_Independent")
dir.create("Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks")
#Dependent variable
dir.create("Graficas_Definitivas/Dependent_variable")
dir.create("Regression_Tables")
dir.create("Regression_Tables/All_attacks")
dir.create("Regression_Tables/All_attacks/Versions_Fullmodel")
dir.create("Regression_Tables/All_attacks/Variables_other_authors")
dir.create("Regression_Tables/Domestic")
dir.create("Regression_Tables/Domestic/Versions_Fullmodel")
dir.create("Regression_Tables/Domestic/Variables_other_authors")
dir.create("Regression_Tables/International")
dir.create("Regression_Tables/Unknown")
dir.create("Regression_Tables/Combined")
dir.create("Regression_Tables/Effectplots")
VDEM: Loading and cleaning Data
# VDEM: Loading and cleaning Data --------------------------------------------------------------------
#Cargar la base manualmente
Manual_vdem <- readRDS("Bases de datos/VDemocracy/V-Dem-CY-Full+Others-v12.rds" )
#Cargar la base más reciente desde el paquete
vdem<-vdem
#Cargar el Codebook desde el paquete
codebook <-codebook
#Filtrar a partir del año 2000
vdem2000<- vdem%>%
filter(year>=2000)
#Selección de paises "western" (no incluye ni Andorra ni Vatican City) y de
#variables de interés
vdem_western_2000_2021<- vdem2000 %>%
filter(country_id %in% c("77","21","67","168","96","144","81","5","148","82",
"6","66","174","101","158","91","20","163","185","76","186")) %>%
select(country_name,country_text_id,country_id,year,historical_date,
v2x_freexp_altinf,
v2x_freexp,v2mecenefm,v2mecenefm_osp,v2meharjrn,v2meharjrn_osp,v2meslfcen,v2meslfcen_osp,v2cldiscm,v2cldiscm_osp,v2cldiscw,v2cldiscw_osp,v2clacfree,v2clacfree_osp,
v2xme_altinf,v2mebias, v2mebias_osp,v2mecrit,v2mecrit_osp, v2merange,v2merange_osp,
v2smlawpr,v2smlawpr_osp,v2smonper,v2smonper_osp,v2smonex,v2smonex_osp,v2smorgviol,v2smorgviol_osp,v2smgovdom,v2smgovdom_osp,v2smpardom,v2smpardom_osp,
v2xcl_disc,v2x_clphy,v2xlg_legcon,v2smpolsoc,v2smpolsoc_osp,
e_peaveduc,e_pop,v2x_cspart,e_gdp)
vdem_world_2000_2021<- vdem2000 %>%
select(country_name,country_text_id,country_id,year,historical_date,
v2x_freexp_altinf,
v2x_freexp,v2mecenefm,v2mecenefm_osp,v2meharjrn,v2meharjrn_osp,v2meslfcen,v2meslfcen_osp,v2cldiscm,v2cldiscm_osp,v2cldiscw,v2cldiscw_osp,v2clacfree,v2clacfree_osp,
v2xme_altinf,v2mebias, v2mebias_osp,v2mecrit,v2mecrit_osp, v2merange,v2merange_osp,
v2smlawpr,v2smlawpr_osp,v2smonper,v2smonper_osp,v2smonex,v2smonex_osp,v2smorgviol,v2smorgviol_osp,v2smgovdom,v2smgovdom_osp,v2smpardom,v2smpardom_osp,
v2xcl_disc,v2x_clphy,v2xlg_legcon,v2smpolsoc,v2smpolsoc_osp,
e_peaveduc,e_pop,v2x_cspart,e_gdp,
#region:
e_regionpol_6C)
#Creating factor variable with regions
vdem_world_2000_2021 <- vdem_world_2000_2021 %>%
mutate(e_regionpol_6C_factor=
recode(e_regionpol_6C,
"1" = "Eastern Europe and Central Asia",
"2" = "Latin America and the Caribbean",
"3" = "The Middle East and North Africa",
"4" = "Sub-Saharan Africa",
"5" = "Western Europe and North America",
"6" ="Asia and Pacific"))
vdem_world_2000_2021$e_regionpol_6C_factor <- factor(vdem_world_2000_2021$e_regionpol_6C_factor, levels = c("Western Europe and North America",
"Eastern Europe and Central Asia",
"Asia and Pacific",
"Latin America and the Caribbean",
"Sub-Saharan Africa",
"The Middle East and North Africa"))
NAs grahps. First check
# NAs grahps. First check --------------------------------------------------
#Checking and replacing NAS:
NA_graph_vdem_western_2000_2021_before<- vdem_western_2000_2021 %>%
summarise_all(list(~is.na(.)))%>%
pivot_longer(everything(),
names_to = "Variables", values_to="Missing") %>%
count(Variables, Missing) %>%
ggplot(aes(y=Variables,x=n,fill=Missing))+
geom_col()+
scale_fill_brewer(palette = "Dark2")+
labs(title="NAs in dataset by variable",
subtitle ="Dataset: vdem_western_2000_2021 (before replacing)" )+
theme_classic()+
theme(axis.text.x = element_text( size = 13),#Tamaños de letra
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
#Export
ggsave(plot = NA_graph_vdem_western_2000_2021_before, filename = "./Graficas_Definitivas/NA_graphs/NA_graph_vdem_western_2000_2021_before.png",
width = 11,
height =11,
type = "cairo",
dpi = "retina")
#View for Markdown
NA_graph_vdem_western_2000_2021_before

#Replacing 19 Nas of Luxembourg in the education variable for mean values: only vdem_western_2000_2021
#The Nas on population and gdt wont be replaced as they
#correspond to the values for each contry on 2020 and 2021 and
#such years wont be included in the study
sum(is.na(vdem_western_2000_2021$e_peaveduc))
## [1] 22
vdem_western_2000_2021<- vdem_western_2000_2021 %>%
mutate( e_peaveduc = replace_na(e_peaveduc,mean(e_peaveduc, na.rm = TRUE)))
sum(is.na(vdem_western_2000_2021$e_peaveduc))
## [1] 0
#NAs graph after
NA_graph_vdem_western_2000_2021_after<- vdem_western_2000_2021 %>%
summarise_all(list(~is.na(.)))%>%
pivot_longer(everything(),
names_to = "Variables", values_to="Missing") %>%
count(Variables, Missing) %>%
ggplot(aes(y=Variables,x=n,fill=Missing))+
geom_col()+
scale_fill_brewer(palette = "Dark2")+
labs(title="NAs in dataset by variable",
subtitle ="Dataset: vdem_western_2000_2021 (after replacing)" )+
theme_classic()+
theme(axis.text.x = element_text( size = 13),#Tamaños de letra
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
#Export
ggsave(plot = NA_graph_vdem_western_2000_2021_after, filename = "./Graficas_Definitivas/NA_graphs/NA_graph_vdem_western_2000_2021_after.png",
width = 11,
height =11,
type = "cairo",
dpi = "retina")
#View for Markdown
NA_graph_vdem_western_2000_2021_after

Inverting some osp variables for graphs
# ##Inverting some osp variables for graphs --------
#VDEMWORLD
#v2mecenefm_osp (0-4)
vdem_world_2000_2021$v2mecenefm_osp <- 4-vdem_world_2000_2021$v2mecenefm_osp
#v2meharjrn_osp (0-4)
vdem_world_2000_2021$v2meharjrn_osp <- 4-vdem_world_2000_2021$v2meharjrn_osp
#v2meslfcen_osp (0-3)
vdem_world_2000_2021$v2meslfcen_osp <- 3-vdem_world_2000_2021$v2meslfcen_osp
#v2mebias_osp (0-4)
vdem_world_2000_2021$v2mebias_osp <- 4-vdem_world_2000_2021$v2mebias_osp
#v2smorgviol_osp (0-2)
vdem_world_2000_2021$v2smorgviol_osp <- 2-vdem_world_2000_2021$v2smorgviol_osp
#v2smgovdom_osp (0-4)
vdem_world_2000_2021$v2smgovdom_osp <- 4-vdem_world_2000_2021$v2smgovdom_osp
#v2smpardom_osp (0-4)
vdem_world_2000_2021$v2smpardom_osp <- 4-vdem_world_2000_2021$v2smpardom_osp
#v2smpolsoc_osp (0-4)
vdem_world_2000_2021$v2smpolsoc_osp <- 4-vdem_world_2000_2021$v2smpolsoc_osp
#VDEMWESTER
#v2mecenefm_osp (0-4)
vdem_western_2000_2021$v2mecenefm_osp <- 4-vdem_western_2000_2021$v2mecenefm_osp
#v2meharjrn_osp (0-4)
vdem_western_2000_2021$v2meharjrn_osp <- 4-vdem_western_2000_2021$v2meharjrn_osp
#v2meslfcen_osp (0-3)
vdem_western_2000_2021$v2meslfcen_osp <- 3-vdem_western_2000_2021$v2meslfcen_osp
#v2mebias_osp (0-4)
vdem_western_2000_2021$v2mebias_osp <- 4-vdem_western_2000_2021$v2mebias_osp
#v2smorgviol_osp (0-2)
vdem_western_2000_2021$v2smorgviol_osp <- 2-vdem_western_2000_2021$v2smorgviol_osp
#v2smgovdom_osp (0-4)
vdem_western_2000_2021$v2smgovdom_osp <- 4-vdem_western_2000_2021$v2smgovdom_osp
#v2smpardom_osp (0-4)
vdem_western_2000_2021$v2smpardom_osp <- 4-vdem_western_2000_2021$v2smpardom_osp
#v2smpolsoc_osp (0-4)
vdem_western_2000_2021$v2smpolsoc_osp <- 4-vdem_western_2000_2021$v2smpolsoc_osp
Inverting some point estimate variables for regressions
# Inverting some point estimate variables for regressions (Vde --------
##Inverting some point estimate variables for regressions
#v2mecenefm (0-4)
vdem_western_2000_2021$v2mecenefm <- vdem_western_2000_2021$v2mecenefm*-1
#v2meharjrn (0-4)
vdem_western_2000_2021$v2meharjrn <- vdem_western_2000_2021$v2meharjrn*-1
#v2meslfcen (0-3)
vdem_western_2000_2021$v2meslfcen <- vdem_western_2000_2021$v2meslfcen*-1
#v2mebias (0-4)
vdem_western_2000_2021$v2mebias <- vdem_western_2000_2021$v2mebias*-1
#v2smorgviol (0-2)
vdem_western_2000_2021$v2smorgviol <- vdem_western_2000_2021$v2smorgviol*-1
#v2smgovdom (0-4)
vdem_western_2000_2021$v2smgovdom <- vdem_western_2000_2021$v2smgovdom*-1
#v2smpardom (0-4)
vdem_western_2000_2021$v2smpardom<- vdem_western_2000_2021$v2smpardom*-1
#v2smpolsoc(0-4)
vdem_western_2000_2021$v2smpolsoc <- vdem_western_2000_2021$v2smpolsoc*-1
FREEDOM OF EXPRESSION
# FREEDOM OF EXPRESSION ---------------------------------------------------
#Freedom of Expression and Alternative Sources of Information index: v2x_freexp_altinf
#Question: To what extent does government respect press and media freedom, the freedom of
#ordinary people to discuss political matters at home and in the public sphere, as well as the
#freedom of academic and cultural expression?
#Clarification: This index includes all variables in the two indices v2x_freexp and v2xme_altinf.
#Scale: Interval, from low to high (0-1)
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_freexp_altinf))+
geom_histogram()+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2x_freexp_altinf<-vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_freexp_altinf))+
geom_histogram()+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources/hist_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2x_freexp_altinf)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2x_freexp_altinf))+
geom_histogram()+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)

#Export
hist_world_v2x_freexp_altinf<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2x_freexp_altinf))+
geom_histogram()+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)
ggsave(plot = hist_world_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources/hist_world_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2x_freexp_altinf)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_freexp_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2x_freexp_altinf<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_freexp_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources/geomline_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2x_freexp_altinf)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2x_freexp_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Index",
color ="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

facet_wrap(~ e_regionpol_6C_factor)
## <ggproto object: Class FacetWrap, Facet, gg>
## compute_layout: function
## draw_back: function
## draw_front: function
## draw_labels: function
## draw_panels: function
## finish_data: function
## init_scales: function
## map_data: function
## params: list
## setup_data: function
## setup_params: function
## shrink: TRUE
## train_scales: function
## vars: function
## super: <ggproto object: Class FacetWrap, Facet, gg>
#Export
geomline_world_v2x_freexp_altinf<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2x_freexp_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Index",
color ="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
facet_wrap(~ e_regionpol_6C_factor)
## <ggproto object: Class FacetWrap, Facet, gg>
## compute_layout: function
## draw_back: function
## draw_front: function
## draw_labels: function
## draw_panels: function
## finish_data: function
## init_scales: function
## map_data: function
## params: list
## setup_data: function
## setup_params: function
## shrink: TRUE
## train_scales: function
## vars: function
## super: <ggproto object: Class FacetWrap, Facet, gg>
ggsave(plot = geomline_world_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources/geomline_world_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2x_freexp_altinf)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_freexp_altinf))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)1",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2x_freexp_altinf<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_freexp_altinf))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources/geomline_porpaises_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2x_freexp_altinf)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2x_freexp_altinf<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources/boxplot_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2x_freexp_altinf)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)

#Export
boxplot_world_v2x_freexp_altinf<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression and Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression_Alternative sources/boxplot_world_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2x_freexp_altinf)
#5.12.5 Freedom of expression index: v2x_freexp
#Question: To what extent does government respect press and media freedom, the freedom of
#ordinary people to discuss political matters at home and in the public sphere, as well as the
#freedom of academic and cultural expression?
#Scale: Interval, from low to high (0-1).
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_freexp))+
geom_histogram()+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2x_freexp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_freexp))+
geom_histogram()+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2x_freexp,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression/hist_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2x_freexp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2x_freexp))+
geom_histogram(aes())+
labs(title="Freedom of Expression index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)

#Export
hist_world_v2x_freexp<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2x_freexp))+
geom_histogram(aes())+
labs(title="Freedom of Expression index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)
ggsave(plot = hist_world_v2x_freexp,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression/hist_world_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2x_freexp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_freexp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2x_freexp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_freexp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_world_v2x_freexp,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression/geomline_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2x_freexp)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2x_freexp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Freedom of Expression index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2x_freexp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2x_freexp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Freedom of Expression index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2x_freexp,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression/geomline_world_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2x_freexp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_freexp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2x_freexp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_freexp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2x_freexp,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression/geomline_porpaises_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2x_freexp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2x_freexp<-vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2x_freexp,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression/boxplot_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2x_freexp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)

#Export
boxplot_world_v2x_freexp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_freexp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of Expression index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2x_freexp,
filename = "./Graficas_Definitivas/Freedom of expression/Freedom of expression/boxplot_world_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2x_freexp)
#5.12.16 Alternative sources of information index (D) (v2xme_altinf)
#Question: To what extent is the media (a) un-biased in their coverage or lack of coverage of the
#opposition, (b) allowed to be critical of the regime, and (c) representative of a wide array of
#political perspectives?
#Scale: Interval, from low to high (0-1).
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2xme_altinf))+
geom_histogram()+
labs(title="Alternative sources of information index",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2xme_altinf<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2xme_altinf))+
geom_histogram()+
labs(title="Alternative sources of information index",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2xme_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Alternative sources/hist_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2xme_altinf)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2xme_altinf))+
geom_histogram()+
labs(title="Alternative sources of information index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2xme_altinf<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2xme_altinf))+
geom_histogram()+
labs(title="Alternative sources of information index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2xme_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Alternative sources/hist_world_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2xme_altinf)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2xme_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2xme_altinf<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2xme_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2xme_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Alternative sources/geomline_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2xme_altinf)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2xme_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2xme_altinf<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2xme_altinf,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2xme_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Alternative sources/geomline_world_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2xme_altinf)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2xme_altinf))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2xme_altinf<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2xme_altinf))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2xme_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Alternative sources/geomline_porpaises_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2xme_altinf)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xme_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2xme_altinf<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xme_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Alternative Sources of Information index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2xme_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Alternative sources/boxplot_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2xme_altinf)
#World
#Por Años
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xme_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2xme_altinf<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xme_altinf))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Alternative Sources of Information index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2xme_altinf,
filename = "./Graficas_Definitivas/Freedom of expression/Alternative sources/boxplot_world_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2xme_altinf)
Online information flow
# Online information flow -------------------------------------------------
#6.3.6 Defamation protection (C) (v2smlawpr)
#Question: Does the legal framework provide protection against defamatory online content, or hate
#speech?
#Responses:
#0: No. The law provides no protection against Internet defamation and hate speech.
#1: Not really. The law provides a weak protection and to very limited range of circumstances.
#2: Somewhat. The law provides some protection against Internet defamation and hate speech
#but in limited circumstances, or only to particular groups of people.
#3: Mostly. The law provides protection against Internet defamation and hate speech under
#many circumstances, and to most groups of people.
#4: Yes. The law provides comprehensive protection against Internet defamation and hate
#speech.
#Scale: Ordinal, converted to interval by the measurement model.
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2smlawpr_osp))+
geom_histogram()+
labs(title="Defamation protection",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2smlawpr_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2smlawpr_osp))+
geom_histogram()+
labs(title="Defamation protection",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Online information flow/Defamation protection/hist_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2smlawpr_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.numeric(v2smlawpr_osp)))+
geom_histogram()+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)

#Export
hist_world_v2smlawpr_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.numeric(v2smlawpr_osp)))+
geom_histogram()+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~ e_regionpol_6C_factor)
ggsave(plot = hist_world_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Online information flow/Defamation protection/hist_world_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2smlawpr_osp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smlawpr_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2smlawpr_osp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smlawpr_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Online information flow/Defamation protection/geomline_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2smlawpr_osp)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smlawpr_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2smlawpr_osp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smlawpr_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Online information flow/Defamation protection/geomline_world_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smlawpr_osp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smlawpr_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Defamation protection",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2smlawpr_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smlawpr_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Defamation protection",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Online information flow/Defamation protection/geomline_porpaises_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smlawpr_osp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smlawpr_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Defamation protection",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2smlawpr_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smlawpr_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Defamation protection",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Online information flow/Defamation protection/boxplot_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2smlawpr_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smlawpr_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2smlawpr_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smlawpr_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Defamation protection",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Online information flow/Defamation protection/boxplot_world_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2smlawpr_osp)
#6.4.2 Online media perspectives (C) (v2smonper)
#Additional versions: *_osp, *_ord, *_codelow, *_codehigh, *_sd, *_mean, *_nr
#Question: Do the major domestic online media outlets represent a wide range of political
#perspectives?
#Responses:
#0: The major domestic online media outlets represent only the government’s perspective.
#1: The major domestic online media outlets represent only the perspectives of the government
#and a government approved, semi-official opposition party.
#2: The major domestic online media outlets represent a variety of political perspectives but
#they systematically ignore at least one political perspective that is important in this society.
#3: All perspectives that are important in this society are represented in at least one of the
#major domestic online media outlets.
#4: All perspectives that are important in this society are represented in many major domestic
#online media outlets.
#Scale: Ordinal, converted to interval by the measurement model
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2smonper_osp))+
geom_histogram()+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2smonper_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2smonper_osp))+
geom_histogram()+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2smonper_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media perspectives/hist_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2smonper_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2smonper_osp))+
geom_histogram()+
labs(title="Online media perspectives",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2smonper_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2smonper_osp))+
geom_histogram()+
labs(title="Online media perspectives",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2smonper_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media perspectives/hist_world_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2smonper_osp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smonper_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2smonper_osp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smonper_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2smonper_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media perspectives/geomline_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2smonper_osp)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smonper_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Online media perspectives",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2smonper_osp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smonper_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Online media perspectives",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smonper_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media perspectives/geomline_world_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smonper_osp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smonper_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2smonper_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smonper_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2smonper_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media perspectives/geomline_porpaises_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2smonper_osp)
#Boxplots
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonper_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2smonper_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonper_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media perspectives",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2smonper_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media perspectives/boxplot_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2smonper_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonper_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media perspectives",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2smonper_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonper_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media perspectives",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2smonper_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media perspectives/boxplot_world_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2smonper_osp)
#6.4.1 Online media existence (C) (v2smonex)
#Additional versions: *_osp, *_ord, *_codelow, *_codehigh, *_sd, *_mean, *_nr
#Question: Do people consume domestic online media?
#Responses:
#0: Not at all. No one consumes domestic online media. Skip next question if this answer is
#selected.
#1: Limited. Domestic online media consumption is limited.
#2: Relatively extensive. Domestic online media consumption is common.
#3: Extensive. Almost everyone consumes domestic online media.
#Ordering: if 0, skip v2smonper
#Scale: Ordinal, converted to interval by the measurement model.
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2smonex_osp))+
geom_histogram()+
labs(title="Online media existence",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2smonex_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2smonex_osp))+
geom_histogram()+
labs(title="Online media existence",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2smonex_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media existence/hist_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2smonex_osp)
#World
hist_world_v2smonex_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2smonex_osp))+
geom_histogram()+
labs(title="Online media existence",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
#Export
ggsave(plot = hist_world_v2smonex_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media existence/hist_world_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2smonex_osp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smonex_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Online media existence",
subtitle= "2000-2021",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2smonex_osp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smonex_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Online media existence",
subtitle= "2000-2021",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2smonex_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media existence/geomline_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2smonex_osp)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smonex_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Online media existence",
subtitle= "2000-2021",
x="Years",
y = "Index",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2smonex_osp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smonex_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Online media existence",
subtitle= "2000-2021",
x="Years",
y = "Index",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smonex_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media existence/geomline_world_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smonex_osp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smonex_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Online media existence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2smonex_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smonex_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Online media existence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2smonex_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media existence/geomline_porpaises_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2smonex_osp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonex_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media existence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2smonex_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonex_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media existence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2smonex_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media existence/boxplot_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2smonex_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonex_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media existence",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2smonex_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smonex_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Online media existence",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2smonex_osp,
filename = "./Graficas_Definitivas/Online information flow/Online media existence/boxplot_world_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2smonex_osp)
#6.5.3 Use of social media to organize offline violence (C) (v2smorgviol)
#Question: How often do people use social media to organize offline violence?
#Responses:
#0: Frequently. There are numerous cases in which people have used social media to organize
#offline violence.
#1: Sometimes. There are a few cases in which people have used social media to organize offline
#violence.
#2: Never. People have never used social media to organize offline violence.
#Scale: Ordinal, converted to interval by the measurement model
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=v2smorgviol_osp))+
geom_histogram()+
labs(title="Use of social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2smorgviol_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2smorgviol_osp))+
geom_histogram()+
labs(title="Use of social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Online information flow/social media to organize violence/hist_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2smorgviol_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2smorgviol_osp))+
geom_histogram()+
labs(title="Use of social media to organize offline violence",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2smorgviol_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2smorgviol_osp))+
geom_histogram()+
labs(title="Use of social media to organize offline violence",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Online information flow/social media to organize violence/hist_world_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2smorgviol_osp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smorgviol_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2smorgviol_osp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smorgviol_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Online information flow/social media to organize violence/geomline_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2smorgviol_osp)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smorgviol_osp,.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Social media to organize offline violence",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2smorgviol_osp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smorgviol_osp,.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Social media to organize offline violence",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Online information flow/social media to organize violence/geomline_world_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smorgviol_osp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smorgviol_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2smorgviol_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smorgviol_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Online information flow/social media to organize violence/geomline_porpaises_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2smorgviol_osp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smorgviol_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2smorgviol_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smorgviol_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Social media to organize offline violence",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Online information flow/social media to organize violence/boxplot_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2smorgviol_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smorgviol_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Social media to organize offline violence",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2smorgviol_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smorgviol_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Social media to organize offline violence",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Online information flow/social media to organize violence/boxplot_world_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2smorgviol_osp)
#6.1.1 Government dissemination of false information domestic (C) (v2smgovdom)
#Question: How often do the government and its agents use social media to disseminate misleading
#viewpoints or false information to influence its own population?
#Responses:
#0: Extremely often. The government disseminates false information on all key political issues.
#1: Often. The government disseminates false information on many key political issues.
#2: About half the time. The government disseminates false information on some key political
#issues, but not others.
#3: Rarely. The government disseminates false information on only a few key political issues.
#4: Never, or almost never. The government never disseminates false information on key political
#issues.
#Scale: Ordinal, converted to interval by the measurement model
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=v2smgovdom_osp))+
geom_histogram()+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2smgovdom_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2smgovdom_osp))+
geom_histogram()+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Online information flow/Government false information/hist_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2smgovdom_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2smgovdom_osp))+
geom_histogram()+
labs(title="Government dissemination of false information domestic",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2smgovdom_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2smgovdom_osp))+
geom_histogram()+
labs(title="Government dissemination of false information domestic",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Online information flow/Government false information/hist_world_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2smgovdom_osp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smgovdom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2smgovdom_osp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smgovdom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Online information flow/Government false information/geomline_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2smgovdom_osp)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smgovdom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Government dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2smgovdom_osp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smgovdom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Government dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Online information flow/Government false information/geomline_world_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smgovdom_osp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smgovdom_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2smgovdom_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smgovdom_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Online information flow/Government false information/geomline_porpaises_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2smgovdom_osp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smgovdom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2smgovdom_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smgovdom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Government dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Online information flow/Government false information/boxplot_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2smgovdom_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smgovdom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Government dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2smgovdom_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smgovdom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Government dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Online information flow/Government false information/boxplot_world_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2smgovdom_osp)
#6.1.3 Party dissemination of false information domestic (C) (v2smpardom)
#Question: How often do major political parties and candidates for office use social media to
#disseminate misleading viewpoints or false information to influence their own population?
#Responses:
#0: Extremely often. Major political parties and candidates disseminate false information on
#all key political issues.
#1: Often. Major political parties and candidates disseminate false information on many key
#political issues.
#2: About half the time. Major political parties and candidates disseminate false information
#on some key political issues, but not others.
#3: Rarely. Major political parties and candidates disseminate false information on only a few
#key political issues.
#4: Never, or almost never. Major political parties and candidates never disseminate false
#information on key political issues.
#Scale: Ordinal, converted to interval by the measurement model
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=v2smpardom_osp))+
geom_histogram()+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2smpardom_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2smpardom_osp))+
geom_histogram()+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2smpardom_osp,
filename = "./Graficas_Definitivas/Online information flow/Party false information/hist_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2smpardom_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2smpardom_osp))+
geom_histogram()+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2smpardom_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2smpardom_osp))+
geom_histogram()+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2smpardom_osp,
filename = "./Graficas_Definitivas/Online information flow/Party false information/hist_world_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2smpardom_osp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smpardom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2smpardom_osp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smpardom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2smpardom_osp,
filename = "./Graficas_Definitivas/Online information flow/Party false information/geomline_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2smpardom_osp)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smpardom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Party dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2smpardom_osp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smpardom_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Party dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smpardom_osp,
filename = "./Graficas_Definitivas/Online information flow/Party false information/geomline_world_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smpardom_osp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smpardom_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2smpardom_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smpardom_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2smpardom_osp,
filename = "./Graficas_Definitivas/Online information flow/Party false information/geomline_porpaises_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2smpardom_osp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpardom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2smpardom_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpardom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Party dissemination of false information domestic",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2smpardom_osp,
filename = "./Graficas_Definitivas/Online information flow/Party false information/boxplot_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2smpardom_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpardom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Party dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2smpardom_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpardom_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Party dissemination of false information domestic",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2smpardom_osp,
filename = "./Graficas_Definitivas/Online information flow/Party false information/boxplot_world_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2smpardom_osp)
Variables suggested by previous studies
# Variables suggested by previous studies ---------------------
#5.12.9 Freedom of discussion (D) (v2xcl_disc)
#Question: Are citizens able to openly discuss political issues in private homes and in public spaces?
#Clarification: This indicator specifies the extent to which citizens are able to engage in private
#discussions, particularly on political issues, in private homes and public spaces restaurants,
#public transportation, sports events, work etc. without fear of harassment by other members
#of the polity or the public authorities. We are interested in restrictions by the government and
#its agents but also cultural restrictions or customary laws that are enforced by other members
#of the polity, sometimes in informal ways.
#Scale: Interval, from low to high (0-1).
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2xcl_disc))+
geom_histogram()+
labs(title="Freedom of discussion",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2xcl_disc<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2xcl_disc))+
geom_histogram()+
labs(title="Freedom of discussion",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2xcl_disc,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion/hist_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2xcl_disc)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2xcl_disc))+
geom_histogram()+
labs(title="Freedom of discussion",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2xcl_disc<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2xcl_disc))+
geom_histogram()+
labs(title="Freedom of discussion",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2xcl_disc,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion/hist_world_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2xcl_disc)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2xcl_disc,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Freedom of discussion",
subtitle= "Western countires (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2xcl_disc<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2xcl_disc,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Freedom of discussion",
subtitle= "Western countires (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2xcl_disc,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion/geomline_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2xcl_disc)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2xcl_disc,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Freedom of discussion",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2xcl_disc<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2xcl_disc,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Freedom of discussion",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2xcl_disc,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion/geomline_world_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2xcl_disc)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2xcl_disc))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Freedom of discussion",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2xcl_disc<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2xcl_disc))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Freedom of discussion",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2xcl_disc,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion/geomline_porpaises_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2xcl_disc)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xcl_disc))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of discussion",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2xcl_disc<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xcl_disc))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of discussion",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2xcl_disc,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion/boxplot_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2xcl_disc)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xcl_disc))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of discussion",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13)) +
facet_wrap(~ e_regionpol_6C_factor)

#Export
boxplot_world_v2xcl_disc<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xcl_disc))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Freedom of discussion",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13)) +
facet_wrap(~ e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2xcl_disc,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Freedom of discussion/boxplot_world_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2xcl_disc)
#5.5.2 Physical violence index (D) (v2x_clphy) (Piazza)
#Question: To what extent is civil liberty respected?
#Clarification: Civil liberty is understood as liberal freedom, where freedom is a property of
#individuals. Civil liberty is constituted by the absence of physical violence committed by
#government agents and the absence of constraints of private liberties and political liberties by
#the government.
#Scale: Interval, from low to high (0-1).
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_clphy))+
geom_histogram()+
labs(title="Physical violence index",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2x_clphy<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_clphy))+
geom_histogram()+
labs(title="Physical violence index",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2x_clphy,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Physical violence/hist_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2x_clphy)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2x_clphy))+
geom_histogram()+
labs(title="Physical violence index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2x_clphy<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2x_clphy))+
geom_histogram()+
labs(title="Physical violence index",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2x_clphy,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Physical violence/hist_world_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2x_clphy)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_clphy,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Physical violence index ",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2x_clphy<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2x_clphy,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Physical violence index ",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2x_clphy,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Physical violence/geomline_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2x_clphy)
#World
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_clphy,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Physical violence index ",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2x_clphy<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_clphy,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Physical violence index ",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2x_clphy,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Physical violence/geomline_world_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2x_clphy)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_clphy))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Physical violence index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2x_clphy<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_clphy))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Physical violence index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2x_clphy,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Physical violence/geomline_porpaises_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2x_clphy)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_clphy))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Physical violence index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2x_clphy<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_clphy))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Physical violence index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2x_clphy,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Physical violence/boxplot_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2x_clphy)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_clphy))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Physical violence index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2x_clphy<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_clphy))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Physical violence index",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2x_clphy,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Physical violence/boxplot_world_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2x_clphy)
#2.2.11 Legislative constraints on the executive index (D) (v2xlg_legcon)
#Question: To what extent are the legislature and government agencies e.g., comptroller general,
#general prosecutor, or ombudsman capable of questioning, investigating, and exercising
#oversight over the executive?
#Scale: Interval, from low to high (0-1).
#Source(s): v2lgqstexp v2lgotovst v2lginvstp v2lgoppart
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=v2xlg_legcon))+
geom_histogram()+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2xlg_legcon<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2xlg_legcon))+
geom_histogram()+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2xlg_legcon,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints/hist_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2xlg_legcon)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2xlg_legcon))+
geom_histogram()+
labs(title="Legislative constraints on the executive",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2xlg_legcon<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2xlg_legcon))+
geom_histogram()+
labs(title="Legislative constraints on the executive",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2xlg_legcon,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints/hist_world_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2xlg_legcon)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2xlg_legcon,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2xlg_legcon<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2xlg_legcon,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2xlg_legcon,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints/geomline_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2xlg_legcon)
#World
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2xlg_legcon,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Legislative constraints on the executive",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2xlg_legcon<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2xlg_legcon,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Legislative constraints on the executive",
subtitle= "2000-2021",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2xlg_legcon,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints/geomline_world_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2xlg_legcon)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2xlg_legcon))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2xlg_legcon<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2xlg_legcon))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2xlg_legcon,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints/geomline_porpaises_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2xlg_legcon)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xlg_legcon))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2xlg_legcon<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xlg_legcon))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Legislative constraints on the executive",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2xlg_legcon,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints/boxplot_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2xlg_legcon)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xlg_legcon))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Legislative constraints on the executive",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2xlg_legcon<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2xlg_legcon))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Legislative constraints on the executive",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2xlg_legcon,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Legislative constraints/boxplot_world_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2xlg_legcon)
#6.5.10 Polarization of society (C) (v2smpolsoc):
#Question: How would you characterize the differences of opinions on major political issues in this
#society?
#Clarification: While plurality of views exists in all societies, we are interested in knowing the
#extent to which these differences in opinions result in major clashes of views and polarization
#or, alternatively, whether there is general agreement on the general direction this society should
#develop.
#Responses:
#0: Serious polarization. There are serious differences in opinions in society on almost all key
#political issues, which result in major clashes of views.
#1: Moderate polarization. There are differences in opinions in society on many key political
#issues, which result in moderate clashes of views.
#2: Medium polarization. Differences in opinions are noticeable on about half of the key political
#issues, resulting in some clashes of views.
#3: Limited polarization. There are differences in opinions on only a few key political issues,
#resulting in few clashes of views.
#4: No polarization. There are differences in opinions but there is a general agreement on the
#direction for key political issues.
#Scale: Ordinal, converted to interval by the measurement model.
#Histograma
vdem_western_2000_2021 %>%
ggplot(aes(x=v2smpolsoc_osp))+
geom_histogram()+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2smpolsoc_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2smpolsoc_osp))+
geom_histogram()+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Index",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Polarization/hist_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2smpolsoc_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=v2smpolsoc_osp))+
geom_histogram()+
labs(title="Polarization of society",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
hist_world_v2smpolsoc_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=v2smpolsoc_osp))+
geom_histogram()+
labs(title="Polarization of society",
subtitle= "2000-2021",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = hist_world_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Polarization/hist_world_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_world_v2smpolsoc_osp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smpolsoc_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2smpolsoc_osp<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2smpolsoc_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Polarization/geomline_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2smpolsoc_osp)
#World
#Tendencia general
vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smpolsoc_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_world_v2smpolsoc_osp<- vdem_world_2000_2021 %>%
group_by(year,e_regionpol_6C_factor) %>%
summarise(Mean_variable = mean(v2smpolsoc_osp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line(aes(color=e_regionpol_6C_factor))+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
color="Region")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_world_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Polarization/geomline_world_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_world_v2smpolsoc_osp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smpolsoc_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2smpolsoc_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2smpolsoc_osp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Polarization/geomline_porpaises_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2smpolsoc_osp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpolsoc_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2smpolsoc_osp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpolsoc_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Polarization of society",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Polarization/boxplot_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2smpolsoc_osp)
#World
vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpolsoc_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Polarization of society",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)

#Export
boxplot_world_v2smpolsoc_osp<- vdem_world_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2smpolsoc_osp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Polarization of society",
subtitle= "2000-2021",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~e_regionpol_6C_factor)
ggsave(plot = boxplot_world_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Variables suggested on previous studies/Polarization/boxplot_world_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_world_v2smpolsoc_osp)
Control variables
# Control variables -------------------------------------------------------
#8.3.3 GDP (E) (e_gdp)
#Additional versions: *_sd
#Clarification: Point estimate from latent variable model of Gross Domestic Product based on a
#number of sources. For details, see the citation.
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=e_gdp))+
geom_histogram()+
labs(title="Gross domestic product",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_e_gdp<-vdem_western_2000_2021 %>%
ggplot(aes(x=e_gdp))+
geom_histogram()+
labs(title="Gross domestic product",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_e_gdp,
filename = "./Graficas_Definitivas/Control variables/GDP/hist_e_gdp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_e_gdp)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(e_gdp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
theme_classic()+
labs(title="Gross domestic product",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_e_gdp <- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(e_gdp,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
theme_classic()+
labs(title="Gross domestic product",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_e_gdp,
filename = "./Graficas_Definitivas/Control variables/GDP/geomline_e_gdp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_e_gdp)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=e_gdp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Gross domestic product",
subtitle= "Western countires (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_e_gdp<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=e_gdp))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Gross domestic product",
subtitle= "Western countires (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_e_gdp,
filename = "./Graficas_Definitivas/Control variables/GDP/geomline_porpaises_e_gdp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_e_gdp)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=e_gdp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Gross domestic product",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_e_gdp<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=e_gdp))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Gross domestic product",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_e_gdp,
filename = "./Graficas_Definitivas/Control variables/GDP/boxplot_e_gdp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_e_gdp)
#8.1.1 Education 15+ (E) (e_peaveduc)
#Question: What is the average years of education among citizens older than 15?
#Clarification: The Average years of education in the total population aged 15 years and older.
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=e_peaveduc))+
geom_histogram()+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_e_peaveduc<-vdem_western_2000_2021 %>%
ggplot(aes(x=e_peaveduc))+
geom_histogram()+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_e_peaveduc,
filename = "./Graficas_Definitivas/Control variables/education/hist_e_peaveduc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_e_peaveduc)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(e_peaveduc,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
theme_classic()+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_e_peaveduc <- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(e_peaveduc,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
theme_classic()+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_e_peaveduc,
filename = "./Graficas_Definitivas/Control variables/education/geomline_e_peaveduc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_e_peaveduc)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=e_peaveduc))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countires (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_e_peaveduc<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=e_peaveduc))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countires (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_e_peaveduc,
filename = "./Graficas_Definitivas/Control variables/education/geomline_porpaises_e_peaveduc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_e_peaveduc)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=e_peaveduc))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_e_peaveduc<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=e_peaveduc))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Average years of education among citizens older than 15",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_e_peaveduc,
filename = "./Graficas_Definitivas/Control variables/education/boxplot_e_peaveduc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_e_peaveduc)
#Population (E) (e_pop)
#Clarification: Point estimate from latent variable model of Population based on a number of sources.
#For details, see the citation.
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=e_pop))+
geom_histogram()+
labs(title="Population",
subtitle= "western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_e_pop<- vdem_western_2000_2021 %>%
ggplot(aes(x=e_pop))+
geom_histogram()+
labs(title="Population",
subtitle= "western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_e_pop,
filename = "./Graficas_Definitivas/Control variables/Population/hist_e_pop.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_e_pop)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(e_pop,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Population",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_e_pop<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(e_pop,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Population",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_e_pop,
filename = "./Graficas_Definitivas/Control variables/Population/geomline_e_pop.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_e_pop)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=e_pop))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Population",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_e_pop<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=e_pop))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Population",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_e_pop,
filename = "./Graficas_Definitivas/Control variables/Population/geomline_porpaises_e_pop.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_e_pop)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=e_pop))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Population",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_e_pop<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=e_pop))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Population",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_e_pop,
filename = "./Graficas_Definitivas/Control variables/Population/boxplot_e_pop.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_e_pop)
#2.2.13 Civil society participation index (D) (v2x_cspart)
#Project Manager(s): Michael Bernhard
#Additional versions: *_codelow, *_codehigh, *_sd
#Question: Are major CSOs routinely consulted by policymakers; how large is the involvement of
#people in CSOs; are women prevented from participating; and is legislative candidate
#nomination within party organization highly decentralized or made through party primaries?
#Clarification: The sphere of civil society lies in the public space between the private sphere and
#the state. Here, citizens organize in groups to pursue their collective interests and ideals. We
#call these groups civil society organizations CSOs. CSOs include, but are by no means limited
#to, interest groups, labor unions, spiritual organizations if they are engaged in civic or political
#activities, social movements, professional associations, charities, and other non-governmental
#organizations.
#The core civil society index CCSI is designed to provide a measure of a robust civil society,
#understood as one that enjoys autonomy from the state and in which citizens freely and actively
#pursue their political and civic goals, however conceived.
#Scale: Interval, from low to high (0-1).
#XSource(s): v2pscnslnl v2cscnsult v2csprtcpt v2csgender
#Histogram
vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_cspart))+
geom_histogram()+
labs(title="Civil society participation indeX",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_v2x_cspart<- vdem_western_2000_2021 %>%
ggplot(aes(x=v2x_cspart))+
geom_histogram()+
labs(title="Civil society participation indeX",
subtitle= "Western countries (2000-2021)",
x="Rating",
y = "Count",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 0,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_v2x_cspart,
filename = "./Graficas_Definitivas/Control variables/Civil society participation index/hist_v2x_cspart.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(hist_v2x_cspart)
#Tendencia general
vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_cspart,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Civil society participation indeX",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_v2x_cspart<- vdem_western_2000_2021 %>%
group_by(year) %>%
summarise(Mean_variable = mean(v2x_cspart,na.rm=T)) %>%
ggplot(aes(x=year,y=Mean_variable))+
geom_line()+
labs(title="Civil society participation index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_v2x_cspart,
filename = "./Graficas_Definitivas/Control variables/Civil society participation index/geomline_v2x_cspart.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_v2x_cspart)
#Por países
vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_cspart,na.rm=T))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Civil society participation indeX",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geomline_porpaises_v2x_cspart<- vdem_western_2000_2021 %>%
ggplot(aes(x=year,y=v2x_cspart,na.rm=T))+
geom_line()+
facet_wrap(~country_name)+
labs(title="Civil society participation indeX",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Index",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geomline_porpaises_v2x_cspart,
filename = "./Graficas_Definitivas/Control variables/Civil society participation index/geomline_porpaises_v2x_cspart.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geomline_porpaises_v2x_cspart)
#Boxplots
#Por Años
vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_cspart))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Civil society participation index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_v2x_cspart<- vdem_western_2000_2021 %>%
ggplot(aes(x=as.factor(year),y=v2x_cspart))+
geom_boxplot(fill="#1B9E77")+
stat_summary(fun.y="mean",color="red3", shape=20)+
labs(title="Civil society participation index",
subtitle= "Western countries (2000-2021)",
x="Years",
y = "Rating",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_v2x_cspart,
filename = "./Graficas_Definitivas/Control variables/Civil society participation index/boxplot_v2x_cspart.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_v2x_cspart)
GTD: Loading and cleaning Data
# GTD: Loading and cleaning Data -----------------------------------------------------------
gtd.raw <- read_xlsx("globalterrorismdb_0221dist (1).xlsx")
gtd.clean <- gtd.raw
dim(gtd.clean)
## [1] 201183 135
#Creando base de Western( Sin Andora ni Vatican City)
gtd.clean_Western <- gtd.clean %>% filter(country %in%
c("14","15","21","38","55","68",
"69","75","91","96","98","116","142",
"144","151","162","185","198","199",
"603","217"))
#Creating factor variable with type of attack
gtd.clean_Western <- gtd.clean_Western %>%
mutate(INT_LOG_FACTOR=
recode(INT_LOG,
"1" = "International",
"0" = "Domestic",
"-9" = "Unknown"))
#Creating country_text_id in GTD dataset
gtd.clean_Western$country_text_id <- NA
#Andorra (EXCLUDED)
#Australia (14)/AUS
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==14 ] <- "AUS"
#Austria (15) /AUT
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==15 ] <- "AUT"
#Belgium (21) /BEL
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==21 ] <- "BEL"
#Canada (38) /CAN
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==38 ] <- "CAN"
#Denmark (55) /DNK
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==55 ] <- "DNK"
#Finland (68) /FIN
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==68 ] <- "FIN"
#France (69) /FRA
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==69 ] <- "FRA"
#Germany (75) /DEU
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==75 ] <- "DEU"
#Iceland (91) /ISL
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==91 ] <- "ISL"
#Ireland (96) /IRL
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==96 ] <- "IRL"
#Italy (98) /ITA
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==98 ] <- "ITA"
#Luxembourg (116) /LUX
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==116 ] <- "LUX"
#Netherlands (142) /NLD
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==142 ] <- "NLD"
#New Zealand (144) /NZL
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==144 ] <- "NZL"
#Norway (151) /NOR
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==151 ] <- "NOR"
#PORTUGAL (162) /PRT
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==162 ] <- "PRT"
#Spain (185) /ESP
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==185 ] <- "ESP"
#Sweden (198) /SWE
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==198 ] <- "SWE"
#Switzerland (199) /CHE
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==199 ] <- "CHE"
#United States
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==217 ] <- "USA"
#United Kingdom (603) /GBR
gtd.clean_Western$country_text_id[ gtd.clean_Western$country==603 ] <- "GBR"
#Vatican City (EXCLUDED)
GTD: Exploratory graphs
# GTD: Exploratory graphs ----------------------------------------------------------------
#Base de ataques y muertes por pais
gtd_by_country <- gtd.clean_Western %>%
filter(iyear %in% c(2000:2019)) %>%
group_by(country_txt,country,INT_LOG,INT_LOG_FACTOR,iyear) %>%
summarise(Total = n(), Casualties=(sum(nkill,na.rm = T)))
#Base de ataques por año
gtd_by_year <- gtd_by_country %>%
group_by(iyear,INT_LOG,INT_LOG_FACTOR,country_txt,country)%>%
summarise("Total" = sum(Total))
#Incidentes terroristas en países occidentales por año
gtd_by_year %>%
ggplot(aes(x = as.factor(iyear), y = Total,fill = as.factor(INT_LOG_FACTOR))) +
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Year",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geom_col_total_attacks_year <- gtd_by_year %>%
ggplot(aes(x = as.factor(iyear), y = Total,fill = as.factor(INT_LOG_FACTOR))) +
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Year",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geom_col_total_attacks_year,
filename = "./Graficas_Definitivas/Dependent_variable/geom_col_total_attacks_year.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geom_col_total_attacks_year)
#Incidenntes terroristas en países occidentales por año (Position = Dodge)
gtd_by_year %>%
ggplot(aes(x = as.factor(iyear), y = Total,fill = as.factor(INT_LOG_FACTOR))) +
labs(x = "Country",y = "Total No of Attacks") +
geom_col(position = "dodge") +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Year",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geom_col_total_attacks_year_divided<- gtd_by_year %>%
ggplot(aes(x = as.factor(iyear), y = Total,fill = as.factor(INT_LOG_FACTOR))) +
labs(x = "Country",y = "Total No of Attacks") +
geom_col(position = "dodge") +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Year",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geom_col_total_attacks_year_divided,
filename = "./Graficas_Definitivas/Dependent_variable/geom_col_total_attacks_year_divided.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geom_col_total_attacks_year_divided)
#Incidenntes terroristas en países occidentales por país
gtd_by_country%>%
ggplot(aes(x = country_txt, y = Total,fill = as.factor(INT_LOG_FACTOR)))+
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geom_col_total_attacks_country<- gtd_by_country %>%
ggplot(aes(x = country_txt, y = Total,fill = as.factor(INT_LOG_FACTOR)))+
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geom_col_total_attacks_country,
filename = "./Graficas_Definitivas/Dependent_variable/geom_col_total_attacks_country.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geom_col_total_attacks_country)
#Casualties by country
gtd_by_country%>%
ggplot(aes(x = country_txt, y = Casualties,fill = as.factor(INT_LOG_FACTOR)))+
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist casualties in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geom_col_total_casualties_country<- gtd_by_country%>%
ggplot(aes(x = country_txt, y = Casualties,fill = as.factor(INT_LOG_FACTOR)))+
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist casualties in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geom_col_total_casualties_country,
filename = "./Graficas_Definitivas/Dependent_variable/geom_col_total_casualties_country.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geom_col_total_casualties_country)
#Casualties by Year
gtd_by_country%>%
ggplot(aes(x = as.factor(iyear), y = Casualties,fill = as.factor(INT_LOG_FACTOR)))+
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist casualties in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
geom_col_total_casualties_year <- gtd_by_country%>%
ggplot(aes(x = as.factor(iyear), y = Casualties,fill = as.factor(INT_LOG_FACTOR)))+
labs(x = "Country",y = "Total No of Attacks") +
geom_col() +
scale_fill_brewer(palette = "Accent")+
labs(title="Terrorist casualties in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = geom_col_total_casualties_year,
filename = "./Graficas_Definitivas/Dependent_variable/geom_col_total_casualties_year.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(geom_col_total_casualties_year)
#Boxplots attacks
gtd_by_country%>%
ggplot(aes(x = as.factor(iyear), y = Total))+
labs(x = "Country",y = "Total No of Attacks") +
geom_boxplot(fill="#1B9E77") +
stat_summary(fun.y="mean",color="red", shape=20)+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
boxplot_total_attacks_year <- gtd_by_country%>%
ggplot(aes(x = as.factor(iyear), y = Total))+
labs(x = "Year",y = "Total No of Attacks") +
geom_boxplot(fill="#1B9E77") +
stat_summary(fun.y="mean",color="red", shape=20)+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = boxplot_total_attacks_year,
filename = "./Graficas_Definitivas/Dependent_variable/boxplot_total_attacks_year.png",
width = 14, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_total_attacks_year)
#Boxplots attacks divided
gtd_by_country%>%
ggplot(aes(x = as.factor(iyear), y = Total))+
labs(x = "Country",y = "Total No of Attacks") +
geom_boxplot(fill="#1B9E77") +
stat_summary(fun.y="mean",color="red", shape=20)+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~INT_LOG_FACTOR)

#Export
boxplot_total_attacks_year_divided <- gtd_by_country%>%
ggplot(aes(x = as.factor(iyear), y = Total))+
labs(x = "Year",y = "Total No of Attacks") +
geom_boxplot(fill="#1B9E77") +
stat_summary(fun.y="mean",color="red", shape=20)+
labs(title="Terrorist attacks in western countries",
subtitle= "2000-2019",
x="Country",
y = "Number of atacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13, angle = 45,hjust = 0.5,vjust = 0.5),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~INT_LOG_FACTOR)
ggsave(plot = boxplot_total_attacks_year_divided,
filename = "./Graficas_Definitivas/Dependent_variable/boxplot_total_attacks_year_divided.png",
width = 14, height = 7,
type= "cairo",
dpi = "retina")
ggplotly(boxplot_total_attacks_year_divided)
Checking that vectors are identical in GTD and Vdem dastasets
# Checking that vectors are identical in GTD and Vdem dastasets -----------
View(gtd.clean_Western %>%
select(country,country_txt,country_text_id) %>%
group_by(country,country_txt,country_text_id) %>%
summarise())
vector1 <- unique(gtd.clean_Western$country_text_id)
vector2 <- unique(vdem_western_2000_2021$country_text_id)
vector1 %in% vector2
## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [16] TRUE TRUE TRUE TRUE TRUE TRUE
vector2 %in% vector1
## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [16] TRUE TRUE TRUE TRUE TRUE TRUE
#Creando "not in"
`%!in%` <- Negate(`%in%`)
vector1 %!in% vector2
## [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
vector2 %!in% vector1
## [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
unique(gtd.clean_Western$country_text_id)
## [1] "USA" "ITA" "CHE" "ESP" "IRL" "GBR" "NLD" "BEL" "CAN" "AUS" "SWE" "AUT"
## [13] "FRA" "PRT" "NZL" "DNK" "NOR" "LUX" "ISL" "FIN" "DEU"
unique(vdem_western_2000_2021$country_text_id)
## [1] "SWE" "CHE" "USA" "PRT" "CAN" "AUS" "FRA" "DEU" "IRL" "ITA" "NLD" "ESP"
## [13] "GBR" "AUT" "BEL" "DNK" "FIN" "ISL" "LUX" "NZL" "NOR"
sum(is.na(gtd.clean_Western$country_text_id))
## [1] 0
Creating unique ID (Combining year and country_txt_id)
# Creating unique ID (Combining year and country_txt_id) ---------------------
gtd.clean_Western$new_id <- paste(gtd.clean_Western$country_text_id, gtd.clean_Western$iyear, sep= "_")
vdem_western_2000_2021$new_id <- paste(vdem_western_2000_2021$country_text_id, vdem_western_2000_2021$year, sep= "_")
View(vdem_western_2000_2021)
View(gtd.clean_Western %>%
select(country,country_txt,country_text_id,new_id) %>%
group_by(country,country_txt,country_text_id,new_id) %>%
summarise())
#Cheking that both ids are indentical/ creating gtd_clean_Western_2000_2019
gtd_clean_Western_2000_2019 <- gtd.clean_Western %>%
select(eventid,iyear,imonth,iday,approxdate,country,country_txt,country_text_id,
city,summary,INT_LOG,INT_LOG_FACTOR,nkill,nkillter,nwound,nwoundte,new_id) %>%
filter(iyear %in% c(2000:2019))
##Cheking
#set diff (#display items that are only in first vector, but not in second vector)
vector_1<-unique(gtd_clean_Western_2000_2019$new_id)
vector_2<-unique(vdem_western_2000_2021$new_id)
setdiff(vector_1,vector_2)
## character(0)
sum(is.na(gtd_clean_Western_2000_2019$new_id))
## [1] 0
sum(is.na(vdem_western_2000_2021$new_id))
## [1] 0
glimpse(gtd_clean_Western_2000_2019)
## Rows: 3,743
## Columns: 17
## $ eventid <dbl> 200001010010, 200001010011, 200001010027, 200001020001~
## $ iyear <dbl> 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, ~
## $ imonth <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~
## $ iday <dbl> 1, 1, 1, 2, 3, 3, 3, 4, 5, 5, 6, 7, 8, 8, 8, 10, 13, 1~
## $ approxdate <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ country <dbl> 185, 185, 217, 75, 217, 217, 217, 185, 185, 185, 185, ~
## $ country_txt <chr> "Spain", "Spain", "United States", "Germany", "United ~
## $ country_text_id <chr> "ESP", "ESP", "USA", "DEU", "USA", "USA", "USA", "ESP"~
## $ city <chr> "Galdacano", "Guernica", "Mesick", "Erfurt", "Petaluma~
## $ summary <chr> "01/01/2000: A Civil Guard barracks in Galdacano, Vizc~
## $ INT_LOG <dbl> -9, -9, 0, 0, 0, -9, -9, -9, -9, -9, -9, -9, 0, -9, -9~
## $ INT_LOG_FACTOR <chr> "Unknown", "Unknown", "Domestic", "Domestic", "Domesti~
## $ nkill <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, ~
## $ nkillter <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~
## $ nwound <dbl> 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~
## $ nwoundte <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~
## $ new_id <chr> "ESP_2000", "ESP_2000", "USA_2000", "DEU_2000", "USA_2~
glimpse(vdem_western_2000_2021)
## Rows: 462
## Columns: 48
## $ country_name <chr> "Sweden", "Sweden", "Sweden", "Sweden", "Sweden", "S~
## $ country_text_id <chr> "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SW~
## $ country_id <dbl> 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5~
## $ year <dbl> 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008~
## $ historical_date <date> 2000-12-31, 2001-12-31, 2002-12-31, 2003-12-31, 200~
## $ v2x_freexp_altinf <dbl> 0.975, 0.975, 0.975, 0.975, 0.975, 0.975, 0.975, 0.9~
## $ v2x_freexp <dbl> 0.978, 0.978, 0.978, 0.978, 0.978, 0.978, 0.978, 0.9~
## $ v2mecenefm <dbl> -3.471, -3.471, -3.471, -3.471, -3.471, -3.471, -3.4~
## $ v2mecenefm_osp <dbl> 0.063, 0.063, 0.063, 0.063, 0.063, 0.063, 0.063, 0.0~
## $ v2meharjrn <dbl> -2.492, -2.492, -2.492, -2.492, -2.492, -2.492, -2.4~
## $ v2meharjrn_osp <dbl> 0.736, 0.736, 0.736, 0.736, 0.736, 0.736, 0.736, 0.7~
## $ v2meslfcen <dbl> -2.335, -2.335, -2.335, -2.335, -2.335, -2.335, -2.3~
## $ v2meslfcen_osp <dbl> 0.261, 0.261, 0.261, 0.261, 0.261, 0.261, 0.261, 0.2~
## $ v2cldiscm <dbl> 2.569, 2.569, 2.569, 2.569, 2.569, 2.569, 2.569, 3.0~
## $ v2cldiscm_osp <dbl> 3.843, 3.843, 3.843, 3.843, 3.843, 3.843, 3.843, 3.9~
## $ v2cldiscw <dbl> 2.316, 2.316, 2.316, 2.316, 2.316, 2.316, 2.316, 2.3~
## $ v2cldiscw_osp <dbl> 3.771, 3.771, 3.771, 3.771, 3.771, 3.771, 3.771, 3.7~
## $ v2clacfree <dbl> 3.263, 3.263, 3.263, 3.263, 3.263, 3.263, 3.263, 3.2~
## $ v2clacfree_osp <dbl> 3.896, 3.896, 3.896, 3.896, 3.896, 3.896, 3.896, 3.8~
## $ v2xme_altinf <dbl> 0.955, 0.955, 0.955, 0.955, 0.955, 0.955, 0.955, 0.9~
## $ v2mebias <dbl> -2.532, -2.532, -2.532, -2.532, -2.532, -2.532, -2.5~
## $ v2mebias_osp <dbl> 0.192, 0.192, 0.192, 0.192, 0.192, 0.192, 0.192, 0.2~
## $ v2mecrit <dbl> 3.177, 3.177, 3.177, 3.177, 3.177, 3.177, 3.177, 3.1~
## $ v2mecrit_osp <dbl> 2.956, 2.956, 2.956, 2.956, 2.956, 2.956, 2.956, 2.9~
## $ v2merange <dbl> 2.066, 2.066, 2.066, 2.066, 2.066, 2.066, 2.066, 2.0~
## $ v2merange_osp <dbl> 2.807, 2.807, 2.807, 2.807, 2.807, 2.807, 2.807, 2.8~
## $ v2smlawpr <dbl> 2.417, 2.417, 2.417, 2.417, 2.417, 2.417, 2.417, 2.4~
## $ v2smlawpr_osp <dbl> 3.836, 3.836, 3.836, 3.836, 3.836, 3.836, 3.836, 3.8~
## $ v2smonper <dbl> 1.451, 1.451, 1.451, 1.451, 1.451, 1.451, 1.451, 1.4~
## $ v2smonper_osp <dbl> 3.487, 3.487, 3.487, 3.487, 3.487, 3.487, 3.487, 3.4~
## $ v2smonex <dbl> 1.229, 1.229, 1.229, 1.229, 1.421, 1.421, 1.908, 1.9~
## $ v2smonex_osp <dbl> 2.617, 2.617, 2.617, 2.617, 2.694, 2.694, 2.843, 2.8~
## $ v2smorgviol <dbl> 0.446, 0.446, 0.446, 0.446, 0.446, 0.446, 0.446, 0.4~
## $ v2smorgviol_osp <dbl> 0.904, 0.904, 0.904, 0.904, 0.904, 0.904, 0.904, 0.9~
## $ v2smgovdom <dbl> -2.456, -2.456, -2.456, -2.456, -2.456, -2.456, -2.4~
## $ v2smgovdom_osp <dbl> 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.1~
## $ v2smpardom <dbl> -2.317, -2.317, -2.317, -2.317, -2.317, -2.317, -2.3~
## $ v2smpardom_osp <dbl> 0.398, 0.398, 0.398, 0.398, 0.398, 0.398, 0.398, 0.3~
## $ v2xcl_disc <dbl> 0.957, 0.957, 0.957, 0.957, 0.957, 0.957, 0.957, 0.9~
## $ v2x_clphy <dbl> 0.990, 0.990, 0.990, 0.990, 0.990, 0.990, 0.990, 0.9~
## $ v2xlg_legcon <dbl> 0.972, 0.972, 0.972, 0.972, 0.972, 0.972, 0.971, 0.9~
## $ v2smpolsoc <dbl> -1.293, -1.293, -1.293, -1.293, -1.293, -1.293, -1.2~
## $ v2smpolsoc_osp <dbl> 1.511, 1.511, 1.511, 1.511, 1.511, 1.511, 1.511, 1.5~
## $ e_peaveduc <dbl> 11.530, 11.562, 11.594, 11.626, 11.658, 11.690, 11.7~
## $ e_pop <dbl> 944.506, 947.176, 945.940, 952.667, 958.108, 959.564~
## $ v2x_cspart <dbl> 0.956, 0.956, 0.956, 0.956, 0.956, 0.956, 0.956, 0.9~
## $ e_gdp <dbl> 34848.11, 35565.51, 36048.57, 36998.11, 38503.91, 39~
## $ new_id <chr> "SWE_2000", "SWE_2001", "SWE_2002", "SWE_2003", "SWE~
Final Merge (using “left bind” not “merge”)
# Final Merge (using "left bind" not "merge") -------------------------------------------------------------
#total_INTLOG_domestic
INTLOG_domestic <- gtd_clean_Western_2000_2019 %>%
filter(INT_LOG_FACTOR=="Domestic") %>%
group_by(new_id,
INT_LOG,INT_LOG_FACTOR) %>%
summarise(
total_attacks = n(),
sum_nkill=(sum(nkill,na.rm = T)),
sum_nkillter=(sum(nkillter,na.rm = T)),
sum_nwound=(sum(nwound,na.rm = T)),
sum_nwoundte=(sum(nwoundte,na.rm = T)))
total_INTLOG_domestic<- left_join(vdem_western_2000_2021, INTLOG_domestic, by="new_id")
total_INTLOG_domestic <- total_INTLOG_domestic %>%
mutate(total_attacks = coalesce(total_attacks, 0),
sum_nkill = coalesce(sum_nkill, 0),
sum_nkillter = coalesce(sum_nkillter,0),
sum_nwound = coalesce(sum_nwound,0),
sum_nwoundte = coalesce(sum_nwoundte,0))
total_INTLOG_domestic$INT_LOG=0
total_INTLOG_domestic$INT_LOG_FACTOR="Domestic"
#Filter (2000-2019)
total_INTLOG_domestic <- total_INTLOG_domestic %>%
filter(year %in% c(2000:2019))
write.csv(total_INTLOG_domestic,"Bases_CSV/total_INTLOG_domestic.csv", row.names = FALSE)
#total_INTLOG_domestic_lagged
total_INTLOG_domestic_lagged<- total_INTLOG_domestic %>%
group_by(country_name) %>%
mutate(total_attacks=dplyr::lead(total_attacks,n=1, default = NA)) %>%
as.data.frame()
total_INTLOG_domestic_lagged <- total_INTLOG_domestic_lagged %>%
select(!c(sum_nkill,sum_nkillter,sum_nwound,sum_nwoundte)) %>%
filter(year %in% c(2000:2018))
write.csv(total_INTLOG_domestic_lagged,"Bases_CSV/total_INTLOG_domestic_lagged.csv", row.names = FALSE)
#total_INTLOG_international
INTLOG_international <- gtd_clean_Western_2000_2019 %>%
filter(INT_LOG_FACTOR=="International") %>%
group_by(new_id,
INT_LOG,INT_LOG_FACTOR) %>%
summarise(
total_attacks = n(),
sum_nkill=(sum(nkill,na.rm = T)),
sum_nkillter=(sum(nkillter,na.rm = T)),
sum_nwound=(sum(nwound,na.rm = T)),
sum_nwoundte=(sum(nwoundte,na.rm = T)))
total_INTLOG_international<- left_join(vdem_western_2000_2021, INTLOG_international, by="new_id")
total_INTLOG_international <- total_INTLOG_international %>%
mutate(total_attacks = coalesce(total_attacks, 0),
sum_nkill = coalesce(sum_nkill, 0),
sum_nkillter = coalesce(sum_nkillter,0),
sum_nwound = coalesce(sum_nwound,0),
sum_nwoundte = coalesce(sum_nwoundte,0))
total_INTLOG_international$INT_LOG=1
total_INTLOG_international$INT_LOG_FACTOR="International"
#Filter (2000-2019)
total_INTLOG_international <- total_INTLOG_international %>%
filter(year %in% c(2000:2019))
write.csv(total_INTLOG_international,"Bases_CSV/total_INTLOG_international.csv", row.names = FALSE)
#total_INTLOG_international
total_INTLOG_international_lagged<- total_INTLOG_international %>%
group_by(country_name) %>%
mutate(total_attacks=dplyr::lead(total_attacks,n=1, default = NA)) %>%
as.data.frame()
total_INTLOG_international_lagged <- total_INTLOG_international_lagged %>%
select(!c(sum_nkill,sum_nkillter,sum_nwound,sum_nwoundte)) %>%
filter(year %in% c(2000:2018))
write.csv(total_INTLOG_international_lagged,"Bases_CSV/total_INTLOG_international_lagged.csv", row.names = FALSE)
#total_INTLOG_unknown
INTLOG_unknown <- gtd_clean_Western_2000_2019 %>%
filter(INT_LOG_FACTOR=="Unknown") %>%
group_by(new_id,
INT_LOG,INT_LOG_FACTOR) %>%
summarise(
total_attacks = n(),
sum_nkill=(sum(nkill,na.rm = T)),
sum_nkillter=(sum(nkillter,na.rm = T)),
sum_nwound=(sum(nwound,na.rm = T)),
sum_nwoundte=(sum(nwoundte,na.rm = T)))
total_INTLOG_unknown<- left_join(vdem_western_2000_2021, INTLOG_unknown, by="new_id")
View(total_INTLOG_unknown)
total_INTLOG_unknown <- total_INTLOG_unknown %>%
mutate(total_attacks = coalesce(total_attacks, 0),
sum_nkill = coalesce(sum_nkill, 0),
sum_nkillter = coalesce(sum_nkillter,0),
sum_nwound = coalesce(sum_nwound,0),
sum_nwoundte = coalesce(sum_nwoundte,0))
total_INTLOG_unknown$INT_LOG=-9
total_INTLOG_unknown$INT_LOG_FACTOR="Unknown"
#Filter (2000-2019)
total_INTLOG_unknown <- total_INTLOG_unknown %>%
filter(year %in% c(2000:2019))
write.csv(total_INTLOG_unknown,"Bases_CSV/total_INTLOG_unknown.csv", row.names = FALSE)
#total_INTLOG_unknown_lagged
total_INTLOG_unknown_lagged<- total_INTLOG_unknown %>%
group_by(country_name) %>%
mutate(total_attacks=dplyr::lead(total_attacks,n=1, default = NA)) %>%
as.data.frame()
total_INTLOG_unknown_lagged <- total_INTLOG_unknown_lagged %>%
select(!c(sum_nkill,sum_nkillter,sum_nwound,sum_nwoundte)) %>%
filter(year %in% c(2000:2018))
write.csv(total_INTLOG_unknown_lagged,"Bases_CSV/total_INTLOG_unknown_lagged.csv", row.names = FALSE)
####
# total_no_INTLOG (Sum of all attacks each year)
no_INTLOG <- gtd_clean_Western_2000_2019 %>%
group_by(new_id) %>%
summarise(
total_attacks = n(),
sum_nkill=(sum(nkill,na.rm = T)),
sum_nkillter=(sum(nkillter,na.rm = T)),
sum_nwound=(sum(nwound,na.rm = T)),
sum_nwoundte=(sum(nwoundte,na.rm = T)))
total_no_INTLOG<- left_join(vdem_western_2000_2021, no_INTLOG, by="new_id")
total_no_INTLOG <- total_no_INTLOG %>%
mutate(total_attacks = coalesce(total_attacks, 0),
sum_nkill = coalesce(sum_nkill, 0),
sum_nkillter = coalesce(sum_nkillter,0),
sum_nwound = coalesce(sum_nwound,0),
sum_nwoundte = coalesce(sum_nwoundte,0))
#Filter (2000-2019)
total_no_INTLOG <- total_no_INTLOG %>%
filter(year %in% c(2000:2019))
write.csv(total_no_INTLOG,"Bases_CSV/total_no_INTLOG.csv", row.names = FALSE)
#total_no_INTLOG_lagged
total_no_INTLOG_lagged<- total_no_INTLOG %>%
group_by(country_name) %>%
mutate(total_attacks=dplyr::lead(total_attacks,n=1, default = NA)) %>%
as.data.frame()
total_no_INTLOG_lagged <- total_no_INTLOG_lagged %>%
select(!c(sum_nkill,sum_nkillter,sum_nwound,sum_nwoundte)) %>%
filter(year %in% c(2000:2018))
write.csv(total_no_INTLOG_lagged,"Bases_CSV/total_no_INTLOG_lagged.csv", row.names = FALSE)
###
#total_INTLOG (Domestic / International / Unknown on the same dataset)
total_INTLOG<- rbind (total_INTLOG_domestic,
total_INTLOG_international,
total_INTLOG_unknown)
write.csv(total_INTLOG,"Bases_CSV/total_INTLOG.csv", row.names = FALSE)
#total_INTLOG_lagged (Domestic / International / Unknown on the same dataset)
total_INTLOG_lagged<- rbind (total_INTLOG_domestic_lagged,
total_INTLOG_international_lagged,
total_INTLOG_unknown_lagged)
write.csv(total_INTLOG_lagged,"Bases_CSV/total_INTLOG_lagged.csv", row.names = FALSE)
Graficas NAS (midlle check)
# Graficas NAS (midlle check) ---------------------------------------------------
#NAS total_no_INTLOG_lagged
total_no_INTLOG_lagged %>%
summarise_all(list(~is.na(.)))%>%
pivot_longer(everything(),
names_to = "Variables", values_to="Missing") %>%
count(Variables, Missing) %>%
ggplot(aes(y=Variables,x=n,fill=Missing))+
geom_col()+
scale_fill_brewer(palette = "Dark2")+
labs(title="NAs in dataset by variable",
subtitle = "Data set: total_no_INTLOG ")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),#Tamaños de letra
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#NAS total_INTLOG_lagged
total_INTLOG_lagged %>%
summarise_all(list(~is.na(.)))%>%
pivot_longer(everything(),
names_to = "Variables", values_to="Missing") %>%
count(Variables, Missing) %>%
ggplot(aes(y=Variables,x=n,fill=Missing))+
geom_col()+
scale_fill_brewer(palette = "Dark2")+
labs(title="NAs in dataset by variable",
subtitle = "Data set: total_INTLOG_lagged ")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),#Tamaños de letra
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

Summary statistics Tables first check
# Summary statistics Tables first check ----------------------------------------------------------
#Summary statistics
#Domestic
stargazer(as.data.frame(total_INTLOG_domestic_lagged),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG domestic lagged)",
out="./Summary_Tables/First_check/Summary_Statistics_total_INTLOG_domestic_lagged.html")
##
## Summary Statistics (dataset: total INTLOG domestic lagged)
## =======================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## -------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## v2x_freexp_altinf 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## v2x_freexp 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## v2mecenefm 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## v2mecenefm_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## v2meharjrn 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## v2meharjrn_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## v2meslfcen 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## v2meslfcen_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## v2cldiscm 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## v2cldiscm_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## v2cldiscw 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## v2cldiscw_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## v2clacfree 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## v2clacfree_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## v2xme_altinf 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## v2mebias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## v2mebias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## v2mecrit 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## v2mecrit_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## v2merange 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## v2merange_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## v2smlawpr 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## v2smlawpr_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## v2smonper 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## v2smonper_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## v2smonex 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## v2smonex_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## v2smorgviol 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## v2smorgviol_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## v2smgovdom 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## v2smgovdom_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## v2smpardom 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## v2smpardom_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## v2xcl_disc 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## v2x_clphy 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## v2xlg_legcon 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## v2smpolsoc 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## v2smpolsoc_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## e_peaveduc 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## e_pop 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## v2x_cspart 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## e_gdp 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## INT_LOG 399 0.000 0.000 0 0 0 0 0
## total_attacks 399 2.278 6.719 0 0 0 1 58
## -------------------------------------------------------------------------------------------------------
#International
stargazer(as.data.frame(total_INTLOG_international_lagged),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG international lagged)",
out="./Summary_Tables/First_check/Summary_Statistics_total_INTLOG_international_lagged.html")
##
## Summary Statistics (dataset: total INTLOG international lagged)
## =======================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## -------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## v2x_freexp_altinf 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## v2x_freexp 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## v2mecenefm 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## v2mecenefm_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## v2meharjrn 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## v2meharjrn_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## v2meslfcen 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## v2meslfcen_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## v2cldiscm 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## v2cldiscm_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## v2cldiscw 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## v2cldiscw_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## v2clacfree 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## v2clacfree_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## v2xme_altinf 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## v2mebias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## v2mebias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## v2mecrit 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## v2mecrit_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## v2merange 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## v2merange_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## v2smlawpr 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## v2smlawpr_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## v2smonper 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## v2smonper_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## v2smonex 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## v2smonex_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## v2smorgviol 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## v2smorgviol_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## v2smgovdom 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## v2smgovdom_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## v2smpardom 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## v2smpardom_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## v2xcl_disc 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## v2x_clphy 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## v2xlg_legcon 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## v2smpolsoc 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## v2smpolsoc_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## e_peaveduc 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## e_pop 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## v2x_cspart 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## e_gdp 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## INT_LOG 399 1.000 0.000 1 1 1 1 1
## total_attacks 399 0.451 1.705 0 0 0 0 19
## -------------------------------------------------------------------------------------------------------
#Unknown
stargazer(as.data.frame(total_INTLOG_unknown_lagged),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG unknown lagged)",
out="./Summary_Tables/First_check/Summary_Statistics_total_INTLOG_unknown_lagged.html")
##
## Summary Statistics (dataset: total INTLOG unknown lagged)
## =======================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## -------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## v2x_freexp_altinf 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## v2x_freexp 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## v2mecenefm 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## v2mecenefm_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## v2meharjrn 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## v2meharjrn_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## v2meslfcen 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## v2meslfcen_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## v2cldiscm 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## v2cldiscm_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## v2cldiscw 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## v2cldiscw_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## v2clacfree 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## v2clacfree_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## v2xme_altinf 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## v2mebias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## v2mebias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## v2mecrit 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## v2mecrit_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## v2merange 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## v2merange_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## v2smlawpr 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## v2smlawpr_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## v2smonper 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## v2smonper_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## v2smonex 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## v2smonex_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## v2smorgviol 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## v2smorgviol_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## v2smgovdom 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## v2smgovdom_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## v2smpardom 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## v2smpardom_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## v2xcl_disc 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## v2x_clphy 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## v2xlg_legcon 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## v2smpolsoc 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## v2smpolsoc_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## e_peaveduc 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## e_pop 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## v2x_cspart 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## e_gdp 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## INT_LOG 399 -9.000 0.000 -9 -9 -9 -9 -9
## total_attacks 399 5.972 13.760 0 0 1 5 86
## -------------------------------------------------------------------------------------------------------
#Total no INTLOG (all)
stargazer(as.data.frame(total_no_INTLOG_lagged),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total no INTLOG lagged /All )",
out="./Summary_Tables/First_check/Summary_Statistics_total_no_INTLOG_lagged.html")
##
## Summary Statistics (dataset: total no INTLOG lagged /All )
## =======================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## -------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## v2x_freexp_altinf 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## v2x_freexp 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## v2mecenefm 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## v2mecenefm_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## v2meharjrn 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## v2meharjrn_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## v2meslfcen 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## v2meslfcen_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## v2cldiscm 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## v2cldiscm_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## v2cldiscw 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## v2cldiscw_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## v2clacfree 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## v2clacfree_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## v2xme_altinf 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## v2mebias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## v2mebias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## v2mecrit 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## v2mecrit_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## v2merange 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## v2merange_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## v2smlawpr 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## v2smlawpr_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## v2smonper 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## v2smonper_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## v2smonex 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## v2smonex_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## v2smorgviol 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## v2smorgviol_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## v2smgovdom 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## v2smgovdom_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## v2smpardom 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## v2smpardom_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## v2xcl_disc 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## v2x_clphy 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## v2xlg_legcon 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## v2smpolsoc 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## v2smpolsoc_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## e_peaveduc 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## e_pop 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## v2x_cspart 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## e_gdp 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## total_attacks 399 8.702 19.410 0 0 1 6 136
## -------------------------------------------------------------------------------------------------------
#Total INTLOG
stargazer(as.data.frame(total_INTLOG_lagged),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG lagged)",
out="./Summary_Tables/First_check/Summary_Statistics_total_INTLOG_lagged.html")
##
## Summary Statistics (dataset: total INTLOG lagged)
## =========================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## ---------------------------------------------------------------------------------------------------------
## country_id 1,197 100.714 58.137 5 67 91 158 186
## year 1,197 2,009.000 5.480 2,000 2,004 2,009 2,014 2,018
## v2x_freexp_altinf 1,197 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## v2x_freexp 1,197 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## v2mecenefm 1,197 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## v2mecenefm_osp 1,197 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## v2meharjrn 1,197 -2.705 0.598 -4.078 -3.054 -2.632 -2.252 -1.535
## v2meharjrn_osp 1,197 0.652 0.292 0.107 0.444 0.659 0.875 1.319
## v2meslfcen 1,197 -2.303 0.536 -3.235 -2.739 -2.319 -1.902 -1.143
## v2meslfcen_osp 1,197 0.308 0.185 0.059 0.143 0.266 0.433 0.820
## v2cldiscm 1,197 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## v2cldiscm_osp 1,197 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## v2cldiscw 1,197 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## v2cldiscw_osp 1,197 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## v2clacfree 1,197 2.856 0.423 1.459 2.589 2.953 3.180 3.597
## v2clacfree_osp 1,197 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## v2xme_altinf 1,197 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## v2mebias 1,197 -2.240 0.455 -3.005 -2.637 -2.252 -1.998 -1.017
## v2mebias_osp 1,197 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## v2mecrit 1,197 2.662 0.385 1.182 2.519 2.695 2.845 3.337
## v2mecrit_osp 1,197 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## v2merange 1,197 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## v2merange_osp 1,197 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## v2smlawpr 1,197 1.145 0.670 -0.119 0.659 1.154 1.579 2.417
## v2smlawpr_osp 1,197 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## v2smonper 1,197 1.449 0.485 0.658 1.033 1.451 1.700 2.548
## v2smonper_osp 1,197 3.457 0.230 3.024 3.255 3.487 3.605 3.881
## v2smonex 1,197 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## v2smonex_osp 1,197 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## v2smorgviol 1,197 -0.233 0.861 -2.419 -0.738 0.038 0.457 1.008
## v2smorgviol_osp 1,197 0.658 0.298 0.034 0.444 0.755 0.908 1.095
## v2smgovdom 1,197 -1.966 0.665 -2.922 -2.669 -2.080 -1.425 -0.028
## v2smgovdom_osp 1,197 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## v2smpardom 1,197 -1.534 0.806 -3.068 -2.001 -1.514 -1.247 0.656
## v2smpardom_osp 1,197 0.838 0.485 0.145 0.540 0.802 0.961 2.340
## v2xcl_disc 1,197 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## v2x_clphy 1,197 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## v2xlg_legcon 1,197 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## v2smpolsoc 1,197 -0.866 1.120 -2.831 -1.809 -0.803 0.041 2.125
## v2smpolsoc_osp 1,197 1.920 0.842 0.594 1.162 1.897 2.630 3.880
## e_peaveduc 1,197 11.769 1.299 7.340 11.290 11.902 12.710 13.610
## e_pop 1,197 3,885.907 6,969.696 29.995 557.566 1,104.035 5,015.820 34,862.720
## v2x_cspart 1,197 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## e_gdp 1,197 173,601.000 371,712.900 1,185.426 24,763.680 43,713.620 174,052.500 2,077,898.000
## INT_LOG 1,197 -2.667 4.499 -9 -9 0 1 1
## total_attacks 1,197 2.901 9.181 0 0 0 1 86
## ---------------------------------------------------------------------------------------------------------
Distribution Dependet Variable
# Distribution Dependet Variable ------------------------------------------
#Divided by type of attack
total_INTLOG %>%
ggplot(aes(x=total_attacks))+
geom_histogram(bins = 50)+
theme_classic()+
labs(title="Terrorist attacks",
subtitle= "Western countries (2000-2019)",
x="Anual number of attacks per country",
y = "Count",
fill="Type")+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~INT_LOG_FACTOR)

#Export
hist_total_INTLOG_facet_wrap<- total_INTLOG %>%
ggplot(aes(x=total_attacks))+
geom_histogram(bins = 50)+
theme_classic()+
labs(title="Terrorist attacks",
subtitle= "Western countries (2000-2019)",
x="Anual number of attacks per country",
y = "Count",
fill="Type")+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_wrap(~INT_LOG_FACTOR)
ggsave(plot = hist_total_INTLOG_facet_wrap,
filename = "./Graficas_Definitivas/Dependent_variable/hist_total_INTLOG_Domestic_International_Unknown.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Total number of attacks
total_INTLOG %>%
ggplot(aes(x=total_attacks))+
geom_histogram(bins=50)+
theme_classic()+
labs(title="Terrorist attacks",
subtitle= "Western countries (2000-2019)",
x="Anual number of attacks per country",
y = "Count",
fill="Type")+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
hist_total_INTLOG <- total_INTLOG %>%
ggplot(aes(x=total_attacks))+
geom_histogram(bins=50)+
theme_classic()+
labs(title="Terrorist attacks",
subtitle= "Western countries (2000-2019)",
x="Anual number of attacks per country",
y = "Count",
fill="Type")+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = hist_total_INTLOG,
filename = "./Graficas_Definitivas/Dependent_variable/hist_total_INTLOG.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
Scatterplots dependent vs independent
Domestic/International/Unknown
# Scatterplots dependent vs independent Domestic/International/Unknown -----------------------------------
#Freedom of Expression and Alternative Sources of information index
#total_attacks / v2x_freexp_altinf
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression & Alternative Sources",
subtitle= "Western countries 2000-2019",
x=" Freedom of Expression & Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2x_freexp_altinf <- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression & Alternative Sources",
subtitle= "Western countries 2000-2019",
x=" Freedom of Expression & Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Freedom of Expression index
#total_attacks (LOGSCALE) / v2x_freexp
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression",
subtitle= "Western countries 2000-2019",
x=" Freedom of Expression index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2x_freexp<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression",
subtitle= "Western countries 2000-2019",
x=" Freedom of Expression index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2x_freexp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Alternative Sources of information index
#total_attacks (LOGSCALE) / v2xme_altinf
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xme_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Alternative sources",
subtitle= "Western countries 2000-2019",
x="Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2xme_altinf<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xme_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Alternative sources",
subtitle= "Western countries 2000-2019",
x="Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2xme_altinf,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Defamation protection
#total_attacks (LOGSCALE) / v2smlawpr
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smlawpr_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Defamation protection",
subtitle= "Western countries 2000-2019",
x="Defamation protection ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2smlawpr_osp<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smlawpr_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Defamation protection",
subtitle= "Western countries 2000-2019",
x="Defamation protection ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Online media perspectives
#total_attacks (LOGSCALE) / v2smonper
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonper_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media perspectives ",
subtitle= "Western countries 2000-2019",
x="Online media perspectives ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2smonper_osp<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonper_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media perspectives ",
subtitle= "Western countries 2000-2019",
x="Online media perspectives ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2smonper_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Online media existence
#total_attacks (LOGSCALE) / v2smonex
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonex_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media existence",
subtitle= "Western countries 2000-2019",
x="Online media existence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2smonex_osp<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonex_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media existence",
subtitle= "Western countries 2000-2019",
x="Online media existence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2smonex_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
# Use of social media to organize offline violence
#total_attacks (LOGSCALE) / v2smorgviol
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smorgviol_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs social media to organize offline violence",
subtitle= "Western countries 2000-2019",
x="Use of social media to organize offline violence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2smorgviol_osp<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smorgviol_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs social media to organize offline violence",
subtitle= "Western countries 2000-2019",
x="Use of social media to organize offline violence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Government dissemination of false information domestic
#total_attacks (LOGSCALE) / v2smgovdom
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smgovdom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Government false information",
subtitle= "Western countries 2000-2019",
x="Government dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2smgovdom_osp<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smgovdom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Government false information",
subtitle= "Western countries 2000-2019",
x="Government dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Party dissemination of false information domestic
#total_attacks (LOGSCALE) / v2smpardom
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpardom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Party false information",
subtitle= "Western countries 2000-2019",
x="Party dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2smpardom_osp<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpardom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Party false information",
subtitle= "Western countries 2000-2019",
x="Party dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2smpardom_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Freedom of discussion
#total_attacks (LOGSCALE) / v2xcl_disc
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xcl_disc))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of discussion",
subtitle= "Western countries 2000-2019",
x="Freedom of discussion",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2xcl_disc<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xcl_disc))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of discussion",
subtitle= "Western countries 2000-2019",
x="Freedom of discussion",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2xcl_disc,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Physical violence index
#total_attacks (LOGSCALE) / v2x_clphy
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_clphy))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Physical violence index",
subtitle= "Western countries 2000-2019",
x="Physical violence index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2x_clphy<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_clphy))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Physical violence index",
subtitle= "Western countries 2000-2019",
x="Physical violence index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2x_clphy,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Legislative constraints on the executive index
#total_attacks (LOGSCALE) / v2xlg_legcon
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xlg_legcon))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Constraints on the executive",
subtitle= "Western countries 2000-2019",
x="Legislative constraints on the executive index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2xlg_legcon<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xlg_legcon))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Constraints on the executive",
subtitle= "Western countries 2000-2019",
x="Legislative constraints on the executive index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2xlg_legcon,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Polarization of society
#total_attacks (LOGSCALE) / v2smpolsoc
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpolsoc_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Polarization of society",
subtitle= "Western countries 2000-2019",
x="Polarization of society ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2smpolsoc_osp <- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpolsoc_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Polarization of society",
subtitle= "Western countries 2000-2019",
x="Polarization of society ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Civil society participation index
#total_attacks (LOGSCALE) / v2x_cspart
total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_cspart))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Civil society participation",
subtitle= "Western countries 2000-2019",
x="Civil society participation index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))

#Export
scatter_v2x_cspart<- total_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_cspart))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Civil society participation",
subtitle= "Western countries 2000-2019",
x="Civil society participation index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))+
facet_grid(rows = vars(INT_LOG_FACTOR))
ggsave(plot = scatter_v2x_cspart,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/scatter_v2x_cspart.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
Scatterplots dependent vs independent All attacks
# Scatterplots dependent vs independent All attacks -----------------------------------
#Freedom of Expression and Alternative Sources of information index
#total_attacks / v2x_freexp_altinf
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression & Alternative Sources",
subtitle= "Western countries 2000-2019 (all attacks)",
x=" Freedom of Expression & Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2x_freexp_altinf <- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression & Alternative Sources",
subtitle= "Western countries 2000-2019 (all attacks)",
x=" Freedom of Expression & Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2x_freexp_altinf,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2x_freexp_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Freedom of Expression index
#total_attacks (LOGSCALE) / v2x_freexp
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression",
subtitle= "Western countries 2000-2019 (all attacks)",
x=" Freedom of Expression index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2x_freexp<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_freexp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of Expression",
subtitle= "Western countries 2000-2019 (all attacks)",
x=" Freedom of Expression index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2x_freexp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2x_freexp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Alternative Sources of information index
#total_attacks (LOGSCALE) / v2xme_altinf
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xme_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Alternative sources",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2xme_altinf<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xme_altinf))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Alternative sources",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Alternative Sources of information index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2xme_altinf,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2xme_altinf.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Defamation protection
#total_attacks (LOGSCALE) / v2smlawpr
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smlawpr_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Defamation protection",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Defamation protection ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2smlawpr_osp<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smlawpr_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Defamation protection",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Defamation protection ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2smlawpr_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2smlawpr_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Online media perspectives
#total_attacks (LOGSCALE) / v2smonper
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonper_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media perspectives ",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Online media perspectives ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2smonper_osp<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonper_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media perspectives ",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Online media perspectives ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2smonper_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2smonper_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Online media existence
#total_attacks (LOGSCALE) / v2smonex
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonex_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media existence",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Online media existence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2smonex_osp<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smonex_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Online media existence",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Online media existence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2smonex_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2smonex_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
# Use of social media to organize offline violence
#total_attacks (LOGSCALE) / v2smorgviol
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smorgviol_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs social media to organize offline violence",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Use of social media to organize offline violence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2smorgviol_osp<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smorgviol_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs social media to organize offline violence",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Use of social media to organize offline violence",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2smorgviol_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2smorgviol_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Government dissemination of false information domestic
#total_attacks (LOGSCALE) / v2smgovdom
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smgovdom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Government false information",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Government dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2smgovdom_osp<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smgovdom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Government false information",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Government dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2smgovdom_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2smgovdom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Party dissemination of false information domestic
#total_attacks (LOGSCALE) / v2smpardom
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpardom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Party false information",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Party dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2smpardom_osp<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpardom_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Party false information",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Party dissemination of false information domestic",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2smpardom_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2smpardom_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Freedom of discussion
#total_attacks (LOGSCALE) / v2xcl_disc
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xcl_disc))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of discussion",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Freedom of discussion",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2xcl_disc<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xcl_disc))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Freedom of discussion",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Freedom of discussion",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2xcl_disc,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2xcl_disc.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Physical violence index
#total_attacks (LOGSCALE) / v2x_clphy
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_clphy))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Physical violence index",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Physical violence index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2x_clphy<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_clphy))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Physical violence index",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Physical violence index",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2x_clphy,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2x_clphy.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Legislative constraints on the executive index
#total_attacks (LOGSCALE) / v2xlg_legcon
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xlg_legcon))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Constraints on the executive",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Legislative constraints on the executive index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2xlg_legcon<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2xlg_legcon))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Constraints on the executive",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Legislative constraints on the executive index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2xlg_legcon,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2xlg_legcon.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Polarization of society
#total_attacks (LOGSCALE) / v2smpolsoc
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpolsoc_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Polarization of society",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Polarization of society ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2smpolsoc_osp <- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2smpolsoc_osp))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Polarization of society",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Polarization of society ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2smpolsoc_osp,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2smpolsoc_osp.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#Civil society participation index
#total_attacks (LOGSCALE) / v2x_cspart
total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_cspart))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Civil society participation",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Civil society participation index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))

#Export
scatter_v2x_cspart<- total_no_INTLOG %>%
ggplot(aes(y=log(total_attacks),x=v2x_cspart))+
geom_point()+
geom_smooth(method=lm, color="darkred", fill="#36EEE0")+
labs(title="Terrorist activity vs Civil society participation",
subtitle= "Western countries 2000-2019 (all attacks)",
x="Civil society participation index ",
y = "Log Annual number of terrorist attacks",
fill="Type")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
ggsave(plot = scatter_v2x_cspart,
filename = "./Graficas_Definitivas/Scatter_Dependent_vs_Independent/All_attacks/scatter_v2x_cspart.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
Data frames for Regression_lagged
# Data frames for Regression_lagged --------------------------------------------------------------
##Freedom of press
#v2x_freexp_altinf / Freedom of expression and alternative sources of information index
#v2x_freexp / Freedom of expression index
#v2mecenefm/ Government censorship effort Media
#v2meharjrn/ Harassment of journalists
#v2meslfcen/ Media self-censorship
#v2cldiscm/ Freedom of discussion for men
#v2cldiscw/ Freedom of discussion for women
#v2clacfree/ Freedom of academic and cultural expression
#v2xme_altinf / Alternative Sources of information index
#v2mebias/ Media bias
#v2mecrit/ Print/broadcast media critical
#v2merange/ Print/broadcast media perspectives
##Online information flow
#v2smlawpr / Defamation protection
#v2smonper / Online media perspectives
#v2smonex / Online media existence
#v2smorgviol / Use of social media to organize offline violence
#v2smgovdom / Government dissemination of false information domestic
#v2smpardom / Party dissemination of false information domestic
#Independent variables suggested by previous studies
#v2xcl_disc / Freedom of discussion
#v2x_clphy / Physical violence index
#v2xlg_legcon / Legislative constraints on the executive index
#v2smpolsoc / Polarization of society
#Control Variables
#e_peaveduc / Average years of education citizens 15+
#e_gdp / GDP
#e_pop / Population
#v2x_cspart / Civil society participation index
#Renaming data sets for regression (for lagged regressions)
# total_no_INTLOG_renamed
#Modifying indexes X10
total_no_INTLOG_multiplied <- total_no_INTLOG_lagged
total_no_INTLOG_multiplied$v2x_freexp_altinf_x10 <- total_no_INTLOG_multiplied$v2x_freexp_altinf*10
total_no_INTLOG_multiplied$v2x_freexp_x10 <- total_no_INTLOG_multiplied$v2x_freexp*10
total_no_INTLOG_multiplied$v2xme_altinf_x10 <- total_no_INTLOG_multiplied$v2xme_altinf*10
total_no_INTLOG_multiplied$v2xcl_disc_x10 <- total_no_INTLOG_multiplied$v2xcl_disc*10
total_no_INTLOG_multiplied$v2x_clphy_x10 <- total_no_INTLOG_multiplied$v2x_clphy*10
total_no_INTLOG_multiplied$v2xlg_legcon_x10 <- total_no_INTLOG_multiplied$v2xlg_legcon*10
total_no_INTLOG_multiplied$v2x_cspart_x10 <- total_no_INTLOG_multiplied$v2x_cspart*10
#Dividing population by 100 so that each unit represents 1 million
total_no_INTLOG_multiplied$e_pop_div_100<- total_no_INTLOG_multiplied$e_pop/100
View(total_no_INTLOG_multiplied)
#Renamed
total_no_INTLOG_renamed<- total_no_INTLOG_multiplied %>%
rename(Freedom_exp_alternative_sourc_index=v2x_freexp_altinf,
Freedom_exp_alternative_sourc_index_x10=v2x_freexp_altinf_x10,
Freedom_expression_index = v2x_freexp,
Freedom_expression_index_x10 = v2x_freexp_x10,
Government_censorship_Media= v2mecenefm,
Government_censorship_Media_osp= v2mecenefm_osp,
Harassment_journalists= v2meharjrn,
Harassment_journalists_osp= v2meharjrn_osp,
Media_self_censorship= v2meslfcen,
Media_self_censorship_osp= v2meslfcen_osp,
Freedom_discussion_men = v2cldiscm,
Freedom_discussion_men_osp = v2cldiscm_osp,
Freedom_discussion_women= v2cldiscw,
Freedom_discussion_women_osp= v2cldiscw_osp,
Freedom_academic_cultural_expression=v2clacfree,
Freedom_academic_cultural_expression_osp=v2clacfree_osp,
Alternative_Sources_index= v2xme_altinf,
Alternative_Sources_index_x10= v2xme_altinf_x10,
Media_bias= v2mebias,
Media_bias_osp= v2mebias_osp,
Media_critical=v2mecrit,
Media_critical_osp=v2mecrit_osp,
Media_perspectives=v2merange,
Media_perspectives_osp=v2merange_osp,
Defamation_protection = v2smlawpr,
Defamation_protection_osp = v2smlawpr_osp,
Online_media_perspectives = v2smonper,
Online_media_perspectives_osp = v2smonper_osp,
Online_media_existence = v2smonex,
Online_media_existence_osp = v2smonex_osp,
Social_media_organize_violence= v2smorgviol,
Social_media_organize_violence_osp = v2smorgviol_osp,
Government_false_information = v2smgovdom,
Government_false_information_osp = v2smgovdom_osp,
Party_false_information = v2smpardom,
Party_false_information_osp = v2smpardom_osp,
Freedom_discussion = v2xcl_disc,
Freedom_discussion_x10 = v2xcl_disc_x10,
Physical_violence_index = v2x_clphy,
Physical_violence_index_x10 = v2x_clphy_x10,
Constraints_executive_index = v2xlg_legcon,
Constraints_executive_index_x10 = v2xlg_legcon_x10,
Polarization_society = v2smpolsoc,
Polarization_society_osp = v2smpolsoc_osp,
Civil_society_participation_index = v2x_cspart,
Civil_society_participation_index_x10 = v2x_cspart_x10,
Average_years_education_citizens = e_peaveduc,
Gross_domestic_product = e_gdp,
Population = e_pop,
Population_millions=e_pop_div_100)
##Mean versions of some variables
# Freedom_expression_mean_media_censorship
total_no_INTLOG_renamed<- total_no_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(Freedom_expression_mean_media_censorship=sum(Government_censorship_Media+Harassment_journalists+Media_self_censorship)/3) %>%
ungroup()
# Freedom_expression_mean_discussion
total_no_INTLOG_renamed<- total_no_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(Freedom_expression_mean_discussion=sum(Freedom_discussion_men+Freedom_discussion_women+Freedom_academic_cultural_expression)/3) %>%
ungroup()
# Alternative_sources_mean
#(Media bias is saved in an inverted format, and that inverted version goes to the regressions.
#However, the mean aggregation will be performed with the non inverted version of the variable, because it
#makes more sense. In order to return the variable to the original scale it has to be multiplied again by -1)
total_no_INTLOG_renamed<- total_no_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(Alternative_sources_mean=sum(Media_bias*-1+Media_critical+Media_perspectives)/3) %>%
ungroup()
# False_information_mean
total_no_INTLOG_renamed<- total_no_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(False_information_mean=sum(Government_false_information+Party_false_information)/2) %>%
ungroup()
write.csv(total_no_INTLOG_renamed,"Bases_CSV/total_no_INTLOG_renamed_lagged.csv", row.names = FALSE)
### total_INTLOG_renamed
#Modifying indexes X10
total_INTLOG_multiplied <- total_INTLOG_lagged
total_INTLOG_multiplied$v2x_freexp_altinf_x10 <- total_INTLOG_multiplied$v2x_freexp_altinf*10
total_INTLOG_multiplied$v2x_freexp_x10 <- total_INTLOG_multiplied$v2x_freexp*10
total_INTLOG_multiplied$v2xme_altinf_x10 <- total_INTLOG_multiplied$v2xme_altinf*10
total_INTLOG_multiplied$v2xcl_disc_x10 <- total_INTLOG_multiplied$v2xcl_disc*10
total_INTLOG_multiplied$v2x_clphy_x10 <- total_INTLOG_multiplied$v2x_clphy*10
total_INTLOG_multiplied$v2xlg_legcon_x10 <- total_INTLOG_multiplied$v2xlg_legcon*10
total_INTLOG_multiplied$v2x_cspart_x10 <- total_INTLOG_multiplied$v2x_cspart*10
#Dividing population by 100 so that each unit represents 1 million
total_INTLOG_multiplied$e_pop_div_100<- total_INTLOG_multiplied$e_pop/100
#Renamed
total_INTLOG_renamed<- total_INTLOG_multiplied %>%
rename(Freedom_exp_alternative_sourc_index=v2x_freexp_altinf,
Freedom_exp_alternative_sourc_index_x10=v2x_freexp_altinf_x10,
Freedom_expression_index = v2x_freexp,
Freedom_expression_index_x10 = v2x_freexp_x10,
Government_censorship_Media= v2mecenefm,
Government_censorship_Media_osp= v2mecenefm_osp,
Harassment_journalists= v2meharjrn,
Harassment_journalists_osp= v2meharjrn_osp,
Media_self_censorship= v2meslfcen,
Media_self_censorship_osp= v2meslfcen_osp,
Freedom_discussion_men = v2cldiscm,
Freedom_discussion_men_osp = v2cldiscm_osp,
Freedom_discussion_women= v2cldiscw,
Freedom_discussion_women_osp= v2cldiscw_osp,
Freedom_academic_cultural_expression=v2clacfree,
Freedom_academic_cultural_expression_osp=v2clacfree_osp,
Alternative_Sources_index= v2xme_altinf,
Alternative_Sources_index_x10= v2xme_altinf_x10,
Media_bias= v2mebias,
Media_bias_osp= v2mebias_osp,
Media_critical=v2mecrit,
Media_critical_osp=v2mecrit_osp,
Media_perspectives=v2merange,
Media_perspectives_osp=v2merange_osp,
Defamation_protection = v2smlawpr,
Defamation_protection_osp = v2smlawpr_osp,
Online_media_perspectives = v2smonper,
Online_media_perspectives_osp = v2smonper_osp,
Online_media_existence = v2smonex,
Online_media_existence_osp = v2smonex_osp,
Social_media_organize_violence= v2smorgviol,
Social_media_organize_violence_osp = v2smorgviol_osp,
Government_false_information = v2smgovdom,
Government_false_information_osp = v2smgovdom_osp,
Party_false_information = v2smpardom,
Party_false_information_osp = v2smpardom_osp,
Freedom_discussion = v2xcl_disc,
Freedom_discussion_x10 = v2xcl_disc_x10,
Physical_violence_index = v2x_clphy,
Physical_violence_index_x10 = v2x_clphy_x10,
Constraints_executive_index = v2xlg_legcon,
Constraints_executive_index_x10 = v2xlg_legcon_x10,
Polarization_society = v2smpolsoc,
Polarization_society_osp = v2smpolsoc_osp,
Civil_society_participation_index = v2x_cspart,
Civil_society_participation_index_x10 = v2x_cspart_x10,
Average_years_education_citizens = e_peaveduc,
Gross_domestic_product = e_gdp,
Population = e_pop,
Population_millions =e_pop_div_100)
##Mean versions of some variables
# Freedom_expression_mean_media_censorship
total_INTLOG_renamed<- total_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(Freedom_expression_mean_media_censorship=(Government_censorship_Media+Harassment_journalists+Media_self_censorship)/3) %>%
ungroup()
# Freedom_expression_mean_discussion
total_INTLOG_renamed<- total_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(Freedom_expression_mean_discussion=(Freedom_discussion_men+Freedom_discussion_women+Freedom_academic_cultural_expression)/3) %>%
ungroup()
# Alternative_sources_mean
#(Media bias is saved in an inverted format, and that inverted version goes to the regressions.
#However, the mean aggregation will be performed with the non inverted version of the variable, because it
#makes more sense. In order to return the variable to the original scale it has to be multiplied again by -1)
total_INTLOG_renamed<- total_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(Alternative_sources_mean=(Media_bias*-1+Media_critical+Media_perspectives)/3) %>%
ungroup()
View(total_INTLOG_renamed)
# False_information_mean
total_INTLOG_renamed<- total_INTLOG_renamed %>%
group_by(new_id) %>%
mutate(False_information_mean=(Government_false_information+Party_false_information)/2) %>%
ungroup()
write.csv(total_INTLOG_renamed,"Bases_CSV/total_INTLOG_renamed_lagged.csv", row.names = FALSE)
#Subsets
total_INTLOG_unknown_renamed <- total_INTLOG_renamed %>%
filter(INT_LOG==-9)
write.csv(total_INTLOG,"Bases_CSV/total_INTLOG_unknown_renamed_lagged.csv", row.names = FALSE)
total_INTLOG_domestic_renamed <- total_INTLOG_renamed %>%
filter(INT_LOG==0)
write.csv(total_INTLOG,"Bases_CSV/total_INTLOG_domestic_renamed_lagged.csv", row.names = FALSE)
total_INTLOG_international_renamed <- total_INTLOG_renamed %>%
filter(INT_LOG==1)
write.csv(total_INTLOG_international,"Bases_CSV/total_INTLOG_international_renamed_lagged.csv", row.names = FALSE)
##Cheking that all data sets are correct (the sum of domestic/ international and unknown should match the values of the "no intlog data set")
total_INTLOG_domestic_renamed[total_INTLOG_domestic_renamed$new_id == "USA_2018", "total_attacks"]+
total_INTLOG_international_renamed[total_INTLOG_international_renamed$new_id == "USA_2018", "total_attacks"]+
total_INTLOG_unknown_renamed[total_INTLOG_unknown_renamed$new_id == "USA_2018", "total_attacks"]
total_no_INTLOG_renamed[total_no_INTLOG_renamed$new_id == "USA_2018", "total_attacks"]
sum(total_INTLOG_domestic_renamed[, "total_attacks"])+
sum(total_INTLOG_international_renamed[, "total_attacks"])+
sum(total_INTLOG_unknown_renamed[, "total_attacks"])
## [1] 3472
sum(total_no_INTLOG_renamed[, "total_attacks"])
## [1] 3472
View(total_no_INTLOG_renamed)
NAs graph final check
# NAs graph final check ---------------------------------------------------
#NAS total_no_INTLOG_renamed
NA_gaph_total_no_INTLOG_renamed <- total_no_INTLOG_renamed %>%
summarise_all(list(~is.na(.)))%>%
pivot_longer(everything(),
names_to = "Variables", values_to="Missing") %>%
count(Variables, Missing) %>%
ggplot(aes(y=Variables,x=n,fill=Missing))+
geom_col()+
scale_fill_brewer(palette = "Dark2")+
labs(title="NAs in dataset by variable",
subtitle = "Dataset: total_no_INTLOG_renamed ")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),#Tamaños de letra
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
#Export
ggsave(plot = NA_gaph_total_no_INTLOG_renamed, filename = "./Graficas_Definitivas/NA_graphs/NA_gaph_total_no_INTLOG_renamed.png",
width = 11,
height =11,
type = "cairo",
dpi = "retina")
#View for Markdown
NA_gaph_total_no_INTLOG_renamed

#NAS total_INTLOG_renamed
NA_graph_total_INTLOG_renamed<- total_INTLOG_renamed %>%
summarise_all(list(~is.na(.)))%>%
pivot_longer(everything(),
names_to = "Variables", values_to="Missing") %>%
count(Variables, Missing) %>%
ggplot(aes(y=Variables,x=n,fill=Missing))+
geom_col()+
scale_fill_brewer(palette = "Dark2")+
labs(title="NAs in dataset by variable",
subtitle = "Dataset: total_INTLOG_renamed ")+
theme_classic()+
theme(axis.text.x = element_text( size = 13),#Tamaños de letra
axis.title.y = element_text( size = 15),
axis.title.x = element_text( size = 15),
plot.title = element_text(size = 20,face = "bold"),
plot.subtitle = element_text(size = 15),
legend.title = element_text(size = 15),
legend.text = element_text(size = 13))
#Export
ggsave(plot = NA_graph_total_INTLOG_renamed, filename = "./Graficas_Definitivas/NA_graphs/NA_graph_total_INTLOG_renamed.png",
width = 11,
height =11,
type = "cairo",
dpi = "retina")
#View for Markdown
NA_graph_total_INTLOG_renamed

Summary statistics tables (final check)
#Summary statistics tables (final check) ---------------------------------
#Summary statistics
#Domestic
stargazer(as.data.frame(total_INTLOG_domestic_renamed),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG domestic renamed)",
out="./Summary_Tables/Final_check/Summary_Statistics_total_INTLOG_domestic_renamed.html")
##
## Summary Statistics (dataset: total INTLOG domestic renamed)
## ==============================================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## ------------------------------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## Freedom_exp_alternative_sourc_index 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## Freedom_expression_index 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## Government_censorship_Media 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## Government_censorship_Media_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## Harassment_journalists 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## Harassment_journalists_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## Media_self_censorship 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## Media_self_censorship_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## Freedom_discussion_men 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## Freedom_discussion_men_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## Freedom_discussion_women 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## Freedom_discussion_women_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## Freedom_academic_cultural_expression 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## Freedom_academic_cultural_expression_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## Alternative_Sources_index 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## Media_bias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## Media_bias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## Media_critical 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## Media_critical_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## Media_perspectives 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## Media_perspectives_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## Defamation_protection 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## Defamation_protection_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## Online_media_perspectives 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## Online_media_perspectives_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## Online_media_existence 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## Online_media_existence_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## Social_media_organize_violence 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## Social_media_organize_violence_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## Government_false_information 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## Government_false_information_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## Party_false_information 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## Party_false_information_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## Freedom_discussion 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## Physical_violence_index 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## Constraints_executive_index 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## Polarization_society 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## Polarization_society_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## Average_years_education_citizens 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## Population 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## Civil_society_participation_index 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## Gross_domestic_product 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## INT_LOG 399 0.000 0.000 0 0 0 0 0
## total_attacks 399 2.278 6.719 0 0 0 1 58
## Freedom_exp_alternative_sourc_index_x10 399 9.646 0.167 8.980 9.590 9.680 9.760 9.890
## Freedom_expression_index_x10 399 9.718 0.132 9.200 9.640 9.740 9.810 9.920
## Alternative_Sources_index_x10 399 9.346 0.308 8.270 9.310 9.420 9.530 9.770
## Freedom_discussion_x10 399 9.666 0.159 8.930 9.600 9.690 9.780 9.930
## Physical_violence_index_x10 399 9.710 0.221 8.340 9.640 9.780 9.870 9.900
## Constraints_executive_index_x10 399 9.254 0.488 7.740 8.980 9.320 9.710 9.860
## Civil_society_participation_index_x10 399 9.380 0.413 8.500 9.090 9.530 9.700 9.900
## Population_millions 399 38.859 69.755 0.300 5.593 11.040 50.154 348.627
## Freedom_expression_mean_media_censorship 399 -2.614 0.434 -3.365 -2.911 -2.634 -2.278 -1.641
## Freedom_expression_mean_discussion 399 2.736 0.259 1.895 2.567 2.734 2.847 3.446
## Alternative_sources_mean 399 2.371 0.314 1.502 2.271 2.397 2.561 2.968
## False_information_mean 399 -1.750 0.649 -2.869 -2.341 -1.719 -1.358 -0.237
## ------------------------------------------------------------------------------------------------------------------------------
#International
stargazer(as.data.frame(total_INTLOG_international_renamed),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG international renamed)",
out="./Summary_Tables/Final_check/Summary_Statistics_total_INTLOG_international_renamed.html")
##
## Summary Statistics (dataset: total INTLOG international renamed)
## ==============================================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## ------------------------------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## Freedom_exp_alternative_sourc_index 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## Freedom_expression_index 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## Government_censorship_Media 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## Government_censorship_Media_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## Harassment_journalists 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## Harassment_journalists_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## Media_self_censorship 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## Media_self_censorship_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## Freedom_discussion_men 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## Freedom_discussion_men_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## Freedom_discussion_women 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## Freedom_discussion_women_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## Freedom_academic_cultural_expression 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## Freedom_academic_cultural_expression_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## Alternative_Sources_index 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## Media_bias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## Media_bias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## Media_critical 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## Media_critical_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## Media_perspectives 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## Media_perspectives_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## Defamation_protection 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## Defamation_protection_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## Online_media_perspectives 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## Online_media_perspectives_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## Online_media_existence 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## Online_media_existence_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## Social_media_organize_violence 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## Social_media_organize_violence_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## Government_false_information 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## Government_false_information_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## Party_false_information 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## Party_false_information_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## Freedom_discussion 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## Physical_violence_index 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## Constraints_executive_index 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## Polarization_society 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## Polarization_society_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## Average_years_education_citizens 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## Population 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## Civil_society_participation_index 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## Gross_domestic_product 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## INT_LOG 399 1.000 0.000 1 1 1 1 1
## total_attacks 399 0.451 1.705 0 0 0 0 19
## Freedom_exp_alternative_sourc_index_x10 399 9.646 0.167 8.980 9.590 9.680 9.760 9.890
## Freedom_expression_index_x10 399 9.718 0.132 9.200 9.640 9.740 9.810 9.920
## Alternative_Sources_index_x10 399 9.346 0.308 8.270 9.310 9.420 9.530 9.770
## Freedom_discussion_x10 399 9.666 0.159 8.930 9.600 9.690 9.780 9.930
## Physical_violence_index_x10 399 9.710 0.221 8.340 9.640 9.780 9.870 9.900
## Constraints_executive_index_x10 399 9.254 0.488 7.740 8.980 9.320 9.710 9.860
## Civil_society_participation_index_x10 399 9.380 0.413 8.500 9.090 9.530 9.700 9.900
## Population_millions 399 38.859 69.755 0.300 5.593 11.040 50.154 348.627
## Freedom_expression_mean_media_censorship 399 -2.614 0.434 -3.365 -2.911 -2.634 -2.278 -1.641
## Freedom_expression_mean_discussion 399 2.736 0.259 1.895 2.567 2.734 2.847 3.446
## Alternative_sources_mean 399 2.371 0.314 1.502 2.271 2.397 2.561 2.968
## False_information_mean 399 -1.750 0.649 -2.869 -2.341 -1.719 -1.358 -0.237
## ------------------------------------------------------------------------------------------------------------------------------
#Unknown
stargazer(as.data.frame(total_INTLOG_unknown_renamed),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG unknown renamed)",
out="./Summary_Tables/Final_check/Summary_Statistics_total_INTLOG_unknown_renamed.html")
##
## Summary Statistics (dataset: total INTLOG unknown renamed)
## ==============================================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## ------------------------------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## Freedom_exp_alternative_sourc_index 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## Freedom_expression_index 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## Government_censorship_Media 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## Government_censorship_Media_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## Harassment_journalists 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## Harassment_journalists_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## Media_self_censorship 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## Media_self_censorship_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## Freedom_discussion_men 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## Freedom_discussion_men_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## Freedom_discussion_women 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## Freedom_discussion_women_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## Freedom_academic_cultural_expression 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## Freedom_academic_cultural_expression_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## Alternative_Sources_index 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## Media_bias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## Media_bias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## Media_critical 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## Media_critical_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## Media_perspectives 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## Media_perspectives_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## Defamation_protection 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## Defamation_protection_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## Online_media_perspectives 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## Online_media_perspectives_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## Online_media_existence 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## Online_media_existence_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## Social_media_organize_violence 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## Social_media_organize_violence_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## Government_false_information 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## Government_false_information_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## Party_false_information 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## Party_false_information_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## Freedom_discussion 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## Physical_violence_index 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## Constraints_executive_index 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## Polarization_society 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## Polarization_society_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## Average_years_education_citizens 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## Population 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## Civil_society_participation_index 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## Gross_domestic_product 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## INT_LOG 399 -9.000 0.000 -9 -9 -9 -9 -9
## total_attacks 399 5.972 13.760 0 0 1 5 86
## Freedom_exp_alternative_sourc_index_x10 399 9.646 0.167 8.980 9.590 9.680 9.760 9.890
## Freedom_expression_index_x10 399 9.718 0.132 9.200 9.640 9.740 9.810 9.920
## Alternative_Sources_index_x10 399 9.346 0.308 8.270 9.310 9.420 9.530 9.770
## Freedom_discussion_x10 399 9.666 0.159 8.930 9.600 9.690 9.780 9.930
## Physical_violence_index_x10 399 9.710 0.221 8.340 9.640 9.780 9.870 9.900
## Constraints_executive_index_x10 399 9.254 0.488 7.740 8.980 9.320 9.710 9.860
## Civil_society_participation_index_x10 399 9.380 0.413 8.500 9.090 9.530 9.700 9.900
## Population_millions 399 38.859 69.755 0.300 5.593 11.040 50.154 348.627
## Freedom_expression_mean_media_censorship 399 -2.614 0.434 -3.365 -2.911 -2.634 -2.278 -1.641
## Freedom_expression_mean_discussion 399 2.736 0.259 1.895 2.567 2.734 2.847 3.446
## Alternative_sources_mean 399 2.371 0.314 1.502 2.271 2.397 2.561 2.968
## False_information_mean 399 -1.750 0.649 -2.869 -2.341 -1.719 -1.358 -0.237
## ------------------------------------------------------------------------------------------------------------------------------
#Total no INTLOG (all)
stargazer(as.data.frame(total_no_INTLOG_renamed),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total no INTLOG renamed /All )",
out="./Summary_Tables/Final_check/Summary_Statistics_total_no_INTLOG_renamed.html")
##
## Summary Statistics (dataset: total no INTLOG renamed /All )
## ==============================================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## ------------------------------------------------------------------------------------------------------------------------------
## country_id 399 100.714 58.185 5 67 91 158 186
## year 399 2,009.000 5.484 2,000 2,004 2,009 2,014 2,018
## Freedom_exp_alternative_sourc_index 399 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## Freedom_expression_index 399 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## Government_censorship_Media 399 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## Government_censorship_Media_osp 399 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## Harassment_journalists 399 -2.705 0.599 -4.078 -3.054 -2.632 -2.252 -1.535
## Harassment_journalists_osp 399 0.652 0.293 0.107 0.444 0.659 0.875 1.319
## Media_self_censorship 399 -2.303 0.536 -3.235 -2.696 -2.319 -1.902 -1.143
## Media_self_censorship_osp 399 0.308 0.185 0.059 0.154 0.266 0.433 0.820
## Freedom_discussion_men 399 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## Freedom_discussion_men_osp 399 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## Freedom_discussion_women 399 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## Freedom_discussion_women_osp 399 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## Freedom_academic_cultural_expression 399 2.856 0.424 1.459 2.589 2.953 3.173 3.597
## Freedom_academic_cultural_expression_osp 399 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## Alternative_Sources_index 399 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## Media_bias 399 -2.240 0.456 -3.005 -2.637 -2.252 -1.998 -1.017
## Media_bias_osp 399 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## Media_critical 399 2.662 0.386 1.182 2.519 2.695 2.845 3.337
## Media_critical_osp 399 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## Media_perspectives 399 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## Media_perspectives_osp 399 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## Defamation_protection 399 1.145 0.671 -0.119 0.659 1.154 1.579 2.417
## Defamation_protection_osp 399 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## Online_media_perspectives 399 1.449 0.486 0.658 1.033 1.451 1.700 2.548
## Online_media_perspectives_osp 399 3.457 0.231 3.024 3.255 3.487 3.605 3.881
## Online_media_existence 399 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## Online_media_existence_osp 399 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## Social_media_organize_violence 399 -0.233 0.862 -2.419 -0.738 0.038 0.457 1.008
## Social_media_organize_violence_osp 399 0.658 0.299 0.034 0.444 0.755 0.908 1.095
## Government_false_information 399 -1.966 0.666 -2.922 -2.669 -2.080 -1.425 -0.028
## Government_false_information_osp 399 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## Party_false_information 399 -1.534 0.807 -3.068 -2.001 -1.514 -1.247 0.656
## Party_false_information_osp 399 0.838 0.486 0.145 0.540 0.802 0.961 2.340
## Freedom_discussion 399 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## Physical_violence_index 399 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## Constraints_executive_index 399 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## Polarization_society 399 -0.866 1.121 -2.831 -1.809 -0.803 0.037 2.125
## Polarization_society_osp 399 1.920 0.843 0.594 1.162 1.897 2.625 3.880
## Average_years_education_citizens 399 11.769 1.300 7.340 11.290 11.902 12.710 13.610
## Population 399 3,885.907 6,975.530 29.995 559.296 1,104.035 5,015.366 34,862.720
## Civil_society_participation_index 399 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## Gross_domestic_product 399 173,601.000 372,024.100 1,185.426 24,871.490 43,713.620 172,924.200 2,077,898.000
## total_attacks 399 8.702 19.410 0 0 1 6 136
## Freedom_exp_alternative_sourc_index_x10 399 9.646 0.167 8.980 9.590 9.680 9.760 9.890
## Freedom_expression_index_x10 399 9.718 0.132 9.200 9.640 9.740 9.810 9.920
## Alternative_Sources_index_x10 399 9.346 0.308 8.270 9.310 9.420 9.530 9.770
## Freedom_discussion_x10 399 9.666 0.159 8.930 9.600 9.690 9.780 9.930
## Physical_violence_index_x10 399 9.710 0.221 8.340 9.640 9.780 9.870 9.900
## Constraints_executive_index_x10 399 9.254 0.488 7.740 8.980 9.320 9.710 9.860
## Civil_society_participation_index_x10 399 9.380 0.413 8.500 9.090 9.530 9.700 9.900
## Population_millions 399 38.859 69.755 0.300 5.593 11.040 50.154 348.627
## Freedom_expression_mean_media_censorship 399 -2.614 0.434 -3.365 -2.911 -2.634 -2.278 -1.641
## Freedom_expression_mean_discussion 399 2.736 0.259 1.895 2.567 2.734 2.847 3.446
## Alternative_sources_mean 399 2.371 0.314 1.502 2.271 2.397 2.561 2.968
## False_information_mean 399 -1.750 0.649 -2.869 -2.341 -1.719 -1.358 -0.237
## ------------------------------------------------------------------------------------------------------------------------------
#Total INTLOG
stargazer(as.data.frame(total_INTLOG_renamed),
type = "text",
median = TRUE,
title = "Summary Statistics (dataset: total INTLOG renamed)",
out="./Summary_Tables/Final_check/Summary_Statistics_total_INTLOG_renamed.html")
##
## Summary Statistics (dataset: total INTLOG renamed)
## ================================================================================================================================
## Statistic N Mean St. Dev. Min Pctl(25) Median Pctl(75) Max
## --------------------------------------------------------------------------------------------------------------------------------
## country_id 1,197 100.714 58.137 5 67 91 158 186
## year 1,197 2,009.000 5.480 2,000 2,004 2,009 2,014 2,018
## Freedom_exp_alternative_sourc_index 1,197 0.965 0.017 0.898 0.959 0.968 0.976 0.989
## Freedom_expression_index 1,197 0.972 0.013 0.920 0.964 0.974 0.981 0.992
## Government_censorship_Media 1,197 -2.833 0.462 -3.516 -3.218 -2.800 -2.599 -1.542
## Government_censorship_Media_osp 1,197 0.225 0.157 0.057 0.102 0.202 0.270 0.834
## Harassment_journalists 1,197 -2.705 0.598 -4.078 -3.054 -2.632 -2.252 -1.535
## Harassment_journalists_osp 1,197 0.652 0.292 0.107 0.444 0.659 0.875 1.319
## Media_self_censorship 1,197 -2.303 0.536 -3.235 -2.739 -2.319 -1.902 -1.143
## Media_self_censorship_osp 1,197 0.308 0.185 0.059 0.143 0.266 0.433 0.820
## Freedom_discussion_men 1,197 2.685 0.356 1.639 2.474 2.673 2.921 3.576
## Freedom_discussion_men_osp 1,197 3.853 0.090 3.450 3.817 3.869 3.917 3.980
## Freedom_discussion_women 1,197 2.667 0.353 1.925 2.442 2.644 2.909 3.452
## Freedom_discussion_women_osp 1,197 3.852 0.084 3.612 3.811 3.864 3.917 3.974
## Freedom_academic_cultural_expression 1,197 2.856 0.423 1.459 2.589 2.953 3.180 3.597
## Freedom_academic_cultural_expression_osp 1,197 3.770 0.146 3.093 3.705 3.823 3.877 3.945
## Alternative_Sources_index 1,197 0.935 0.031 0.827 0.931 0.942 0.953 0.977
## Media_bias 1,197 -2.240 0.455 -3.005 -2.637 -2.252 -1.998 -1.017
## Media_bias_osp 1,197 0.327 0.194 0.085 0.164 0.288 0.399 1.014
## Media_critical 1,197 2.662 0.385 1.182 2.519 2.695 2.845 3.337
## Media_critical_osp 1,197 2.863 0.106 2.313 2.849 2.887 2.915 2.969
## Media_perspectives 1,197 2.212 0.422 0.865 1.962 2.319 2.530 2.854
## Media_perspectives_osp 1,197 2.820 0.133 2.232 2.774 2.870 2.911 2.954
## Defamation_protection 1,197 1.145 0.670 -0.119 0.659 1.154 1.579 2.417
## Defamation_protection_osp 1,197 3.130 0.467 2.119 2.809 3.202 3.478 3.836
## Online_media_perspectives 1,197 1.449 0.485 0.658 1.033 1.451 1.700 2.548
## Online_media_perspectives_osp 1,197 3.457 0.230 3.024 3.255 3.487 3.605 3.881
## Online_media_existence 1,197 1.349 0.733 -0.670 0.914 1.197 1.834 2.800
## Online_media_existence_osp 1,197 2.612 0.259 1.693 2.482 2.605 2.823 2.972
## Social_media_organize_violence 1,197 -0.233 0.861 -2.419 -0.738 0.038 0.457 1.008
## Social_media_organize_violence_osp 1,197 0.658 0.298 0.034 0.444 0.755 0.908 1.095
## Government_false_information 1,197 -1.966 0.665 -2.922 -2.669 -2.080 -1.425 -0.028
## Government_false_information_osp 1,197 0.325 0.260 0.053 0.087 0.225 0.498 1.404
## Party_false_information 1,197 -1.534 0.806 -3.068 -2.001 -1.514 -1.247 0.656
## Party_false_information_osp 1,197 0.838 0.485 0.145 0.540 0.802 0.961 2.340
## Freedom_discussion 1,197 0.967 0.016 0.893 0.960 0.969 0.978 0.993
## Physical_violence_index 1,197 0.971 0.022 0.834 0.964 0.978 0.987 0.990
## Constraints_executive_index 1,197 0.925 0.049 0.774 0.898 0.932 0.971 0.986
## Polarization_society 1,197 -0.866 1.120 -2.831 -1.809 -0.803 0.041 2.125
## Polarization_society_osp 1,197 1.920 0.842 0.594 1.162 1.897 2.630 3.880
## Average_years_education_citizens 1,197 11.769 1.299 7.340 11.290 11.902 12.710 13.610
## Population 1,197 3,885.907 6,969.696 29.995 557.566 1,104.035 5,015.820 34,862.720
## Civil_society_participation_index 1,197 0.938 0.041 0.850 0.909 0.953 0.970 0.990
## Gross_domestic_product 1,197 173,601.000 371,712.900 1,185.426 24,763.680 43,713.620 174,052.500 2,077,898.000
## INT_LOG 1,197 -2.667 4.499 -9 -9 0 1 1
## total_attacks 1,197 2.901 9.181 0 0 0 1 86
## Freedom_exp_alternative_sourc_index_x10 1,197 9.646 0.167 8.980 9.590 9.680 9.760 9.890
## Freedom_expression_index_x10 1,197 9.718 0.132 9.200 9.640 9.740 9.810 9.920
## Alternative_Sources_index_x10 1,197 9.346 0.308 8.270 9.310 9.420 9.530 9.770
## Freedom_discussion_x10 1,197 9.666 0.159 8.930 9.600 9.690 9.780 9.930
## Physical_violence_index_x10 1,197 9.710 0.221 8.340 9.640 9.780 9.870 9.900
## Constraints_executive_index_x10 1,197 9.254 0.488 7.740 8.980 9.320 9.710 9.860
## Civil_society_participation_index_x10 1,197 9.380 0.413 8.500 9.090 9.530 9.700 9.900
## Population_millions 1,197 38.859 69.697 0.300 5.576 11.040 50.158 348.627
## Freedom_expression_mean_media_censorship 1,197 -2.614 0.434 -3.365 -2.911 -2.634 -2.278 -1.641
## Freedom_expression_mean_discussion 1,197 2.736 0.259 1.895 2.567 2.734 2.848 3.446
## Alternative_sources_mean 1,197 2.371 0.314 1.502 2.269 2.397 2.561 2.968
## False_information_mean 1,197 -1.750 0.648 -2.869 -2.341 -1.719 -1.358 -0.237
## --------------------------------------------------------------------------------------------------------------------------------
Corplots
# Corplots ----------------------------------------------------------------
##All_attacks
##Corplot independet variables
forcorplot_independent_all <- total_no_INTLOG_renamed %>%
select(total_attacks,
Freedom_expression_index_x10,
Alternative_Sources_index_x10,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information)
png("./Correlation_Plots/All_attacks/independet_variables.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_independent_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (all attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_independent_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (all attacks)", side=3, line=3)

##Corplot independet variables broken down
forcorplot_independent_brokendown_all <- total_no_INTLOG_renamed %>%
select(total_attacks,
Harassment_journalists,
Media_self_censorship,
Media_bias,
Media_critical,
Media_perspectives,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information)
png("./Correlation_Plots/All_attacks/independet_variables_brokendown.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_independent_brokendown_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (broken down / all attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_independent_brokendown_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (broken down / all attacks)", side=3, line=3)

##Full_model
forcorplot_full_model_all <- total_no_INTLOG_renamed %>%
select(total_attacks,
Freedom_expression_index_x10,
Alternative_Sources_index_x10,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information,
Freedom_discussion_x10,
Physical_violence_index_x10,
Constraints_executive_index_x10,
Polarization_society,
Civil_society_participation_index_x10,
Average_years_education_citizens,
Population_millions)
png("./Correlation_Plots/All_attacks/forcorplot_full_model_all.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_full_model_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (all attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_full_model_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (all attacks)", side=3, line=3)

##Full_model_brokendown
forcorplot_full_model_brokendown_all <- total_no_INTLOG_renamed %>%
select(total_attacks,
Harassment_journalists,
Media_self_censorship,
Media_bias,
Media_critical,
Media_perspectives,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information,
Freedom_discussion_x10,
Physical_violence_index_x10,
Constraints_executive_index_x10,
Polarization_society,
Civil_society_participation_index_x10,
Average_years_education_citizens,
Population_millions)
png("./Correlation_Plots/All_attacks/full_model_brokendown_all.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_full_model_brokendown_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (broken down / all attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_full_model_brokendown_all, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (broken down / all attacks)", side=3, line=3)

##Domestic
##Corplot independet variables
forcorplot_independent_domestic <- total_INTLOG_domestic_renamed %>%
select(total_attacks,
Freedom_expression_index_x10,
Alternative_Sources_index_x10,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information)
png("./Correlation_Plots/Domestic_attacks/independet_variables.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_independent_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (domestic attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_independent_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (domestic attacks)", side=3, line=3)

##Corplot independet variables broken down
forcorplot_independent_brokendown_domestic <- total_INTLOG_domestic_renamed %>%
select(total_attacks,
Harassment_journalists,
Media_self_censorship,
Media_bias,
Media_critical,
Media_perspectives,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information)
png("./Correlation_Plots/Domestic_attacks/independent_brokendown_domestic.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_independent_brokendown_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (broken down / domestic attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_independent_brokendown_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: independent varaibles (broken down / domestic attacks)", side=3, line=3)

##Full_model
forcorplot_full_model_domestic <- total_INTLOG_domestic_renamed %>%
select(total_attacks,
Freedom_expression_index_x10,
Alternative_Sources_index_x10,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information,
Freedom_discussion_x10,
Physical_violence_index_x10,
Constraints_executive_index_x10,
Polarization_society,
Civil_society_participation_index_x10,
Average_years_education_citizens,
Population_millions)
png("./Correlation_Plots/Domestic_attacks/full_model_domestic.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_full_model_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (domestic attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_full_model_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (domestic attacks)", side=3, line=3)

##Full_model_brokendown
forcorplot_full_model_brokendown_domestic <- total_INTLOG_domestic_renamed %>%
select(total_attacks,
Harassment_journalists,
Media_self_censorship,
Media_bias,
Media_critical,
Media_perspectives,
Defamation_protection,
Online_media_perspectives,
Online_media_existence,
Social_media_organize_violence,
Government_false_information,
Party_false_information,
Freedom_discussion_x10,
Physical_violence_index_x10,
Constraints_executive_index_x10,
Polarization_society,
Civil_society_participation_index_x10,
Average_years_education_citizens,
Population_millions)
png("./Correlation_Plots/Domestic_attacks/full_model_brokendown_domestic.png",
width = 6000, height = 3000,type = "cairo",res=300)
chart.Correlation(forcorplot_full_model_brokendown_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (broken down / domestic attacks)", side=3, line=3)
dev.off()
## png
## 2
#View for markdown:
chart.Correlation(forcorplot_full_model_brokendown_domestic, histogram=TRUE, pch=19,
method = "pearson")
mtext("Correlation plot: Full model (broken down / domestic attacks)", side=3, line=3)

Regression_lagged: Full model by type of attack
# Regression_lagged: Full model by type of attack -----------------
#m1 Full model / all attacks
m1_full_all_attacks<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 50))
# TBL export: m1 Full model / all attacks / expo
m1_full_all_attacks%>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1_full_all_attacks_expo.png")
# TBL merge: m1 Full model / all / expo
m1_full_all_attacks_merge_expo <- m1_full_all_attacks%>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1 Full model / all attacks / log
m1_full_all_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1_full_all_attacks_log.png")
# TBL merge: m1 Full model / all / log
m1_full_all_attacks_merge_log <- m1_full_all_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1 Full model / Domestic
m1_full_domestic_attacks<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m1 Full model / domestic / expo
m1_full_domestic_attacks %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m1_full_domestic_attacks_expo.png")
# TBL merge: m1 Full model / domestic / expo
m1_full_domestic_attacks_merge_expo<- m1_full_domestic_attacks %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1 Full model / domestic / log
m1_full_domestic_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m1_full_domestic_attacks_log.png")
# TBL merge: m1 Full model / domestic / log
m1_full_domestic_attacks_merge_log <- m1_full_domestic_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1 Full model / International
m1_full_international_attacks<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_international_renamed,
control = glm.control(maxit = 50))
# TBL export: m1 Full model / international / exp
m1_full_international_attacks %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_International attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/International/m1_full_international_attacks_expo.png")
# TBL merge: m1 Full model / international / expo
m1_full_international_attacks_merge_expo <- m1_full_international_attacks %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1 Full model / international / log
m1_full_international_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_International attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/International/m1_full_international_attacks_log.png")
# TBL merge: m1 Full model / international / log
m1_full_international_attacks_merge_log <- m1_full_international_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1 Full model / Unknown
m1_full_unknown_attacks<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_unknown_renamed,
control = glm.control(maxit = 50))
# TBL export: m1 Full model / unknown / exp
m1_full_unknown_attacks %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Unknown attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Unknown/m1_full_unknown_attacks_expo.png")
# TBL merge: m1 Full model / unknown / expo
m1_full_unknown_attacks_merge_expo <- m1_full_unknown_attacks %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1 Full model / unknown / log
m1_full_unknown_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Unknown attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Unknown/m1_full_unknown_attacks_log.png")
# TBL merge: m1 Full model / unknown / log
m1_full_unknown_attacks_merge_log<- m1_full_unknown_attacks %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1 Full Model:
#PNG
tbl_merge(list(m1_full_domestic_attacks_merge_expo,
m1_full_all_attacks_merge_expo,
m1_full_international_attacks_merge_expo,
m1_full_unknown_attacks_merge_expo),
tab_spanner = c("**Domestic attacks**","**All attacks**","**International attacks**","**Unknown attacks**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Full Model: (2000-2019/lagged)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_full.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1_full_domestic_attacks_merge_expo,
m1_full_all_attacks_merge_expo,
m1_full_international_attacks_merge_expo,
m1_full_unknown_attacks_merge_expo),
tab_spanner = c("**Domestic attacks**","**All attacks**","**International attacks**","**Unknown attacks**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Full Model: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_full.html")
#Por si toca exportarlo por flextable
# as_flex_table() %>%
# flextable::save_as_image(path = "Regression_Tables/combined/combined_m1_full.png", webshot="webshot")
#View for markdown:
tbl_merge(list(m1_full_domestic_attacks_merge_expo,
m1_full_all_attacks_merge_expo,
m1_full_international_attacks_merge_expo,
m1_full_unknown_attacks_merge_expo),
tab_spanner = c("**Domestic attacks**","**All attacks**","**International attacks**","**Unknown attacks**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Full Model: (2000-2019/lagged)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Domestic attacks
|
All attacks
|
International attacks
|
Unknown attacks
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Freedom_expression_index_x10 |
0.00*** |
1.84 |
0.00, 0.01 |
<0.001 |
0.01*** |
1.08 |
0.00, 0.11 |
<0.001 |
0.01** |
1.98 |
0.00, 0.23 |
0.008 |
0.02** |
1.15 |
0.00, 0.22 |
0.001 |
| Alternative_Sources_index_x10 |
17.8*** |
0.621 |
5.62, 57.9 |
<0.001 |
8.54*** |
0.373 |
4.48, 16.2 |
<0.001 |
17.5*** |
0.754 |
4.11, 81.1 |
<0.001 |
7.08*** |
0.402 |
3.54, 14.1 |
<0.001 |
| Defamation_protection |
0.81 |
0.305 |
0.42, 1.50 |
0.5 |
0.85 |
0.156 |
0.61, 1.18 |
0.3 |
0.89 |
0.348 |
0.43, 1.70 |
0.7 |
0.97 |
0.167 |
0.68, 1.38 |
0.9 |
| Online_media_perspectives |
0.21** |
0.522 |
0.08, 0.56 |
0.003 |
0.45** |
0.260 |
0.27, 0.77 |
0.002 |
0.36 |
0.645 |
0.10, 1.24 |
0.11 |
0.48** |
0.275 |
0.27, 0.84 |
0.008 |
| Online_media_existence |
0.57** |
0.212 |
0.36, 0.88 |
0.007 |
1.14 |
0.123 |
0.91, 1.45 |
0.3 |
0.86 |
0.252 |
0.52, 1.41 |
0.6 |
1.23 |
0.132 |
0.96, 1.58 |
0.12 |
| Social_media_organize_violence |
7.21*** |
0.334 |
3.61, 16.1 |
<0.001 |
2.92*** |
0.130 |
2.24, 3.84 |
<0.001 |
3.02** |
0.342 |
1.61, 6.35 |
0.001 |
2.58*** |
0.138 |
1.97, 3.43 |
<0.001 |
| Government_false_information |
2.41** |
0.340 |
1.07, 5.34 |
0.010 |
1.05 |
0.190 |
0.70, 1.57 |
0.8 |
0.76 |
0.349 |
0.36, 1.56 |
0.4 |
0.92 |
0.202 |
0.61, 1.40 |
0.7 |
| Party_false_information |
0.28*** |
0.301 |
0.15, 0.53 |
<0.001 |
0.45*** |
0.154 |
0.34, 0.61 |
<0.001 |
0.53 |
0.352 |
0.25, 1.02 |
0.073 |
0.49*** |
0.165 |
0.36, 0.67 |
<0.001 |
| Freedom_discussion_x10 |
2.20 |
0.990 |
0.31, 15.2 |
0.4 |
2.12 |
0.587 |
0.71, 6.11 |
0.2 |
0.97 |
0.982 |
0.16, 5.66 |
>0.9 |
1.72 |
0.624 |
0.54, 5.30 |
0.4 |
| Physical_violence_index_x10 |
0.76 |
0.635 |
0.15, 3.38 |
0.7 |
0.39* |
0.447 |
0.13, 1.09 |
0.036 |
0.47 |
0.784 |
0.10, 2.51 |
0.3 |
0.31* |
0.472 |
0.10, 0.94 |
0.014 |
| Constraints_executive_index_x10 |
0.26*** |
0.358 |
0.12, 0.54 |
<0.001 |
0.36*** |
0.197 |
0.24, 0.53 |
<0.001 |
0.62 |
0.487 |
0.23, 1.70 |
0.3 |
0.42*** |
0.212 |
0.28, 0.63 |
<0.001 |
| Polarization_society |
0.83 |
0.220 |
0.51, 1.34 |
0.4 |
1.41*** |
0.103 |
1.14, 1.76 |
<0.001 |
2.23*** |
0.198 |
1.53, 3.34 |
<0.001 |
1.47*** |
0.109 |
1.17, 1.85 |
<0.001 |
| Civil_society_participation_index_x10 |
0.61 |
0.408 |
0.19, 1.88 |
0.2 |
1.83* |
0.261 |
1.03, 3.23 |
0.021 |
5.19** |
0.522 |
1.86, 15.5 |
0.002 |
2.21** |
0.282 |
1.21, 4.03 |
0.005 |
| Average_years_education_citizens |
1.73** |
0.167 |
1.21, 2.59 |
0.001 |
1.48*** |
0.081 |
1.23, 1.78 |
<0.001 |
2.19*** |
0.213 |
1.44, 3.42 |
<0.001 |
1.53*** |
0.088 |
1.26, 1.85 |
<0.001 |
| Population_millions |
1.02*** |
0.004 |
1.01, 1.03 |
<0.001 |
1.01*** |
0.002 |
1.00, 1.01 |
<0.001 |
1.00 |
0.004 |
0.99, 1.00 |
0.5 |
1.01*** |
0.002 |
1.00, 1.01 |
<0.001 |
| AIC |
944 |
|
|
|
1,866 |
|
|
|
493 |
|
|
|
1,660 |
|
|
|
| BIC |
1,011 |
|
|
|
1,934 |
|
|
|
561 |
|
|
|
1,728 |
|
|
|
| Deviance |
226 |
|
|
|
409 |
|
|
|
198 |
|
|
|
389 |
|
|
|
| Null deviance |
639 |
|
|
|
977 |
|
|
|
438 |
|
|
|
862 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
Regression_lagged: Simplified versions_domestic
# Regression_lagged: Simplified versions_domestic ----------------------------------------------------
# m2 parsimonious model / domestic
m2_parsimonious_domestic<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m2 parsimonious model / domestic / expo
m2_parsimonious_domestic %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m2_parsimonious_domestic_expo.png")
# TBL merge: m2 parsimonious model / domestic / expo
m2_parsimonious_domestic_merge_expo <- m2_parsimonious_domestic %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m2 parsimonious model / domestic / log
m2_parsimonious_domestic %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m2_parsimonious_domestic_log.png")
# TBL merge: m2 parsimonious model / domestic / log
m2_parsimonious_domestic_merge_log <- m2_parsimonious_domestic %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m3 minimal model
m3_minimal_domestic<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 100))
# TBL export: m3 minimal model / domestic / expo
m3_minimal_domestic %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m3_minimal_domestic_expo.png")
# TBL merge: m3 minimal model / domestic / expo
m3_minimal_domestic_merge_expo <- m3_minimal_domestic %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m3 minimal model / domestic / log
m3_minimal_domestic %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m3_minimal_domestic_log.png")
# TBL merge: m3 minimal model / domestic / log
m3_minimal_domestic_merge_log <- m3_minimal_domestic %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1/m2/m3 / expo :
#PNG
tbl_merge(list(m1_full_domestic_attacks_merge_expo,
m2_parsimonious_domestic_merge_expo,
m3_minimal_domestic_merge_expo),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_m2_m3_domestic_expo.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1_full_domestic_attacks_merge_expo,
m2_parsimonious_domestic_merge_expo,
m3_minimal_domestic_merge_expo),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_m2_m3_domestic_expo.html")
#Combined m1/m2/m3 / log :
#PNG
tbl_merge(list(m1_full_domestic_attacks_merge_log,
m2_parsimonious_domestic_merge_log,
m3_minimal_domestic_merge_log),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_m2_m3_domestic_log.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1_full_domestic_attacks_merge_log,
m2_parsimonious_domestic_merge_log,
m3_minimal_domestic_merge_log),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_m2_m3_domestic_log.html")
#View for markdown:
tbl_merge(list(m1_full_domestic_attacks_merge_expo,
m2_parsimonious_domestic_merge_expo,
m3_minimal_domestic_merge_expo),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Full model
|
Parsimonious model
|
Minimal model
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Freedom_expression_index_x10 |
0.00*** |
1.84 |
0.00, 0.01 |
<0.001 |
0.00*** |
1.46 |
0.00, 0.02 |
<0.001 |
0.00*** |
1.49 |
0.00, 0.03 |
<0.001 |
| Alternative_Sources_index_x10 |
17.8*** |
0.621 |
5.62, 57.9 |
<0.001 |
11.2*** |
0.586 |
3.84, 33.2 |
<0.001 |
20.9*** |
0.640 |
6.51, 69.0 |
<0.001 |
| Defamation_protection |
0.81 |
0.305 |
0.42, 1.50 |
0.5 |
0.47** |
0.287 |
0.25, 0.87 |
0.009 |
1.41 |
0.252 |
0.80, 2.50 |
0.2 |
| Online_media_perspectives |
0.21** |
0.522 |
0.08, 0.56 |
0.003 |
0.28** |
0.452 |
0.11, 0.67 |
0.005 |
0.08*** |
0.373 |
0.04, 0.15 |
<0.001 |
| Online_media_existence |
0.57** |
0.212 |
0.36, 0.88 |
0.007 |
0.58** |
0.212 |
0.37, 0.90 |
0.009 |
1.01 |
0.210 |
0.65, 1.59 |
>0.9 |
| Social_media_organize_violence |
7.21*** |
0.334 |
3.61, 16.1 |
<0.001 |
5.79*** |
0.306 |
3.18, 11.5 |
<0.001 |
|
|
|
|
| Government_false_information |
2.41** |
0.340 |
1.07, 5.34 |
0.010 |
4.04*** |
0.299 |
2.08, 7.81 |
<0.001 |
|
|
|
|
| Party_false_information |
0.28*** |
0.301 |
0.15, 0.53 |
<0.001 |
0.25*** |
0.289 |
0.13, 0.47 |
<0.001 |
|
|
|
|
| Freedom_discussion_x10 |
2.20 |
0.990 |
0.31, 15.2 |
0.4 |
|
|
|
|
|
|
|
|
| Physical_violence_index_x10 |
0.76 |
0.635 |
0.15, 3.38 |
0.7 |
|
|
|
|
|
|
|
|
| Constraints_executive_index_x10 |
0.26*** |
0.358 |
0.12, 0.54 |
<0.001 |
|
|
|
|
|
|
|
|
| Polarization_society |
0.83 |
0.220 |
0.51, 1.34 |
0.4 |
|
|
|
|
|
|
|
|
| Civil_society_participation_index_x10 |
0.61 |
0.408 |
0.19, 1.88 |
0.2 |
|
|
|
|
|
|
|
|
| Average_years_education_citizens |
1.73** |
0.167 |
1.21, 2.59 |
0.001 |
1.07 |
0.119 |
0.84, 1.38 |
0.6 |
0.88 |
0.107 |
0.69, 1.12 |
0.2 |
| Population_millions |
1.02*** |
0.004 |
1.01, 1.03 |
<0.001 |
1.02*** |
0.003 |
1.01, 1.02 |
<0.001 |
1.04*** |
0.003 |
1.03, 1.05 |
<0.001 |
| AIC |
944 |
|
|
|
956 |
|
|
|
1,026 |
|
|
|
| BIC |
1,011 |
|
|
|
1,004 |
|
|
|
1,062 |
|
|
|
| Deviance |
226 |
|
|
|
234 |
|
|
|
238 |
|
|
|
| Null deviance |
639 |
|
|
|
596 |
|
|
|
430 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
Regression_lagged: Simplified versions_all
# Regression_lagged: Simplified versions_all ----------------------------------------------------
# m2 parsimonious model / all
m2_parsimonious_all<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 50))
# TBL export: m2 parsimonious model / all / expo
m2_parsimonious_all %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m2_parsimonious_all_expo.png")
# TBL merge: m2 parsimonious model / all / expo
m2_parsimonious_all_merge_expo <- m2_parsimonious_all %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m2 parsimonious model / all / log
m2_parsimonious_all %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m2_parsimonious_all_log.png")
# TBL merge: m2 parsimonious model / all / log
m2_parsimonious_all_merge_log <- m2_parsimonious_all %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m3 minimal model
m3_minimal_all<-glm.nb(total_attacks ~
Freedom_expression_index_x10 +
Alternative_Sources_index_x10 +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 100))
# TBL export: m3 minimal model / all / expo
m3_minimal_all %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m3_minimal_all_expo.png")
# TBL merge: m3 minimal model / all / expo
m3_minimal_all_merge_expo <- m3_minimal_all %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m3 minimal model / all / log
m3_minimal_all %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m3_minimal_all_log.png")
# TBL merge: m3 minimal model / all / log
m3_minimal_all_merge_log <- m3_minimal_all %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1/m2/m3 / all/ expo :
#PNG
tbl_merge(list(m1_full_all_attacks_merge_expo,
m2_parsimonious_all_merge_expo,
m3_minimal_all_merge_expo),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_m2_m3_domestic_expo.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1_full_all_attacks_merge_expo,
m2_parsimonious_all_merge_expo,
m3_minimal_all_merge_expo),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_m2_m3_domestic_expo.html")
#Combined m1/m2/m3 /all / log :
#PNG
tbl_merge(list(m1_full_all_attacks_merge_log,
m2_parsimonious_all_merge_log,
m3_minimal_all_merge_log),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_m2_m3_domestic_log.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1_full_all_attacks_merge_log,
m2_parsimonious_all_merge_log,
m3_minimal_all_merge_log),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_m2_m3_domestic_log.html")
#View for markdown:
tbl_merge(list(m1_full_all_attacks_merge_expo,
m2_parsimonious_all_merge_expo,
m3_minimal_all_merge_expo),
tab_spanner = c("**Full model**", "**Parsimonious model**","**Minimal model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Full model
|
Parsimonious model
|
Minimal model
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Freedom_expression_index_x10 |
0.01*** |
1.08 |
0.00, 0.11 |
<0.001 |
0.13* |
0.907 |
0.02, 0.77 |
0.024 |
0.15* |
0.893 |
0.02, 0.96 |
0.034 |
| Alternative_Sources_index_x10 |
8.54*** |
0.373 |
4.48, 16.2 |
<0.001 |
3.75*** |
0.360 |
1.98, 7.01 |
<0.001 |
7.10*** |
0.408 |
3.53, 14.1 |
<0.001 |
| Defamation_protection |
0.85 |
0.156 |
0.61, 1.18 |
0.3 |
0.62** |
0.157 |
0.44, 0.87 |
0.002 |
1.18 |
0.145 |
0.84, 1.66 |
0.2 |
| Online_media_perspectives |
0.45** |
0.260 |
0.27, 0.77 |
0.002 |
0.40*** |
0.242 |
0.24, 0.67 |
<0.001 |
0.16*** |
0.214 |
0.11, 0.25 |
<0.001 |
| Online_media_existence |
1.14 |
0.123 |
0.91, 1.45 |
0.3 |
1.21 |
0.123 |
0.95, 1.56 |
0.12 |
1.38* |
0.132 |
1.05, 1.82 |
0.015 |
| Social_media_organize_violence |
2.92*** |
0.130 |
2.24, 3.84 |
<0.001 |
3.33*** |
0.132 |
2.53, 4.45 |
<0.001 |
|
|
|
|
| Government_false_information |
1.05 |
0.190 |
0.70, 1.57 |
0.8 |
2.01*** |
0.172 |
1.39, 2.90 |
<0.001 |
|
|
|
|
| Party_false_information |
0.45*** |
0.154 |
0.34, 0.61 |
<0.001 |
0.41*** |
0.166 |
0.30, 0.55 |
<0.001 |
|
|
|
|
| Freedom_discussion_x10 |
2.12 |
0.587 |
0.71, 6.11 |
0.2 |
|
|
|
|
|
|
|
|
| Physical_violence_index_x10 |
0.39* |
0.447 |
0.13, 1.09 |
0.036 |
|
|
|
|
|
|
|
|
| Constraints_executive_index_x10 |
0.36*** |
0.197 |
0.24, 0.53 |
<0.001 |
|
|
|
|
|
|
|
|
| Polarization_society |
1.41*** |
0.103 |
1.14, 1.76 |
<0.001 |
|
|
|
|
|
|
|
|
| Civil_society_participation_index_x10 |
1.83* |
0.261 |
1.03, 3.23 |
0.021 |
|
|
|
|
|
|
|
|
| Average_years_education_citizens |
1.48*** |
0.081 |
1.23, 1.78 |
<0.001 |
1.15 |
0.070 |
0.97, 1.35 |
0.054 |
1.04 |
0.073 |
0.86, 1.24 |
0.6 |
| Population_millions |
1.01*** |
0.002 |
1.00, 1.01 |
<0.001 |
1.01*** |
0.002 |
1.01, 1.01 |
<0.001 |
1.02*** |
0.002 |
1.02, 1.03 |
<0.001 |
| AIC |
1,866 |
|
|
|
1,893 |
|
|
|
1,987 |
|
|
|
| BIC |
1,934 |
|
|
|
1,941 |
|
|
|
2,023 |
|
|
|
| Deviance |
409 |
|
|
|
407 |
|
|
|
401 |
|
|
|
| Null deviance |
977 |
|
|
|
867 |
|
|
|
636 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
Regression_lagged: Versions of full model_domestic
# Regression_lagged: Versions of full model_domestic --------------------------------------
###vERSIONS OF FULL MODEL
# m1.1_full_domestic_free_exp_alt
m1.1_full_domestic_free_exp_alt<-glm.nb(total_attacks ~
Freedom_exp_alternative_sourc_index_x10+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 150))
# TBL export: m1.1 Full model / domestic / exp
m1.1_full_domestic_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.1 :Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/Versions_Fullmodel/m1.1_full_domestic_free_exp_alt_expo.png")
# TBL merge: m1.1 Full model / domestic / exp
m1.1_full_domestic_free_exp_alt_merge_expo <- m1.1_full_domestic_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.1 Full model / domestic / log
m1.1_full_domestic_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.1 :Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/Versions_Fullmodel/m1.1_full_domestic_free_exp_alt_log.png")
# TBL merge: m1.1 Full model / domestic / log
m1.1_full_domestic_free_exp_alt_merge_log <- m1.1_full_domestic_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1.2_full_domestic_freedom_expression_altsources_brokendown
m1.2_full_domestic_freedom_expression_altsources_brokendown <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m1.2_full_domestic_freedom_expression_altsources_brokendown_down_expo
m1.2_full_domestic_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/Versions_Fullmodel/m1.2_full_domestic_freedom_expression_altsources_brokendown_expo.png")
# TBL merge: m1.2_full_domestic_freedom_expression_altsources_brokendown_expo
m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo <- m1.2_full_domestic_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.2_full_domestic_freedom_expression_an_alternative_sources_broken_down_log
m1.2_full_domestic_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/Versions_Fullmodel/m1.2_full_domestic_freedom_expression_altsources_brokendown_log.png")
# TBL merge: m1.2_full_domestic_freedom_expression_altsources_brokendown_log
m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_log <- m1.2_full_domestic_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1.3_full_domestic_mean_variables
m1.3_full_domestic_mean_variables <-glm.nb(total_attacks ~
Freedom_expression_mean_media_censorship+
Alternative_sources_mean+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
False_information_mean+
Freedom_expression_mean_discussion+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m1.3_full_domestic_mean_variables_expo
m1.3_full_domestic_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/Versions_Fullmodel/m1.3_full_domestic_mean_variables_expo.png")
# TBL merge: m1.3_full_domestic_mean_variables_expo
m1.3_full_domestic_mean_variables_merge_expo <- m1.3_full_domestic_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.3_full_domestic_mean_variables_log
m1.3_full_domestic_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/Versions_Fullmodel/m1.3_full_domestic_mean_variables_log.png")
# TBL merge: m1.3_full_domestic_mean_variables_log
m1.3_full_domestic_mean_variables_merge_log <- m1.3_full_domestic_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1 Full Model/ m1.1 / m1.2 / m1.3:
#PNG
tbl_merge(list(m1.3_full_domestic_mean_variables_merge_expo,
m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m1.1_full_domestic_free_exp_alt_merge_expo,
m1_full_domestic_attacks_merge_expo),
tab_spanner = c("**Full model 1.3**","**Full model 1.2**", "**Full model 1.1**","**Full model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_full_m1.1_m1.2.m1.3.png",vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1.3_full_domestic_mean_variables_merge_expo,
m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m1.1_full_domestic_free_exp_alt_merge_expo,
m1_full_domestic_attacks_merge_expo),
tab_spanner = c("**Full model 1.3**","**Full model 1.2**", "**Full model 1.1**","**Full model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_full_m1.1_m1.2.m1.3.html")
#View for markdown:
tbl_merge(list(m1.3_full_domestic_mean_variables_merge_expo,
m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m1.1_full_domestic_free_exp_alt_merge_expo,
m1_full_domestic_attacks_merge_expo),
tab_spanner = c("**Full model 1.3**","**Full model 1.2**", "**Full model 1.1**","**Full model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Full model 1.3
|
Full model 1.2
|
Full model 1.1
|
Full model
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Freedom_expression_mean_media_censorship |
38.0*** |
0.585 |
11.0, 144 |
<0.001 |
|
|
|
|
|
|
|
|
|
|
|
|
| Alternative_sources_mean |
98.4*** |
0.624 |
29.4, 353 |
<0.001 |
|
|
|
|
|
|
|
|
|
|
|
|
| Defamation_protection |
1.38 |
0.255 |
0.76, 2.44 |
0.2 |
3.82** |
0.410 |
1.62, 9.06 |
0.001 |
0.42** |
0.320 |
0.22, 0.66 |
0.007 |
0.81 |
0.305 |
0.42, 1.50 |
0.5 |
| Online_media_perspectives |
0.11*** |
0.489 |
0.04, 0.29 |
<0.001 |
0.34* |
0.496 |
0.12, 0.93 |
0.031 |
0.31* |
0.536 |
0.11, 0.68 |
0.030 |
0.21** |
0.522 |
0.08, 0.56 |
0.003 |
| Online_media_existence |
0.59* |
0.224 |
0.37, 0.92 |
0.017 |
0.55* |
0.237 |
0.34, 0.88 |
0.012 |
0.76 |
0.206 |
0.57, 1.17 |
0.2 |
0.57** |
0.212 |
0.36, 0.88 |
0.007 |
| Social_media_organize_violence |
5.67*** |
0.287 |
3.11, 11.3 |
<0.001 |
4.28*** |
0.348 |
2.20, 9.67 |
<0.001 |
11.8*** |
0.357 |
6.27, 27.4 |
<0.001 |
7.21*** |
0.334 |
3.61, 16.1 |
<0.001 |
| False_information_mean |
0.36** |
0.370 |
0.15, 0.78 |
0.006 |
|
|
|
|
|
|
|
|
|
|
|
|
| Freedom_expression_mean_discussion |
0.25* |
0.646 |
0.06, 1.02 |
0.031 |
|
|
|
|
|
|
|
|
|
|
|
|
| Physical_violence_index_x10 |
0.78 |
0.627 |
0.18, 3.11 |
0.7 |
0.91 |
0.546 |
0.29, 2.61 |
0.9 |
0.67 |
0.672 |
0.10, 3.65 |
0.5 |
0.76 |
0.635 |
0.15, 3.38 |
0.7 |
| Constraints_executive_index_x10 |
0.08*** |
0.373 |
0.04, 0.18 |
<0.001 |
0.17*** |
0.404 |
0.07, 0.39 |
<0.001 |
0.51 |
0.345 |
0.25, 1.03 |
0.051 |
0.26*** |
0.358 |
0.12, 0.54 |
<0.001 |
| Polarization_society |
1.38 |
0.205 |
0.86, 2.18 |
0.12 |
1.17 |
0.222 |
0.72, 1.89 |
0.5 |
0.58* |
0.216 |
0.37, 0.85 |
0.013 |
0.83 |
0.220 |
0.51, 1.34 |
0.4 |
| Civil_society_participation_index_x10 |
1.54 |
0.404 |
0.54, 4.28 |
0.3 |
0.35* |
0.453 |
0.12, 0.99 |
0.020 |
0.21*** |
0.409 |
0.06, 0.64 |
<0.001 |
0.61 |
0.408 |
0.19, 1.88 |
0.2 |
| Average_years_education_citizens |
3.13*** |
0.215 |
2.01, 5.12 |
<0.001 |
2.22*** |
0.172 |
1.56, 3.24 |
<0.001 |
1.48* |
0.161 |
1.03, 2.21 |
0.015 |
1.73** |
0.167 |
1.21, 2.59 |
0.001 |
| Population_millions |
1.02*** |
0.004 |
1.01, 1.03 |
<0.001 |
1.02*** |
0.003 |
1.01, 1.02 |
<0.001 |
1.01*** |
0.004 |
1.01, 1.02 |
<0.001 |
1.02*** |
0.004 |
1.01, 1.03 |
<0.001 |
| AIC |
933 |
|
|
|
883 |
|
|
|
965 |
|
|
|
944 |
|
|
|
| BIC |
997 |
|
|
|
967 |
|
|
|
1,029 |
|
|
|
1,011 |
|
|
|
| Deviance |
225 |
|
|
|
222 |
|
|
|
230 |
|
|
|
226 |
|
|
|
| Null deviance |
666 |
|
|
|
881 |
|
|
|
583 |
|
|
|
639 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
| Government_censorship_Media |
|
|
|
|
7.96*** |
0.380 |
3.52, 18.6 |
<0.001 |
|
|
|
|
|
|
|
|
| Harassment_journalists |
|
|
|
|
0.16*** |
0.479 |
0.06, 0.44 |
<0.001 |
|
|
|
|
|
|
|
|
| Media_self_censorship |
|
|
|
|
18.4*** |
0.512 |
6.24, 58.0 |
<0.001 |
|
|
|
|
|
|
|
|
| Media_bias |
|
|
|
|
0.59 |
0.354 |
0.28, 1.26 |
0.13 |
|
|
|
|
|
|
|
|
| Media_critical |
|
|
|
|
5.97*** |
0.405 |
2.75, 13.3 |
<0.001 |
|
|
|
|
|
|
|
|
| Media_perspectives |
|
|
|
|
1.52 |
0.390 |
0.65, 3.54 |
0.3 |
|
|
|
|
|
|
|
|
| Government_false_information |
|
|
|
|
3.04** |
0.354 |
1.40, 6.58 |
0.002 |
4.21*** |
0.348 |
1.95, 9.27 |
<0.001 |
2.41** |
0.340 |
1.07, 5.34 |
0.010 |
| Party_false_information |
|
|
|
|
0.26*** |
0.307 |
0.13, 0.46 |
<0.001 |
0.27*** |
0.333 |
0.13, 0.52 |
<0.001 |
0.28*** |
0.301 |
0.15, 0.53 |
<0.001 |
| Freedom_discussion_x10 |
|
|
|
|
0.60 |
0.771 |
0.11, 2.85 |
0.5 |
0.37 |
0.882 |
0.07, 1.27 |
0.3 |
2.20 |
0.990 |
0.31, 15.2 |
0.4 |
| Freedom_exp_alternative_sourc_index_x10 |
|
|
|
|
|
|
|
|
2.02 |
0.912 |
0.50, 13.9 |
0.4 |
|
|
|
|
| Freedom_expression_index_x10 |
|
|
|
|
|
|
|
|
|
|
|
|
0.00*** |
1.84 |
0.00, 0.01 |
<0.001 |
| Alternative_Sources_index_x10 |
|
|
|
|
|
|
|
|
|
|
|
|
17.8*** |
0.621 |
5.62, 57.9 |
<0.001 |
Regression_lagged: Versions of full model_all
# Regression_lagged: Versions of full model_all --------------------------------------
# m1.1_full_all_free_exp_alt
m1.1_full_all_free_exp_alt<-glm.nb(total_attacks ~
Freedom_exp_alternative_sourc_index_x10+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 150))
# TBL export: m1.1 Full model / all / exp
m1.1_full_all_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.1 :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/Versions_Fullmodel/m1.1_full_all_free_exp_alt_expo.png")
# TBL merge: m1.1 Full model / all / exp
m1.1_full_all_free_exp_alt_merge_expo <- m1.1_full_all_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.1 Full model / all / log
m1.1_full_all_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.1 :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/Versions_Fullmodel/m1.1_full_all_free_exp_alt_log.png")
# TBL merge: m1.1 Full model / all / log
m1.1_full_all_free_exp_alt_merge_log <- m1.1_full_all_free_exp_alt %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1.2_full_all_freedom_expression_altsources_brokendown
m1.2_full_all_freedom_expression_altsources_brokendown <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 50))
# TBL export: m1.2_full_all_freedom_expression_altsources_brokendown_down_expo
m1.2_full_all_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/Versions_Fullmodel/m1.2_full_all_freedom_expression_altsources_brokendown_expo.png")
# TBL merge: m1.2_full_all_freedom_expression_altsources_brokendown_expo
m1.2_full_all_freedom_expression_altsources_brokendown_merge_expo <- m1.2_full_all_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.2_full_all_freedom_expression_an_alternative_sources_broken_down_log
m1.2_full_all_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/Versions_Fullmodel/m1.2_full_all_freedom_expression_altsources_brokendown_log.png")
# TBL merge: m1.2_full_all_freedom_expression_altsources_brokendown_log
m1.2_full_all_freedom_expression_altsources_brokendown_merge_log <- m1.2_full_all_freedom_expression_altsources_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1.3_full_all_mean_variables
m1.3_full_all_mean_variables <-glm.nb(total_attacks ~
Freedom_expression_mean_media_censorship+
Alternative_sources_mean+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
False_information_mean+
Freedom_expression_mean_discussion+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 50))
# TBL export: m1.3_full_all_mean_variables_expo
m1.3_full_all_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/Versions_Fullmodel/m1.3_full_all_mean_variables_expo.png")
# TBL merge: m1.3_full_all_mean_variables_expo
m1.3_full_all_mean_variables_merge_expo <- m1.3_full_all_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.3_full_domestic_mean_variables_log
m1.3_full_all_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model 1.2 :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/Versions_Fullmodel/m1.3_full_all_mean_variables_log.png")
# TBL merge: m1.3_full_all_mean_variables_log
m1.3_full_all_mean_variables_merge_log <- m1.3_full_all_mean_variables %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1 Full Model (all attacks)/ m1.1 / m1.2 / m1.3:
#PNG
tbl_merge(list(m1.3_full_all_mean_variables_merge_expo,
m1.2_full_all_freedom_expression_altsources_brokendown_merge_expo,
m1.1_full_all_free_exp_alt_merge_expo,
m1_full_all_attacks_merge_expo),
tab_spanner = c("**Full model 1.3**","**Full model 1.2**", "**Full model 1.1**","**Full model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_full_m1.1_m1.2.m1.3.png",vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1.3_full_all_mean_variables_merge_expo,
m1.2_full_all_freedom_expression_altsources_brokendown_merge_expo,
m1.1_full_all_free_exp_alt_merge_expo,
m1_full_all_attacks_merge_expo),
tab_spanner = c("**Full model 1.3**","**Full model 1.2**", "**Full model 1.1**","**Full model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_full_m1.1_m1.2.m1.3.html")
#View for markdown:
tbl_merge(list(m1.3_full_all_mean_variables_merge_expo,
m1.2_full_all_freedom_expression_altsources_brokendown_merge_expo,
m1.1_full_all_free_exp_alt_merge_expo,
m1_full_all_attacks_merge_expo),
tab_spanner = c("**Full model 1.3**","**Full model 1.2**", "**Full model 1.1**","**Full model**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Full model 1.3
|
Full model 1.2
|
Full model 1.1
|
Full model
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Freedom_expression_mean_media_censorship |
3.43*** |
0.312 |
1.86, 6.37 |
<0.001 |
|
|
|
|
|
|
|
|
|
|
|
|
| Alternative_sources_mean |
15.1*** |
0.350 |
8.10, 28.1 |
<0.001 |
|
|
|
|
|
|
|
|
|
|
|
|
| Defamation_protection |
1.11 |
0.127 |
0.83, 1.47 |
0.4 |
0.98 |
0.186 |
0.67, 1.41 |
>0.9 |
0.66* |
0.170 |
0.46, 0.95 |
0.014 |
0.85 |
0.156 |
0.61, 1.18 |
0.3 |
| Online_media_perspectives |
0.39*** |
0.241 |
0.24, 0.66 |
<0.001 |
0.54* |
0.266 |
0.31, 0.94 |
0.020 |
0.61 |
0.278 |
0.36, 1.06 |
0.079 |
0.45** |
0.260 |
0.27, 0.77 |
0.002 |
| Online_media_existence |
1.16 |
0.125 |
0.91, 1.48 |
0.2 |
1.04 |
0.134 |
0.80, 1.34 |
0.8 |
1.35* |
0.130 |
1.04, 1.75 |
0.021 |
1.14 |
0.123 |
0.91, 1.45 |
0.3 |
| Social_media_organize_violence |
2.56*** |
0.127 |
1.97, 3.36 |
<0.001 |
2.49*** |
0.130 |
1.91, 3.29 |
<0.001 |
3.57*** |
0.144 |
2.68, 4.81 |
<0.001 |
2.92*** |
0.130 |
2.24, 3.84 |
<0.001 |
| False_information_mean |
0.40*** |
0.195 |
0.27, 0.58 |
<0.001 |
|
|
|
|
|
|
|
|
|
|
|
|
| Freedom_expression_mean_discussion |
0.59 |
0.366 |
0.27, 1.25 |
0.2 |
|
|
|
|
|
|
|
|
|
|
|
|
| Physical_violence_index_x10 |
0.30** |
0.438 |
0.10, 0.80 |
0.006 |
0.23** |
0.446 |
0.07, 0.68 |
0.001 |
0.33* |
0.484 |
0.10, 1.01 |
0.021 |
0.39* |
0.447 |
0.13, 1.09 |
0.036 |
| Constraints_executive_index_x10 |
0.26*** |
0.197 |
0.18, 0.38 |
<0.001 |
0.42*** |
0.219 |
0.27, 0.66 |
<0.001 |
0.49*** |
0.206 |
0.32, 0.74 |
<0.001 |
0.36*** |
0.197 |
0.24, 0.53 |
<0.001 |
| Polarization_society |
1.67*** |
0.098 |
1.35, 2.07 |
<0.001 |
1.55*** |
0.118 |
1.23, 1.96 |
<0.001 |
1.13 |
0.104 |
0.91, 1.41 |
0.2 |
1.41*** |
0.103 |
1.14, 1.76 |
<0.001 |
| Civil_society_participation_index_x10 |
1.58 |
0.257 |
0.92, 2.72 |
0.074 |
1.61 |
0.282 |
0.87, 3.00 |
0.091 |
1.01 |
0.263 |
0.57, 1.76 |
>0.9 |
1.83* |
0.261 |
1.03, 3.23 |
0.021 |
| Average_years_education_citizens |
1.78*** |
0.090 |
1.46, 2.17 |
<0.001 |
1.67*** |
0.097 |
1.35, 2.08 |
<0.001 |
1.33*** |
0.083 |
1.09, 1.63 |
<0.001 |
1.48*** |
0.081 |
1.23, 1.78 |
<0.001 |
| Population_millions |
1.01*** |
0.002 |
1.00, 1.01 |
<0.001 |
1.00* |
0.002 |
1.00, 1.01 |
0.024 |
1.01** |
0.002 |
1.00, 1.01 |
0.005 |
1.01*** |
0.002 |
1.00, 1.01 |
<0.001 |
| AIC |
1,858 |
|
|
|
1,846 |
|
|
|
1,898 |
|
|
|
1,866 |
|
|
|
| BIC |
1,922 |
|
|
|
1,930 |
|
|
|
1,962 |
|
|
|
1,934 |
|
|
|
| Deviance |
414 |
|
|
|
410 |
|
|
|
401 |
|
|
|
409 |
|
|
|
| Null deviance |
1,015 |
|
|
|
1,072 |
|
|
|
859 |
|
|
|
977 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
| Government_censorship_Media |
|
|
|
|
2.82*** |
0.260 |
1.67, 4.84 |
<0.001 |
|
|
|
|
|
|
|
|
| Harassment_journalists |
|
|
|
|
1.29 |
0.241 |
0.81, 2.07 |
0.3 |
|
|
|
|
|
|
|
|
| Media_self_censorship |
|
|
|
|
1.04 |
0.248 |
0.61, 1.75 |
0.9 |
|
|
|
|
|
|
|
|
| Media_bias |
|
|
|
|
0.82 |
0.229 |
0.51, 1.32 |
0.4 |
|
|
|
|
|
|
|
|
| Media_critical |
|
|
|
|
4.55*** |
0.261 |
2.74, 7.60 |
<0.001 |
|
|
|
|
|
|
|
|
| Media_perspectives |
|
|
|
|
2.03** |
0.231 |
1.30, 3.17 |
0.002 |
|
|
|
|
|
|
|
|
| Government_false_information |
|
|
|
|
1.03 |
0.202 |
0.67, 1.59 |
0.9 |
1.50* |
0.190 |
0.99, 2.27 |
0.034 |
1.05 |
0.190 |
0.70, 1.57 |
0.8 |
| Party_false_information |
|
|
|
|
0.55*** |
0.162 |
0.40, 0.75 |
<0.001 |
0.47*** |
0.176 |
0.34, 0.65 |
<0.001 |
0.45*** |
0.154 |
0.34, 0.61 |
<0.001 |
| Freedom_discussion_x10 |
|
|
|
|
0.76 |
0.513 |
0.27, 2.02 |
0.6 |
1.06 |
0.561 |
0.37, 2.88 |
>0.9 |
2.12 |
0.587 |
0.71, 6.11 |
0.2 |
| Freedom_exp_alternative_sourc_index_x10 |
|
|
|
|
|
|
|
|
4.62* |
0.653 |
1.09, 17.3 |
0.019 |
|
|
|
|
| Freedom_expression_index_x10 |
|
|
|
|
|
|
|
|
|
|
|
|
0.01*** |
1.08 |
0.00, 0.11 |
<0.001 |
| Alternative_Sources_index_x10 |
|
|
|
|
|
|
|
|
|
|
|
|
8.54*** |
0.373 |
4.48, 16.2 |
<0.001 |
Regression_lagged: Broken_down_domestic
# Regression_lagged: Broken_down_domestic -----------------------------
# m2 parsimonious model_broken_down / domestic
m2_parsimonious_domestic_broken_down <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m2 parsimonious model_broken_down / domestic / expo
m2_parsimonious_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model (broken down): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m2_parsimonious_domestic_broken_down_expo.png")
# TBL merge: m2 parsimonious model_broken_down / domestic / expo
m2_parsimonious_domestic_merge_broken_down_expo <- m2_parsimonious_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m2 parsimonious model_broken_down / domestic / log
m2_parsimonious_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model (broken down): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m2_parsimonious_domestic_broken_down_log.png")
# TBL merge: m2 parsimonious model_broken_down / domestic / log
m2_parsimonious_domestic_merge_broken_down_log <- m2_parsimonious_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m3 minimal model
m3_minimal_domestic_broken_down<-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 150))
# TBL export: m3 minimal model_broken_down / domestic / expo
m3_minimal_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model (broken down): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m3_minimal_domestic_broken_down_expo.png")
# TBL merge: m3 minimal model_broken_down / domestic / expo
m3_minimal_domestic_merge_broken_down_expo <- m3_minimal_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m3 minimal model_broken_down / domestic / log
m3_minimal_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model (borken down): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/Domestic/m3_minimal_domestic_broken_down_log.png")
# TBL merge: m3 minimal model_broken_down / domestic / log
m3_minimal_domestic_merge_broken_down_log <- m3_minimal_domestic_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1/m2/m3 / expo :
#PNG
tbl_merge(list(m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m2_parsimonious_domestic_merge_broken_down_expo,
m3_minimal_domestic_merge_broken_down_expo),
tab_spanner = c("**Full model (broken down)**", "**Parsimonious model (broken down)**","**Minimal model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_m2_m3_domestic_broken_down_expo.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m2_parsimonious_domestic_merge_broken_down_expo,
m3_minimal_domestic_merge_broken_down_expo),
tab_spanner = c("**Full model (broken down)**", "**Parsimonious model (broken down)**","**Minimal model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_m2_m3_domestic_broken_down_expo.html")
#View for markdown:
tbl_merge(list(m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m2_parsimonious_domestic_merge_broken_down_expo,
m3_minimal_domestic_merge_broken_down_expo),
tab_spanner = c("**Full model (broken down)**", "**Parsimonious model (broken down)**","**Minimal model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Full model (broken down)
|
Parsimonious model (broken down)
|
Minimal model (broken down)
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Government_censorship_Media |
7.96*** |
0.380 |
3.52, 18.6 |
<0.001 |
15.3*** |
0.384 |
6.49, 37.5 |
<0.001 |
71.3*** |
0.386 |
34.3, 185 |
<0.001 |
| Harassment_journalists |
0.16*** |
0.479 |
0.06, 0.44 |
<0.001 |
0.39* |
0.370 |
0.17, 0.88 |
0.012 |
0.60 |
0.341 |
0.27, 1.30 |
0.14 |
| Media_self_censorship |
18.4*** |
0.512 |
6.24, 58.0 |
<0.001 |
5.45*** |
0.417 |
2.33, 13.1 |
<0.001 |
1.53 |
0.347 |
0.73, 3.22 |
0.2 |
| Media_bias |
0.59 |
0.354 |
0.28, 1.26 |
0.13 |
0.73 |
0.347 |
0.34, 1.58 |
0.4 |
0.48* |
0.341 |
0.21, 1.06 |
0.029 |
| Media_critical |
5.97*** |
0.405 |
2.75, 13.3 |
<0.001 |
10.0*** |
0.374 |
4.93, 20.7 |
<0.001 |
8.23*** |
0.365 |
4.10, 16.9 |
<0.001 |
| Media_perspectives |
1.52 |
0.390 |
0.65, 3.54 |
0.3 |
0.53 |
0.341 |
0.25, 1.12 |
0.062 |
1.25 |
0.318 |
0.59, 2.60 |
0.5 |
| Defamation_protection |
3.82** |
0.410 |
1.62, 9.06 |
0.001 |
1.38 |
0.330 |
0.69, 2.74 |
0.3 |
3.56*** |
0.301 |
1.84, 7.12 |
<0.001 |
| Online_media_perspectives |
0.34* |
0.496 |
0.12, 0.93 |
0.031 |
0.58 |
0.428 |
0.23, 1.39 |
0.2 |
0.17*** |
0.361 |
0.08, 0.34 |
<0.001 |
| Online_media_existence |
0.55* |
0.237 |
0.34, 0.88 |
0.012 |
0.50** |
0.225 |
0.31, 0.81 |
0.002 |
0.81 |
0.199 |
0.52, 1.26 |
0.3 |
| Social_media_organize_violence |
4.28*** |
0.348 |
2.20, 9.67 |
<0.001 |
3.62*** |
0.326 |
1.95, 7.68 |
<0.001 |
|
|
|
|
| Government_false_information |
3.04** |
0.354 |
1.40, 6.58 |
0.002 |
6.29*** |
0.328 |
2.98, 13.3 |
<0.001 |
|
|
|
|
| Party_false_information |
0.26*** |
0.307 |
0.13, 0.46 |
<0.001 |
0.23*** |
0.320 |
0.12, 0.42 |
<0.001 |
|
|
|
|
| Freedom_discussion_x10 |
0.60 |
0.771 |
0.11, 2.85 |
0.5 |
|
|
|
|
|
|
|
|
| Physical_violence_index_x10 |
0.91 |
0.546 |
0.29, 2.61 |
0.9 |
|
|
|
|
|
|
|
|
| Constraints_executive_index_x10 |
0.17*** |
0.404 |
0.07, 0.39 |
<0.001 |
|
|
|
|
|
|
|
|
| Polarization_society |
1.17 |
0.222 |
0.72, 1.89 |
0.5 |
|
|
|
|
|
|
|
|
| Civil_society_participation_index_x10 |
0.35* |
0.453 |
0.12, 0.99 |
0.020 |
|
|
|
|
|
|
|
|
| Average_years_education_citizens |
2.22*** |
0.172 |
1.56, 3.24 |
<0.001 |
1.43** |
0.127 |
1.07, 1.95 |
0.005 |
1.87*** |
0.112 |
1.39, 2.52 |
<0.001 |
| Population_millions |
1.02*** |
0.003 |
1.01, 1.02 |
<0.001 |
1.01*** |
0.002 |
1.01, 1.02 |
<0.001 |
1.02*** |
0.002 |
1.02, 1.03 |
<0.001 |
| AIC |
883 |
|
|
|
899 |
|
|
|
959 |
|
|
|
| BIC |
967 |
|
|
|
962 |
|
|
|
1,010 |
|
|
|
| Deviance |
222 |
|
|
|
227 |
|
|
|
244 |
|
|
|
| Null deviance |
881 |
|
|
|
793 |
|
|
|
625 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
Regression_lagged: Broken_down_all
# Regression_lagged: Broken_down_all -----------------------------
# m2 parsimonious model_broken_down /all
m2_parsimonious_all_broken_down <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 50))
# TBL export: m2 parsimonious model_broken_down / all / expo
m2_parsimonious_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model (broken down): Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m2_parsimonious_all_broken_down_expo.png")
# TBL merge: m2 parsimonious model_broken_down / all / expo
m2_parsimonious_all_merge_broken_down_expo <- m2_parsimonious_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m2 parsimonious model_broken_down / all / log
m2_parsimonious_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Parsimonious Model (broken down): Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m2_parsimonious_all_broken_down_log.png")
# TBL merge: m2 parsimonious model_broken_down / all / log
m2_parsimonious_all_merge_broken_down_log <- m2_parsimonious_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m3 minimal model
m3_minimal_all_broken_down<-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 150))
# TBL export: m3 minimal model_broken_down / all / expo
m3_minimal_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model (broken down): Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m3_minimal_all_broken_down_expo.png")
# TBL merge: m3 minimal model_broken_down / all / expo
m3_minimal_all_merge_broken_down_expo <- m3_minimal_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m3 minimal model_broken_down / all / log
m3_minimal_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Minimal Model (borken down): Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/All_attacks/m3_minimal_all_broken_down_log.png")
# TBL merge: m3 minimal model_broken_down / all / log
m3_minimal_all_merge_broken_down_log <- m3_minimal_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1/m2/m3 / expo (all attacks):
#PNG
tbl_merge(list(m1.2_full_all_freedom_expression_altsources_brokendown_merge_expo,
m2_parsimonious_all_merge_broken_down_expo,
m3_minimal_all_merge_broken_down_expo),
tab_spanner = c("**Full model (broken down)**", "**Parsimonious model (broken down)**","**Minimal model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_m2_m3_domestic_broken_down_expo.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1.2_full_all_freedom_expression_altsources_brokendown_merge_expo,
m2_parsimonious_all_merge_broken_down_expo,
m3_minimal_all_merge_broken_down_expo),
tab_spanner = c("**Full model (broken down)**", "**Parsimonious model (broken down)**","**Minimal model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_m2_m3_domestic_broken_down_expo.html")
#View for markdown:
tbl_merge(list(m1.2_full_all_freedom_expression_altsources_brokendown_merge_expo,
m2_parsimonious_all_merge_broken_down_expo,
m3_minimal_all_merge_broken_down_expo),
tab_spanner = c("**Full model (broken down)**", "**Parsimonious model (broken down)**","**Minimal model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Full model (broken down)
|
Parsimonious model (broken down)
|
Minimal model (broken down)
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Government_censorship_Media |
2.82*** |
0.260 |
1.67, 4.84 |
<0.001 |
3.41*** |
0.266 |
1.96, 5.95 |
<0.001 |
6.31*** |
0.261 |
3.72, 10.7 |
<0.001 |
| Harassment_journalists |
1.29 |
0.241 |
0.81, 2.07 |
0.3 |
0.88 |
0.219 |
0.57, 1.36 |
0.5 |
0.94 |
0.220 |
0.59, 1.53 |
0.8 |
| Media_self_censorship |
1.04 |
0.248 |
0.61, 1.75 |
0.9 |
0.69 |
0.230 |
0.44, 1.09 |
0.11 |
0.45*** |
0.223 |
0.29, 0.70 |
<0.001 |
| Media_bias |
0.82 |
0.229 |
0.51, 1.32 |
0.4 |
1.00 |
0.230 |
0.62, 1.61 |
>0.9 |
1.10 |
0.243 |
0.66, 1.83 |
0.7 |
| Media_critical |
4.55*** |
0.261 |
2.74, 7.60 |
<0.001 |
2.64*** |
0.232 |
1.70, 4.06 |
<0.001 |
3.44*** |
0.246 |
2.21, 5.35 |
<0.001 |
| Media_perspectives |
2.03** |
0.231 |
1.30, 3.17 |
0.002 |
1.39 |
0.207 |
0.94, 2.06 |
0.11 |
1.83** |
0.223 |
1.19, 2.79 |
0.006 |
| Defamation_protection |
0.98 |
0.186 |
0.67, 1.41 |
>0.9 |
0.85 |
0.177 |
0.59, 1.23 |
0.4 |
1.42* |
0.167 |
1.00, 2.01 |
0.035 |
| Online_media_perspectives |
0.54* |
0.266 |
0.31, 0.94 |
0.020 |
0.38*** |
0.245 |
0.23, 0.64 |
<0.001 |
0.19*** |
0.223 |
0.12, 0.30 |
<0.001 |
| Online_media_existence |
1.04 |
0.134 |
0.80, 1.34 |
0.8 |
1.18 |
0.131 |
0.91, 1.52 |
0.2 |
1.29 |
0.133 |
0.99, 1.68 |
0.056 |
| Social_media_organize_violence |
2.49*** |
0.130 |
1.91, 3.29 |
<0.001 |
2.90*** |
0.121 |
2.25, 3.80 |
<0.001 |
|
|
|
|
| Government_false_information |
1.03 |
0.202 |
0.67, 1.59 |
0.9 |
1.66** |
0.193 |
1.08, 2.54 |
0.009 |
|
|
|
|
| Party_false_information |
0.55*** |
0.162 |
0.40, 0.75 |
<0.001 |
0.56*** |
0.167 |
0.41, 0.77 |
<0.001 |
|
|
|
|
| Freedom_discussion_x10 |
0.76 |
0.513 |
0.27, 2.02 |
0.6 |
|
|
|
|
|
|
|
|
| Physical_violence_index_x10 |
0.23** |
0.446 |
0.07, 0.68 |
0.001 |
|
|
|
|
|
|
|
|
| Constraints_executive_index_x10 |
0.42*** |
0.219 |
0.27, 0.66 |
<0.001 |
|
|
|
|
|
|
|
|
| Polarization_society |
1.55*** |
0.118 |
1.23, 1.96 |
<0.001 |
|
|
|
|
|
|
|
|
| Civil_society_participation_index_x10 |
1.61 |
0.282 |
0.87, 3.00 |
0.091 |
|
|
|
|
|
|
|
|
| Average_years_education_citizens |
1.67*** |
0.097 |
1.35, 2.08 |
<0.001 |
1.26** |
0.089 |
1.03, 1.54 |
0.010 |
1.26** |
0.082 |
1.02, 1.54 |
0.005 |
| Population_millions |
1.00* |
0.002 |
1.00, 1.01 |
0.024 |
1.01*** |
0.002 |
1.00, 1.01 |
<0.001 |
1.02*** |
0.002 |
1.01, 1.02 |
<0.001 |
| AIC |
1,846 |
|
|
|
1,875 |
|
|
|
1,946 |
|
|
|
| BIC |
1,930 |
|
|
|
1,939 |
|
|
|
1,998 |
|
|
|
| Deviance |
410 |
|
|
|
407 |
|
|
|
405 |
|
|
|
| Null deviance |
1,072 |
|
|
|
941 |
|
|
|
743 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
Regression_lagged: Online & offline models_domestic
# Regression_lagged: Online & offline models_domestic -------------------------------------------------
# m1_full_brokendown_onffline_expo / domestic
m1_offline_brokendown <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m1_full_brokendown_offline_expo / domestic / expo
m1_offline_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Offline Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/m1_full_brokendown_offline_expo.png")
# TBL merge: m1_full_brokendown_offline_expo / domestic / expo
m1_full_brokendown_offline_merge_expo <- m1_offline_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1_full_brokendown_offline_expo / domestic / log
m1_offline_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Offline Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/m1_full_brokendown_offline_log.png")
# TBL merge: m1_full_brokendown_offline_expo / domestic / log
m1_full_brokendown_offline_merge_log <- m1_offline_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# # m1_full_brokendown_online_expo / domestic
m1_online_brokendown <-glm.nb(total_attacks ~
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 150))
# TBL export: m1_full_brokendown_online_expo / domestic / expo
m1_online_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Online Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/m1_full_brokendown_online_expo.png")
# TBL merge: m1_full_brokendown_online_expo / domestic / expo
m1_full_brokendown_online_merge_expo <- m1_online_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1_full_brokendown_online / domestic / log
m1_online_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Online Model: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/m1_full_brokendown_online_log.png")
# TBL merge: m1_full_brokendown_online / domestic / log
m1_full_brokendown_online_merge_log <- m1_online_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#combined_m1_offline_m1_online_expo :
#PNG
tbl_merge(list(m1_full_brokendown_offline_merge_expo,
m1_full_brokendown_online_merge_expo),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_offline_m1_online_expo.png", vwidth = 2000, vheight = 1000)
#html
tbl_merge(list(m1_full_brokendown_offline_merge_expo,
m1_full_brokendown_online_merge_expo),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_offline_m1_online_expo.html")
#combined_m1_offline_m1_online_log :
#PNG
tbl_merge(list(m1_full_brokendown_offline_merge_log,
m1_full_brokendown_online_merge_log),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_offline_m1_online_log.png", vwidth = 2000, vheight = 1000)
#html
tbl_merge(list(m1_full_brokendown_offline_merge_log,
m1_full_brokendown_online_merge_log),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1_offline_m1_online_log.html")
#View for markdown:
tbl_merge(list(m1_full_brokendown_offline_merge_expo,
m1_full_brokendown_online_merge_expo),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Offline model (broken down)
|
Online model (broken down)
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Government_censorship_Media |
19.4*** |
0.416 |
7.77, 51.2 |
<0.001 |
|
|
|
|
| Harassment_journalists |
0.74 |
0.329 |
0.37, 1.48 |
0.4 |
|
|
|
|
| Media_self_censorship |
2.21* |
0.369 |
0.98, 5.09 |
0.031 |
|
|
|
|
| Media_bias |
0.35** |
0.353 |
0.16, 0.77 |
0.003 |
|
|
|
|
| Media_critical |
8.50*** |
0.391 |
3.94, 18.6 |
<0.001 |
|
|
|
|
| Media_perspectives |
2.17* |
0.352 |
1.00, 4.67 |
0.028 |
|
|
|
|
| Freedom_discussion_x10 |
0.91 |
0.785 |
0.17, 4.18 |
>0.9 |
0.42 |
0.830 |
0.08, 1.17 |
0.3 |
| Physical_violence_index_x10 |
0.58 |
0.623 |
0.11, 2.62 |
0.4 |
0.84 |
0.658 |
0.15, 4.11 |
0.8 |
| Constraints_executive_index_x10 |
0.46* |
0.308 |
0.23, 0.91 |
0.013 |
0.51 |
0.344 |
0.27, 1.05 |
0.053 |
| Polarization_society |
2.69*** |
0.173 |
1.84, 3.97 |
<0.001 |
0.58* |
0.218 |
0.37, 0.81 |
0.014 |
| Civil_society_participation_index_x10 |
0.61 |
0.444 |
0.21, 1.73 |
0.3 |
0.23*** |
0.391 |
0.07, 0.71 |
<0.001 |
| Average_years_education_citizens |
1.93*** |
0.124 |
1.49, 2.54 |
<0.001 |
1.49* |
0.159 |
1.03, 2.23 |
0.012 |
| Population_millions |
1.01*** |
0.002 |
1.00, 1.02 |
<0.001 |
1.01*** |
0.003 |
1.01, 1.02 |
<0.001 |
| AIC |
967 |
|
|
|
964 |
|
|
|
| BIC |
1,027 |
|
|
|
1,024 |
|
|
|
| Deviance |
247 |
|
|
|
229 |
|
|
|
| Null deviance |
622 |
|
|
|
580 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
| Defamation_protection |
|
|
|
|
0.42** |
0.321 |
0.22, 0.54 |
0.007 |
| Online_media_perspectives |
|
|
|
|
0.32* |
0.535 |
0.12, 0.56 |
0.036 |
| Online_media_existence |
|
|
|
|
0.74 |
0.205 |
0.56, 1.15 |
0.15 |
| Social_media_organize_violence |
|
|
|
|
12.3*** |
0.352 |
8.62, 28.6 |
<0.001 |
| Government_false_information |
|
|
|
|
4.31*** |
0.349 |
2.77, 9.53 |
<0.001 |
| Party_false_information |
|
|
|
|
0.25*** |
0.324 |
0.13, 0.34 |
<0.001 |
Regression_lagged: Online & offline models_all
# Regression_lagged: Online & offline models_all -------------------------------------------------
# m1_offline_all_brokendown
m1_offline_all_brokendown <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 150))
# TBL export: m1_offline_all_brokendown / all / expo
m1_offline_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Offline Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1_offline_all_brokendown_expo.png")
# TBL merge: m1_offline_all_brokendown / all / expo
m1_offline_all_brokendown_merge_expo <- m1_offline_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1_offline_all_brokendown / all / log
m1_offline_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Offline Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1_offline_all_brokendown_log.png")
# TBL merge: m1_offline_all_brokendown / all / log
m1_offline_all_brokendown_merge_log <- m1_offline_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# # m1_online_all_brokendown / all
m1_online_all_brokendown <-glm.nb(total_attacks ~
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 150))
# TBL export: m1_online_all_brokendown / all / expo
m1_online_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Online Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1_online_all_brokendown_expo.png")
# TBL merge: m1_online_all_brokendown / all / expo
m1_online_all_brokendown_merge_expo <- m1_online_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1_online_all_brokendown / all / log
m1_online_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Online Model: Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1_online_all_brokendown_log.png")
# TBL merge: m1_online_all_brokendown / all / log
m1_online_all_brokendown_merge_log <- m1_online_all_brokendown %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#combined_m1_offline_online_all_brokendown_expo :
#PNG
tbl_merge(list(m1_offline_all_brokendown_merge_expo,
m1_online_all_brokendown_merge_expo),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_offline_m1_online_expo.png", vwidth = 2000, vheight = 1000)
#html
tbl_merge(list(m1_offline_all_brokendown_merge_expo,
m1_online_all_brokendown_merge_expo),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_offline_m1_online_expo.html")
#combined_m1_offline_onlinw_all_brokendown_log :
#PNG
tbl_merge(list(m1_offline_all_brokendown_merge_log,
m1_online_all_brokendown_merge_log),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_offline_m1_online_log.png", vwidth = 2000, vheight = 1000)
#html
tbl_merge(list(m1_offline_all_brokendown_merge_log,
m1_online_all_brokendown_merge_log),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/all_combined_m1_offline_m1_online_log.html")
#View for markdown:
tbl_merge(list(m1_offline_all_brokendown_merge_expo,
m1_online_all_brokendown_merge_expo),
tab_spanner = c("**Offline model (broken down)**", "**Online model (broken down)**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Offline model (broken down)
|
Online model (broken down)
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Government_censorship_Media |
3.46*** |
0.267 |
2.02, 6.04 |
<0.001 |
|
|
|
|
| Harassment_journalists |
1.62* |
0.201 |
1.05, 2.47 |
0.016 |
|
|
|
|
| Media_self_censorship |
0.76 |
0.238 |
0.46, 1.25 |
0.2 |
|
|
|
|
| Media_bias |
1.08 |
0.229 |
0.66, 1.76 |
0.7 |
|
|
|
|
| Media_critical |
8.94*** |
0.271 |
5.46, 14.6 |
<0.001 |
|
|
|
|
| Media_perspectives |
2.52*** |
0.235 |
1.60, 3.93 |
<0.001 |
|
|
|
|
| Freedom_discussion_x10 |
1.15 |
0.538 |
0.41, 3.09 |
0.8 |
1.16 |
0.618 |
0.41, 3.30 |
0.8 |
| Physical_violence_index_x10 |
0.15*** |
0.472 |
0.04, 0.53 |
<0.001 |
0.40 |
0.189 |
0.16, 1.01 |
0.053 |
| Constraints_executive_index_x10 |
0.56** |
0.200 |
0.36, 0.87 |
0.004 |
0.60* |
0.124 |
0.40, 0.90 |
0.013 |
| Polarization_society |
2.28*** |
0.107 |
1.83, 2.85 |
<0.001 |
1.25* |
0.133 |
1.02, 1.54 |
0.033 |
| Civil_society_participation_index_x10 |
1.35 |
0.295 |
0.73, 2.45 |
0.3 |
1.35 |
0.326 |
0.84, 2.17 |
0.2 |
| Average_years_education_citizens |
1.49*** |
0.075 |
1.26, 1.76 |
<0.001 |
1.34*** |
0.112 |
1.13, 1.57 |
<0.001 |
| Population_millions |
1.00** |
0.002 |
1.00, 1.01 |
0.010 |
1.00* |
0.002 |
1.00, 1.01 |
0.032 |
| AIC |
1,915 |
|
|
|
1,907 |
|
|
|
| BIC |
1,975 |
|
|
|
1,966 |
|
|
|
| Deviance |
406 |
|
|
|
399 |
|
|
|
| Null deviance |
826 |
|
|
|
828 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
| Defamation_protection |
|
|
|
|
0.70* |
0.122 |
0.50, 0.99 |
0.042 |
| Online_media_perspectives |
|
|
|
|
0.66 |
0.186 |
0.38, 1.15 |
0.14 |
| Online_media_existence |
|
|
|
|
1.33* |
0.173 |
1.03, 1.71 |
0.031 |
| Social_media_organize_violence |
|
|
|
|
3.49*** |
0.506 |
2.62, 4.64 |
<0.001 |
| Government_false_information |
|
|
|
|
1.47* |
0.286 |
1.01, 2.15 |
0.047 |
| Party_false_information |
|
|
|
|
0.48*** |
0.083 |
0.34, 0.67 |
<0.001 |
Regression_lagged: Variables suggested by other authors
# Regression_lagged: Variables suggested by other authors ------------------------
###Variables suggested by other authors
#m4_full_domestic_attacks_freedom_discussion
m4_full_domestic_attacks_freedom_discussion<-glm.nb(total_attacks ~
Freedom_expression_mean_media_censorship +
Alternative_sources_mean +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_expression_mean_discussion+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 100))
# TBL export: m4_full_domestic_attacks_freedom_discussion / domestic / expo
m4_full_domestic_attacks_freedom_discussion %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (freedom of discussion): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m4_full_domestic_attacks_freedom_discussion_expo.png")
# TBL merge: m4_full_domestic_attacks_freedom_discussion/ domestic / expo
m4_full_domestic_attacks_freedom_discussion_merge_expo <- m4_full_domestic_attacks_freedom_discussion %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m4_full_domestic_attacks_freedom_discussion / domestic / log
m4_full_domestic_attacks_freedom_discussion %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("****Test model (Freedom of discussion): Terrorist activity in western countries****"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m4_full_domestic_attacks_freedom_discussion_log.png")
# TBL merge: m4_full_domestic_attacks_freedom_discussion/ domestic / log
m4_full_domestic_attacks_freedom_discussion_merge_log <- m4_full_domestic_attacks_freedom_discussion %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#m5_full_domestic_attacks_physical_violence
m5_full_domestic_attacks_physical_violence<-glm.nb(total_attacks ~
Freedom_expression_mean_media_censorship +
Alternative_sources_mean +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Physical_violence_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m5_full_domestic_attacks_physical_violence / domestic / expo
m5_full_domestic_attacks_physical_violence %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Physical violence): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m5_full_domestic_attacks_physical_violence_expo.png")
# TBL merge: m5_full_domestic_attacks_physical_violence/ domestic / expo
m5_full_domestic_attacks_physical_violence_merge_expo <- m5_full_domestic_attacks_physical_violence %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m5_full_domestic_attacks_physical_violence / domestic / log
m5_full_domestic_attacks_physical_violence %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Physical violence): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m5_full_domestic_attacks_physical_violence_log.png")
# TBL merge: m5_full_domestic_attacks_physical_violence/ domestic / expo
m5_full_domestic_attacks_physical_violence_merge_log <- m5_full_domestic_attacks_physical_violence %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#m6_full_domestic_attacks_constraints_executive
m6_full_domestic_attacks_constraints_executive<-glm.nb(total_attacks ~
Freedom_expression_mean_media_censorship +
Alternative_sources_mean +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Constraints_executive_index_x10 +
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m6_full_domestic_attacks_constraints_executive/ domestic / expo
m6_full_domestic_attacks_constraints_executive %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Constraints executive): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m6_full_domestic_attacks_constraints_executive_expo.png")
# TBL merge: m6_full_domestic_attacks_constraints_executive/ domestic / expo
m6_full_domestic_attacks_constraints_executive_merge_expo <- m6_full_domestic_attacks_constraints_executive %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m6_full_domestic_attacks_constraints_executive/ domestic / log
m6_full_domestic_attacks_constraints_executive %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Constraints executive): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m6_full_domestic_attacks_constraints_executive_log.png")
# TBL merge: m6_full_domestic_attacks_constraints_executive/ domestic / log
m6_full_domestic_attacks_constraints_executive_merge_log <- m6_full_domestic_attacks_constraints_executive %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#m7_full_domestic_attacks_Polarization_society
m7_full_domestic_attacks_Polarization_society<-glm.nb(total_attacks ~
Freedom_expression_mean_media_censorship +
Alternative_sources_mean +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Polarization_society+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m7_full_domestic_attacks_Polarization_society / domestic / expo
m7_full_domestic_attacks_Polarization_society %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Polarization Society): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m7_full_domestic_attacks_Polarization_society_expo.png")
# TBL merge: m7_full_domestic_attacks_Polarization_society/ domestic / expo
m7_full_domestic_attacks_Polarization_society_merge_expo <- m7_full_domestic_attacks_Polarization_society %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m7_full_domestic_attacks_Polarization_society / domestic / log
m7_full_domestic_attacks_Polarization_society %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Polarization Society): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m7_full_domestic_attacks_Polarization_society_log.png")
# TBL merge: m7_full_domestic_attacks_Polarization_society/ domestic / log
m7_full_domestic_attacks_Polarization_society_merge_log <- m7_full_domestic_attacks_Polarization_society %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#m8_full_domestic_attacks_Civil_society_participation
m8_full_domestic_attacks_Civil_society_participation<-glm.nb(total_attacks ~
Freedom_expression_mean_media_censorship +
Alternative_sources_mean +
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Civil_society_participation_index_x10 +
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_domestic_renamed,
control = glm.control(maxit = 50))
# TBL export: m8_full_domestic_attacks_Civil_society_participation / domestic / expo
m8_full_domestic_attacks_Civil_society_participation %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Civil society participation): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m8_full_domestic_attacks_Civil_society_participation_expo.png")
# TBL merge: m8_full_domestic_attacks_Civil_society_participation/ domestic / expo
m8_full_domestic_attacks_Civil_society_participation_merge_expo <- m8_full_domestic_attacks_Civil_society_participation %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m8_full_domestic_attacks_Civil_society_participation / domestic / log
m8_full_domestic_attacks_Civil_society_participation %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test model (Civil society participation): Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/Domestic/Variables_other_authors/m8_full_domestic_attacks_Civil_society_participation_log.png")
# TBL merge: m8_full_domestic_attacks_Civil_society_participation/ domestic / log
m8_full_domestic_attacks_Civil_society_participation_merge_log <- m8_full_domestic_attacks_Civil_society_participation %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m4/m5/m6/m7/m8/ expo :
#PNG
tbl_merge(list(m4_full_domestic_attacks_freedom_discussion_merge_expo,
m5_full_domestic_attacks_physical_violence_merge_expo,
m6_full_domestic_attacks_constraints_executive_merge_expo,
m7_full_domestic_attacks_Polarization_society_merge_expo,
m8_full_domestic_attacks_Civil_society_participation_merge_expo),
tab_spanner = c("**Freedom of discussion**", "**Physical violence**","**Constraints executive**",
"**Polarization society**", "**Civil society participation**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test models: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m4_m5_m6_m7_m8_domestic_expo.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m4_full_domestic_attacks_freedom_discussion_merge_expo,
m5_full_domestic_attacks_physical_violence_merge_expo,
m6_full_domestic_attacks_constraints_executive_merge_expo,
m7_full_domestic_attacks_Polarization_society_merge_expo,
m8_full_domestic_attacks_Civil_society_participation_merge_expo),
tab_spanner = c("**Freedom of discussion**", "**Physical violence**","**Constraints executive**",
"**Polarization society**", "**Civil society participation**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test models: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m4_m5_m6_m7_m8_domestic_expo.html")
#Combined m4/m5/m6/m7/m8/ log :
#PNG
tbl_merge(list(m4_full_domestic_attacks_freedom_discussion_merge_log,
m5_full_domestic_attacks_physical_violence_merge_log,
m6_full_domestic_attacks_constraints_executive_merge_log,
m7_full_domestic_attacks_Polarization_society_merge_log,
m8_full_domestic_attacks_Civil_society_participation_merge_log),
tab_spanner = c("**Freedom of discussion**", "**Physical violence**","**Constraints executive**",
"**Polarization society**", "**Civil society participation**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test models: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m4_m5_m6_m7_m8_domestic_log.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m4_full_domestic_attacks_freedom_discussion_merge_log,
m5_full_domestic_attacks_physical_violence_merge_log,
m6_full_domestic_attacks_constraints_executive_merge_log,
m7_full_domestic_attacks_Polarization_society_merge_log,
m8_full_domestic_attacks_Civil_society_participation_merge_log),
tab_spanner = c("**Freedom of discussion**", "**Physical violence**","**Constraints executive**",
"**Polarization society**", "**Civil society participation**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Test models: Terrorist activity in western countries**"),
subtitle = gt::md("_Domestic attacks: (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m4_m5_m6_m7_m8_domestic_log.html")
#Stargazer with expo coefficients
#est_m1_full_all_attacks_x10 <- cbind(Estimate=coef(m1_full_all_attacks_x10), confint(m1_full_all_attacks_x10))
#exp_coefficients_m1_full_all_attacks_x10<- exp(est_m1_full_all_attacks_x10)
#stargazer(m1_full_all_attacks_x10,
# exp_coefficients_m1_full_all_attacks_x10,
# ci = TRUE,
# type = "text",
# title="Full model: Total attacks",dep.var.labels = "Total terrorist attacks",
# align=TRUE,
# out = "Regression_Tables/All_attacks/m1_full_all_attacks_x10.html")
Regression_lagged: Domestic/ All / International: (Full model broken
down)
# Regression_lagged: Domestic/ All / International: (Full model broken down) -------------------------------
# m1.2_full_all_broken_down
m1.2_full_all_broken_down <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_no_INTLOG_renamed,
control = glm.control(maxit = 50))
# TBL export: m1.2_full_all_broken_down_expo
m1.2_full_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model (broken down) :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1.2_full_all_broken_down_expo.png")
# TBL merge: m1.2_full_all_broken_down_merge_expo
m1.2_full_all_broken_down_merge_expo <- m1.2_full_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.2_full_all_broken_down_log
m1.2_full_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model (broken down) :Terrorist activity in western countries**"),
subtitle = gt::md("_All attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1.2_full_all_broken_down_log.png")
# TBL merge: m1.2_full_all_broken_down_merge_log
m1.2_full_all_broken_down_merge_log <- m1.2_full_all_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# m1.2_full_international_broken_down
m1.2_full_international_broken_down <-glm.nb(total_attacks ~
Government_censorship_Media+
Harassment_journalists+
Media_self_censorship+
Media_bias+
Media_critical+
Media_perspectives+
Defamation_protection +
Online_media_perspectives+
Online_media_existence+
Social_media_organize_violence+
Government_false_information+
Party_false_information+
Freedom_discussion_x10+
Physical_violence_index_x10+
Constraints_executive_index_x10+
Polarization_society+
Civil_society_participation_index_x10+
Average_years_education_citizens+
Population_millions,
data = total_INTLOG_international_renamed,
control = glm.control(maxit = 50))
# TBL export: m1.2_full_international_broken_down_expo
m1.2_full_international_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model (broken down) :Terrorist activity in western countries**"),
subtitle = gt::md("_International attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1.2_full_international_broken_down_expo.png")
# TBL merge: m1.2_full_international_broken_down_merge_expo
m1.2_full_international_broken_down_merge_expo <- m1.2_full_international_broken_down %>%
tbl_regression(label = NULL,
exponentiate = TRUE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
# TBL export: m1.2_full_international_broken_down_log
m1.2_full_international_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_glance_source_note(include = c(logLik)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p() %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Full model (broken down) :Terrorist activity in western countries**"),
subtitle = gt::md("_International attacks (2000-2019)_")) %>%
gt::tab_source_note("All independent and control variables lagged 1 year") %>%
gtsave("Regression_Tables/All_attacks/m1.2_full_international_broken_down_log.png")
# TBL merge: m1.2_full_international_broken_down_merge_log
m1.2_full_international_broken_down_merge_log <- m1.2_full_international_broken_down %>%
tbl_regression(label = NULL,
exponentiate = FALSE,
include = everything(),
show_single_row = NULL,
conf.level = NULL,
intercept = FALSE,
estimate_fun = NULL,
pvalue_fun = NULL,
tidy_fun = NULL,
add_estimate_to_reference_rows = TRUE,
conf.int = NULL) %>%
add_glance_table(include = c(AIC,BIC,deviance,null.deviance,nobs)) %>%
add_significance_stars(hide_ci = FALSE, hide_p = FALSE) %>%
bold_p()
#Combined m1.2_full_brokendown Domestic/International/All:
#PNG
tbl_merge(list(m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m1.2_full_all_broken_down_merge_expo,
m1.2_full_international_broken_down_merge_expo),
tab_spanner = c( "**Domestic attacks**","**All attacks**","**International attacks**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Full Model (broken down): (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1.2_full_domestic_all_international_brokendown_expo.png", vwidth = 2000, vheight = 1000)
#HTML
tbl_merge(list(m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m1.2_full_all_broken_down_merge_expo,
m1.2_full_international_broken_down_merge_expo),
tab_spanner = c( "**Domestic attacks**","**All attacks**","**International attacks**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Full Model (broken down): (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year") %>%
gtsave("Regression_Tables/combined/combined_m1.2_full_domestic_all_international_brokendown_expo.html")
#View for markdown:
tbl_merge(list(m1.2_full_domestic_freedom_expression_altsources_brokendown_merge_expo,
m1.2_full_all_broken_down_merge_expo,
m1.2_full_international_broken_down_merge_expo),
tab_spanner = c( "**Domestic attacks**","**All attacks**","**International attacks**")) %>%
as_gt() %>%
gt::tab_header(
title = gt::md("**Terrorist activity in western countries**"),
subtitle = gt::md("_Full Model (broken down): (2000-2019)_")) %>%
gt::tab_footnote(footnote = "All independent and control variables lagged by 1 year")
| Characteristic |
Domestic attacks
|
All attacks
|
International attacks
|
| IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
IRR |
SE |
95% CI |
p-value |
| Government_censorship_Media |
7.96*** |
0.380 |
3.52, 18.6 |
<0.001 |
2.82*** |
0.260 |
1.67, 4.84 |
<0.001 |
2.63* |
0.478 |
0.99, 7.03 |
0.043 |
| Harassment_journalists |
0.16*** |
0.479 |
0.06, 0.44 |
<0.001 |
1.29 |
0.241 |
0.81, 2.07 |
0.3 |
1.08 |
0.482 |
0.42, 2.83 |
0.9 |
| Media_self_censorship |
18.4*** |
0.512 |
6.24, 58.0 |
<0.001 |
1.04 |
0.248 |
0.61, 1.75 |
0.9 |
0.80 |
0.485 |
0.29, 2.21 |
0.6 |
| Media_bias |
0.59 |
0.354 |
0.28, 1.26 |
0.13 |
0.82 |
0.229 |
0.51, 1.32 |
0.4 |
1.23 |
0.457 |
0.51, 3.00 |
0.6 |
| Media_critical |
5.97*** |
0.405 |
2.75, 13.3 |
<0.001 |
4.55*** |
0.261 |
2.74, 7.60 |
<0.001 |
3.07* |
0.560 |
1.08, 9.28 |
0.045 |
| Media_perspectives |
1.52 |
0.390 |
0.65, 3.54 |
0.3 |
2.03** |
0.231 |
1.30, 3.17 |
0.002 |
4.46** |
0.552 |
1.56, 13.7 |
0.007 |
| Defamation_protection |
3.82** |
0.410 |
1.62, 9.06 |
0.001 |
0.98 |
0.186 |
0.67, 1.41 |
>0.9 |
1.10 |
0.462 |
0.41, 2.66 |
0.8 |
| Online_media_perspectives |
0.34* |
0.496 |
0.12, 0.93 |
0.031 |
0.54* |
0.266 |
0.31, 0.94 |
0.020 |
0.42 |
0.645 |
0.11, 1.46 |
0.2 |
| Online_media_existence |
0.55* |
0.237 |
0.34, 0.88 |
0.012 |
1.04 |
0.134 |
0.80, 1.34 |
0.8 |
0.81 |
0.298 |
0.45, 1.45 |
0.5 |
| Social_media_organize_violence |
4.28*** |
0.348 |
2.20, 9.67 |
<0.001 |
2.49*** |
0.130 |
1.91, 3.29 |
<0.001 |
2.57** |
0.344 |
1.35, 5.44 |
0.006 |
| Government_false_information |
3.04** |
0.354 |
1.40, 6.58 |
0.002 |
1.03 |
0.202 |
0.67, 1.59 |
0.9 |
0.70 |
0.369 |
0.32, 1.52 |
0.3 |
| Party_false_information |
0.26*** |
0.307 |
0.13, 0.46 |
<0.001 |
0.55*** |
0.162 |
0.40, 0.75 |
<0.001 |
0.62 |
0.403 |
0.26, 1.30 |
0.2 |
| Freedom_discussion_x10 |
0.60 |
0.771 |
0.11, 2.85 |
0.5 |
0.76 |
0.513 |
0.27, 2.02 |
0.6 |
0.44 |
0.859 |
0.09, 2.18 |
0.3 |
| Physical_violence_index_x10 |
0.91 |
0.546 |
0.29, 2.61 |
0.9 |
0.23** |
0.446 |
0.07, 0.68 |
0.001 |
0.43 |
0.814 |
0.08, 2.64 |
0.3 |
| Constraints_executive_index_x10 |
0.17*** |
0.404 |
0.07, 0.39 |
<0.001 |
0.42*** |
0.219 |
0.27, 0.66 |
<0.001 |
0.72 |
0.631 |
0.20, 2.51 |
0.6 |
| Polarization_society |
1.17 |
0.222 |
0.72, 1.89 |
0.5 |
1.55*** |
0.118 |
1.23, 1.96 |
<0.001 |
2.48*** |
0.240 |
1.56, 4.11 |
<0.001 |
| Civil_society_participation_index_x10 |
0.35* |
0.453 |
0.12, 0.99 |
0.020 |
1.61 |
0.282 |
0.87, 3.00 |
0.091 |
2.32 |
0.548 |
0.80, 6.95 |
0.12 |
| Average_years_education_citizens |
2.22*** |
0.172 |
1.56, 3.24 |
<0.001 |
1.67*** |
0.097 |
1.35, 2.08 |
<0.001 |
2.59*** |
0.259 |
1.61, 4.53 |
<0.001 |
| Population_millions |
1.02*** |
0.003 |
1.01, 1.02 |
<0.001 |
1.00* |
0.002 |
1.00, 1.01 |
0.024 |
0.99 |
0.004 |
0.98, 1.00 |
0.2 |
| AIC |
883 |
|
|
|
1,846 |
|
|
|
494 |
|
|
|
| BIC |
967 |
|
|
|
1,930 |
|
|
|
578 |
|
|
|
| Deviance |
222 |
|
|
|
410 |
|
|
|
196 |
|
|
|
| Null deviance |
881 |
|
|
|
1,072 |
|
|
|
452 |
|
|
|
| No. Obs. |
399 |
|
|
|
399 |
|
|
|
399 |
|
|
|
1) Effect plot: Full model and comparison by type of attack
# 1) Effect plot: Full model and comparison by type of attack --------
effect_plot_combined_m1_full<- plot_summs(m1_full_domestic_attacks,
m1_full_all_attacks,
m1_full_international_attacks,
m1_full_unknown_attacks,
exp = TRUE,
ci_level = 0.0,
model.names = c("Full model (Domestic)",
"Full model (All)",
"Full model (International)",
"Full model (Unknown)"))
#Export
export_effect_plot_combined_m1_full <- effect_plot_combined_m1_full+
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
#Ggsave
ggsave(plot = export_effect_plot_combined_m1_full,
filename = "Regression_Tables/Effectplots/1_export_effect_plot_combined_m1_full.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_combined_m1_full

2) Effect plot: Simplified versions_domestic
# 2) Effect plot: Simplified versions_domestic ------------------------------
effect_plot_combined_m1_m2_m3_domestic_expo<- plot_summs(m1_full_domestic_attacks,
m2_parsimonious_domestic,
m3_minimal_domestic,
exp = TRUE,
ci_level = 0.0,
model.names = c("Full model (domestic)",
"Parsimonious model (domestic)",
"Minimal model (domestic)"))
#Export
export_effect_plot_combined_m1_m2_m3_domestic_expo <- effect_plot_combined_m1_m2_m3_domestic_expo +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
#Ggsave
ggsave(plot = export_effect_plot_combined_m1_m2_m3_domestic_expo,
filename = "Regression_Tables/Effectplots/2_export_effect_plot_combined_m1_m2_m3_domestic_expo.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_combined_m1_m2_m3_domestic_expo

3) Effect plot: Simplified versions_all
# 3) Effect plot: Simplified versions_all ---------------------------------
all_combined_m1_m2_m3_domestic_expo<- plot_summs( m1_full_all_attacks,
m2_parsimonious_all,
m3_minimal_all,
exp = TRUE,
ci_level = 0.0,
model.names = c("Full model (all)",
"Parsimonious model (all)",
"Minimal model (all)"))
#Export
export_all_combined_m1_m2_m3_domestic_expo <- all_combined_m1_m2_m3_domestic_expo +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
#Ggsave
ggsave(plot = export_all_combined_m1_m2_m3_domestic_expo,
filename = "Regression_Tables/Effectplots/3_export_all_combined_m1_m2_m3_domestic_expo.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_all_combined_m1_m2_m3_domestic_expo

4) Effect plot: Versions of full model_domestic (in two separate
graphs)
# 4) Effect plot: Versions of full model_domestic (in two separate graphs) -------------------------
effect_plot_combined_m1_full_m1.1<- plot_summs(m1.1_full_domestic_free_exp_alt,
m1_full_domestic_attacks,
ci_level = 0.0,
exp = TRUE,
model.names = c("Full model 1.1 (domestic)",
"Full model (domestic)"))
#Export
export_effect_plot_combined_m1_full_m1.1 <- effect_plot_combined_m1_full_m1.1 +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
#Ggsave
ggsave(plot = export_effect_plot_combined_m1_full_m1.1,
filename = "Regression_Tables/Effectplots/4.1_export_effect_plot_combined_m1_full_m1.1.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
effect_plot_combined_m1.2.m1.3<- plot_summs(m1.3_full_domestic_mean_variables,
m1.2_full_domestic_freedom_expression_altsources_brokendown,
ci_level = 0.0,
exp = TRUE,
model.names = c("Full model 1.3 (domestic)",
"Full model 1.2 (domestic)"))
#Export
export_effect_plot_combined_m1.2.m1.3 <- effect_plot_combined_m1.2.m1.3 +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
#Ggsave
ggsave(plot = export_effect_plot_combined_m1.2.m1.3,
filename = "Regression_Tables/Effectplots/4.2_export_effect_plot_combined_m1.2.m1.3.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_combined_m1.2.m1.3

5) Effect plot: Versions of full model_all (in two separate
graphs)
# 5) Effect plot: Versions of full model_all (in two separate graphs) -----------------------------
effect_plot_all_combined_m1_full_m1.1<- plot_summs(m1.1_full_all_free_exp_alt,
m1_full_all_attacks,
ci_level = 0.0,
exp = TRUE,
model.names = c("Full model 1.1 (all)",
"Full model (all)"))
#Export
export_effect_plot_all_combined_m1_full_m1.1 <- effect_plot_all_combined_m1_full_m1.1 +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
#Ggsave
ggsave(plot = export_effect_plot_all_combined_m1_full_m1.1,
filename = "Regression_Tables/Effectplots/5.1_export_effect_plot_all_combined_m1_full_m1.1.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
effect_plot_all_combined_m1.2.m1.3<- plot_summs(m1.3_full_all_mean_variables,
m1.2_full_all_freedom_expression_altsources_brokendown,
ci_level = 0.0,
exp = TRUE,
model.names = c("Full model 1.3 (all)",
"Full model 1.2 (all)"))
#Export
export_effect_plot_all_combined_m1.2.m1.3 <- effect_plot_all_combined_m1.2.m1.3 +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
#Ggsave
ggsave(plot = export_effect_plot_all_combined_m1.2.m1.3,
filename = "Regression_Tables/Effectplots/5.2_export_effect_plot_all_combined_m1.2.m1.3.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_all_combined_m1.2.m1.3

6) Effect plot: Broken_down_domestic
# 6) Effect plot: Broken_down_domestic ------------------------------------
effect_plot_combined_m1_m2_m3_domestic_broken_down_expo<- plot_summs(m1.2_full_domestic_freedom_expression_altsources_brokendown,
m2_parsimonious_domestic_broken_down,
m3_minimal_domestic_broken_down,
ci_level = 0.0,
exp = TRUE,
model.names = c("Full model broken down (domestic)",
"Parsimonious model broken down (domestic)",
"Minimal model (domestic)"))
#Export
export_effect_plot_combined_m1_m2_m3_domestic_broken_down_expo <- effect_plot_combined_m1_m2_m3_domestic_broken_down_expo +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
ggsave(plot = export_effect_plot_combined_m1_m2_m3_domestic_broken_down_expo,
filename = "Regression_Tables/Effectplots/6_export_effect_plot_combined_m1_m2_m3_domestic_broken_down_expo.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_combined_m1_m2_m3_domestic_broken_down_expo

7) Effect plot: Broken_down_all
# 7) Effect plot: Broken_down_all -----------------------------------------
effect_plot_all_combined_m1_m2_m3_domestic_broken_down_expo<- plot_summs(m1.2_full_all_freedom_expression_altsources_brokendown,
m2_parsimonious_all_broken_down,
m3_minimal_all_broken_down,
ci_level = 0.0,
exp = TRUE,
model.names = c("Full model broken down (all)",
"Parsimonious model broken down (all)",
"Minimal model (all)"))
#Export
export_effect_plot_all_combined_m1_m2_m3_domestic_broken_down_expo <- effect_plot_all_combined_m1_m2_m3_domestic_broken_down_expo +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
ggsave(plot = export_effect_plot_all_combined_m1_m2_m3_domestic_broken_down_expo,
filename = "Regression_Tables/Effectplots/7_export_effect_plot_all_combined_m1_m2_m3_domestic_broken_down_expo.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_all_combined_m1_m2_m3_domestic_broken_down_expo

8) Effect plot: Online & offline models_domestic
# 8) Effect plot: Online & offline models_domestic ------------------------
effect_plot_combined_m1_offline_m1_online_expo <- plot_summs(m1_offline_brokendown,
m1_online_brokendown,
exp = TRUE,
ci_level = 0.0,
model.names = c("Offline model (domestic)",
"Online model (domestic)"))
#Export
export_effect_plot_combined_m1_offline_m1_online_expo <- effect_plot_combined_m1_offline_m1_online_expo +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
ggsave(plot = export_effect_plot_combined_m1_offline_m1_online_expo,
filename = "Regression_Tables/Effectplots/8_export_effect_plot_combined_m1_offline_m1_online_expo.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_combined_m1_offline_m1_online_expo

11) Effect plot: Domestic/ All / International: (Full model broken
down)
# 11) Effect plot: Domestic/ All / International: (Full model broken down)------------------------
effect_plot_combined_m1.2_full_domestic_all_international_brokendown_expo <- plot_summs(m1.2_full_domestic_freedom_expression_altsources_brokendown,
m1.2_full_all_broken_down,
m1.2_full_international_broken_down,
exp = TRUE,
ci_level = 0.0,
model.names = c("Full model (domestic)",
"Full model (all)",
"Full model (international)"))
#Export
export_effect_plot_combined_m1.2_full_domestic_all_international_brokendown_expo <- effect_plot_combined_m1.2_full_domestic_all_international_brokendown_expo +
labs(title="Terrorist attacks: negative binomial regression",
subtitle= "Model comparison",
x="exp(coefficients)")
ggsave(plot = export_effect_plot_combined_m1.2_full_domestic_all_international_brokendown_expo,
filename = "Regression_Tables/Effectplots/11_export_effect_plot_combined_m1.2_full_domestic_all_international_brokendown_expo.png",
width = 11, height = 7,
type= "cairo",
dpi = "retina")
#visualize for markdown:
export_effect_plot_combined_m1.2_full_domestic_all_international_brokendown_expo
