Untitled
unknown
plain_text
a month ago
2.5 kB
8
Indexable
Never
#Post WWI (1900-1920) democracy_counts_1900_1920 <- vdem |> filter(year >= 1900, year <= 1920, e_boix_regime == 1) |> group_by(year) |> summarise(num_democracies = n()) ggplot(data = democracy_counts_1900_1920, aes(x = year, y = num_democracies)) + geom_line() + labs(x = "Año", y = "Número de Democracias", title = "Evolución del Número de Democracias (1900-1920)") #Collapse USSR (1986-1994) democracy_counts_1986_1994 <- vdem |> filter(year >= 1986, year <= 1994, e_boix_regime == 1) |> group_by(year) |> summarise(num_democracies = n()) ggplot(data = democracy_counts_1986_1994, aes(x = year, y = num_democracies)) + geom_line() + labs(x = "Año", y = "Número de Democracias", title = "Evolución del Número de Democracias (1900-1920)") #To generate a regression coefficient it is first necessary to create a new #variable with 20-year-periods from 1860 to 1879 for both variables. vdem <- vdem |> mutate(period = cut(year, breaks = seq(1859, max(year), by = 20), labels = FALSE)) #Once we have the variable, we can run a regression for each of those periods: reg11 <- vdem |> group_by(period) |> summarise( coefficient = coef(lm(e_migdppcln ~ v2x_polyarchy))[2], period_start = min(year), period_end = max(year) ) reg12 <- vdem |> group_by(period) |> summarise( coefficient = coef(lm(v2x_polyarchy ~ e_migdppcln))[2], period_start = min(year), period_end = max(year) ) print(reg11) print(reg12) ggplot(data = reg11, aes(x = period_start, y = coefficient)) + geom_line() + labs( x = "Start Year of Period", y = "Coefficient", title = "Evolution of Coefficients Over Time (Regression 1.1)" ) ggplot(data = reg12, aes(x = period_start, y = coefficient)) + geom_line() + labs( x = "Start Year of Period", y = "Coefficient", title = "Evolution of Coefficients Over Time (Regression 1.2)" ) reg21 <- vdem |> group_by(e_regionpol_6C) |> do(model = lm(e_migdppcln ~ v2x_polyarchy, data = .)) |> summarise( region = e_regionpol_6C, coefficient = coef(model)[2], r_squared = summary(model)$r.squared ) print(reg21) region_names <- c("E. Europe/C. Asia", "Latin America", "Middle East", "Sub-Saharan Africa", "Europe/America", "Asia & Pacific") ggplot(reg21, aes(x = factor(region, levels = 1:6, labels = region_names), y = coefficient)) + geom_bar(stat = "identity") + labs(x = "Region", y = "Coefficient") + ggtitle("Corr. Coefficient (reg21) by Region")