Còdis del mòdul

En aquest apartat hi podeu trobar els codis del mòdul 4 Indicadors Polítics.

Democràcia

Per realitzar les activitats d’aquest mòdul, carregueu d’inici els següents paquets:

library(tidyverse)
library(readxl)
library(foreign)
library(countrycode)
devtools::install_github("vdeminstitute/vdemdata")
library(vdemdata)

1. Democràcia minimalista

1.2 Mesures dicotòmiques

tibble(Country = c("Francia", "Sudáfrica", "Unión Soviética", "Arabia Saudí"),
       Year = c(1985, 1985, 1985, 1985),
       Contestation = c(1, 1, 0, 0),
       Inclusion = c(1, 0, 1, 0),
       Democracy = Contestation & Inclusion)%>%
  View()

1.3 Mesures contínues

Polity, DD y DCD

#DD dataset
dd <- as_tibble(read.dta("https://uofi.box.com/shared/static/bba3968d7c3397c024ec.dta"))

#DCD dataset
dcd <- read_csv("https://sites.google.com/site/mkmtwo/democracy-v3.0.csv?attredirects=0")

#Polity V dataset
download.file("http://www.systemicpeace.org/inscr/p5v2018.xls", "p5v2018.xls")
polity <- read_xls("p5v2018.xls")

2. Democràcia substantiva

tibble(N = c("A","B", "C", "D"),
              Contestation = c(10, 1, 10, 7),
              Inclusion = c(10, 9, 3, 6),
              Freedoms = c(5, 8, 4, 6),
              Direct = c(4, 5, 8, 7),
              Equality = c(4, 10, 8, 7),
              Democracy = c(Contestation + Inclusion + Freedoms + Direct + Equality)/5)%>%
  View()

2.2 Freedom House

fiw <- read_xlsx("All_data_FIW_2013-2021.xlsx", sheet = 2, skip = 1)

2.3 Varieties of democracy

devtools::install_github("vdeminstitute/vdemdata") 
library(vdemdata)

plot_indicator("v2x_libdem", "Bolivia", min_year = 1975, max_year = 2020)

Gobernança

En aquest apartat, necessitarem els següents paquets:

library(tidyverse)
library(devtools)
install_github("ropengov/rqog") 
library(rqog)

1. Bona governança

1.3 European Quality of Government Index

library(devtools)
install_github("ropengov/rqog")
library(rqog)

qog_basic <- read_qog(which_data = "basic") %>%
  tibble()

Preferències polítiques

En aquest apartat, necessitarem els següents paquets:

library(tidyverse)
library(manifestoR)

2. Partits polítics

2.2 Anàlisi de programes electorals

Comparative Party Manifesto (CPM)

library(manifestoR)

mp_setapikey("manifesto_apikey.txt") #busca el perfil d'usuari
cpm <- mp_maindataset()
mp_describe_code("107")

cpm %>%
  mutate(edate = as.Date(edate, "%d/%m/%Y")) %>%
  filter(countryname == "Sweden") %>% filter(edate == last(edate)) %>%
  arrange(desc(date)) %>%
  select(Partit = partyname, Data = edate, Internacionalisme = per107)

2.3 Enquestes a experts

Global Party Survey

tibble(x) %>%
  filter(Country %in% c("Angola", "Chad", "El Salvador", "United Kingdom")) %>%
  mutate(Country = countrycode(ISO, "iso3c", "cldr.name.ca")) %>%
  count(Country, Experts)%>%
  View()
Previous