Skip to contents

add_democracy() allows you to add estimates of democracy to your data.

Usage

add_democracy(data, keep)

Arguments

data

a data frame with appropriate peacesciencer attributes

keep

an optional parameter, specified as a character vector, about what democracy estimates the user wants to return from this function. If not specified, everything from the underlying democracy data is returned.

Value

add_democracy() takes a (dyad-year, leader-year, leader-dyad-year, state-year) data frame and adds information about the level of democracy for the state or two states in the dyad in a given year. If the data are dyad-year or leader-dyad-year, the function adds six total columns for the first state (i.e. ccode1 or gwcode1) and the second state (i.e. ccode2 or gwcode2) about the level of democracy measured by the Varieties of Democracy project (v2x_polyarchy), the Polity project (polity2), and Xavier Marquez' QuickUDS extensions/estimates. If the data are state-year or leader-year, the function returns three additional columns to the original data that contain that same information for a given state in a given year.

Details

As of version 1.2, this function leans on the information made available in the isard package. This is a spin-off package I maintain for data that require periodic updates for the functionality in this package. As of writing, peacesciencer only requires that you have the isard package installed. It does not require you to have any particular version of the package installed. Thus, what exactly this function returns may depend on the particular version of isard you have installed. This will assuredly concern the right-bound of the temporal domain of data you get.

You can read more about the data in the documentation for isard.

Be mindful that the data are fundamentally state-year and that extensions to leader-level data should be understood as approximations for leaders in a given state-year.

included in the cw_democracy or gw_democracy data in the isard data. Otherwise, it will return an error that it cannot subset columns that do not exist.

A vignette on the package's website talks about how these data are here primarily to encourage you to maximize the number of observations in the analysis to follow. Xavier Marquez' QuickUDS estimates have the best coverage. If democracy is ultimately a control variable, or otherwise a variable not of huge concern for the analysis (i.e. the user has no particular stake on the best measurement of democracy or the best conceptualization and operationalization of "democracy"), please use Marquez' estimates instead of Polity or V-dem. If the user is doing an analysis of inter-state conflict, and across the standard post-1816 domain in conflict studies, definitely don't use the Polity data because the extent of its missingness is both large and unnecessary. Please read the vignette describing these issues here: http://svmiller.com/peacesciencer/articles/democracy.html

References

Please cite Miller (2022) for peacesciencer. Beyond that, consult the documentation in isard for additional citations (contingent on which democracy estimate you are using).

Author

Steven V. Miller

Examples


# just call `library(tidyverse)` at the top of the your script
library(magrittr)

cow_ddy %>% add_democracy()
#> # A tibble: 2,214,930 × 11
#>    ccode1 ccode2  year euds1 aeuds1 polity21 v2x_polyarchy1 euds2 aeuds2
#>     <dbl>  <dbl> <dbl> <dbl>  <dbl>    <dbl>          <dbl> <dbl>  <dbl>
#>  1      2     20  1920  1.20  0.396        9          0.514  1.08  0.272
#>  2      2     20  1921  1.20  0.396        9          0.51   1.44  0.635
#>  3      2     20  1922  1.21  0.403        9          0.513  1.47  0.658
#>  4      2     20  1923  1.21  0.403        9          0.527  1.47  0.658
#>  5      2     20  1924  1.22  0.415        9          0.527  1.47  0.658
#>  6      2     20  1925  1.22  0.415        9          0.526  1.44  0.635
#>  7      2     20  1926  1.22  0.415        9          0.529  1.44  0.635
#>  8      2     20  1927  1.22  0.415        9          0.53   1.44  0.635
#>  9      2     20  1928  1.27  0.465        9          0.53   1.44  0.635
#> 10      2     20  1929  1.27  0.465        9          0.53   1.44  0.635
#> # ℹ 2,214,920 more rows
#> # ℹ 2 more variables: polity22 <dbl>, v2x_polyarchy2 <dbl>

create_stateyears(system="gw") %>% add_democracy()
#> Joining with `by = join_by(gwcode, year)`
#> # A tibble: 20,652 × 8
#>    gwcode gw_name          microstate  year  euds    aeuds polity2 v2x_polyarchy
#>     <dbl> <chr>                 <dbl> <dbl> <dbl>    <dbl>   <dbl>         <dbl>
#>  1      2 United States o…          0  1816 0.803 -0.00435       6         0.359
#>  2      2 United States o…          0  1817 0.803 -0.00435       6         0.357
#>  3      2 United States o…          0  1818 0.803 -0.00435       6         0.359
#>  4      2 United States o…          0  1819 0.803 -0.00435       6         0.359
#>  5      2 United States o…          0  1820 0.803 -0.00435       6         0.354
#>  6      2 United States o…          0  1821 0.803 -0.00435       6         0.349
#>  7      2 United States o…          0  1822 0.803 -0.00435       6         0.349
#>  8      2 United States o…          0  1823 0.803 -0.00435       6         0.348
#>  9      2 United States o…          0  1824 0.803 -0.00435       6         0.348
#> 10      2 United States o…          0  1825 0.811  0.00331       7         0.348
#> # ℹ 20,642 more rows
create_stateyears(system="cow") %>% add_democracy()
#> Joining with `by = join_by(ccode, year)`
#> # A tibble: 17,511 × 7
#>    ccode cw_name                   year  euds    aeuds polity2 v2x_polyarchy
#>    <dbl> <chr>                    <dbl> <dbl>    <dbl>   <dbl>         <dbl>
#>  1     2 United States of America  1816 0.803 -0.00435       6         0.359
#>  2     2 United States of America  1817 0.803 -0.00435       6         0.357
#>  3     2 United States of America  1818 0.803 -0.00435       6         0.359
#>  4     2 United States of America  1819 0.803 -0.00435       6         0.359
#>  5     2 United States of America  1820 0.803 -0.00435       6         0.354
#>  6     2 United States of America  1821 0.803 -0.00435       6         0.349
#>  7     2 United States of America  1822 0.803 -0.00435       6         0.349
#>  8     2 United States of America  1823 0.803 -0.00435       6         0.348
#>  9     2 United States of America  1824 0.803 -0.00435       6         0.348
#> 10     2 United States of America  1825 0.811  0.00331       7         0.348
#> # ℹ 17,501 more rows