Skip to contents

create_dyadyears() allows you to dyad-year data from either the Correlates of War (CoW) state system membership data or the Gleditsch-Ward (gw) system membership data. The function leans on state system data available in isard.

Usage

create_dyadyears(system = "cow", mry = TRUE, directed = TRUE, subset_years)

Arguments

system

a character specifying whether the user wants Correlates of War state-years ("cow") or Gleditsch-Ward ("gw") state-years. Correlates of War is the default.

mry

optional, defaults to TRUE. If TRUE, the function extends the script beyond the most recent system membership updates to include observation to the most recently concluded calendar year. For example, the Gleditsch-Ward data extend to the end of 2020. When mry == TRUE, the function returns more recent years (e.g. 2018, 2019) under the assumption that states alive at the end of 2016 or 2020 are still alive today. Use with some care.

directed

optional, defaults to TRUE. If TRUE, the function returns so-called "directed" dyad-year data. In directed dyad-year data, France-Germany (220-255) and Germany-France (255-220) are observationally different. If FALSE, the function returns non-directed data. In non-directed data, France-Germany and Germany-France in the same year are the same observation. The standard here is to drop cases where the country code for the second observation is less than the country code for the first observation.

subset_years

and optional character vector for subsetting the years returned to just some temporal domain of interest to the user. For example, c(1816:1820) would subset the data to just all dyad-years in 1816, 1817, 1818, 1819, and 1820. Be advised that it's easiest to subset the data after the full universe of dyad-year data have been created. This means you could, if you choose, effectively overwrite mry = TRUE with this argument since the mry argument is applied at the expansion of the state system data, which occurs at the start of the function.

Value

create_dyadyears() takes state system membership data provided by either Correlates of War or Gleditsch-Ward and returns a dyad-year data frame with one observation for each dyad-year.

Details

The function leans on data made available in the isard package.

Underneath the hood, the function removes dyads that existed in the same year, but not on any given day in the same year. For example, Suriname enters the Correlates of War state system on Nov. 25, 1975, but the Republic of Vietnam was eliminated from the state system on April 30 of the same year.

Dyad-year data for the Gleditsch-Ward system will also include dyadic indicators communicating whether the first state or second state is a microstate. You may not want these and you can always remove them after the fact.

References

Miller, Steven V. 2019. “Create Country-Year and (Non)-Directed Dyad-Year Data With Just a Few Lines in R” https://svmiller.com/blog/2019/01/create-country-year-dyad-year-from-country-data/

Miller, Steven V. 2025. isard: Overflow Data for Quantitative Peace Science Research. https://CRAN.R-project.org/package=isard

Author

Steven V. Miller

Examples

# \donttest{
# CoW is default, will include years beyond 2016 (most recent CoW update)
create_dyadyears()
#> Joining with `by = join_by(ccode1, ccode2, year)`
#> # A tibble: 2,214,930 × 3
#>    ccode1 ccode2  year
#>     <dbl>  <dbl> <int>
#>  1      2     20  1920
#>  2      2     20  1921
#>  3      2     20  1922
#>  4      2     20  1923
#>  5      2     20  1924
#>  6      2     20  1925
#>  7      2     20  1926
#>  8      2     20  1927
#>  9      2     20  1928
#> 10      2     20  1929
#> # ℹ 2,214,920 more rows

# Gleditsch-Ward, include most recent years
create_dyadyears(system="gw")
#> Joining with `by = join_by(gwcode1, gwcode2, year, microstate1, microstate2)`
#> # A tibble: 2,599,466 × 5
#>    gwcode1 gwcode2  year microstate1 microstate2
#>      <dbl>   <dbl> <int>       <dbl>       <dbl>
#>  1       2      20  1867           0           0
#>  2       2      20  1868           0           0
#>  3       2      20  1869           0           0
#>  4       2      20  1870           0           0
#>  5       2      20  1871           0           0
#>  6       2      20  1872           0           0
#>  7       2      20  1873           0           0
#>  8       2      20  1874           0           0
#>  9       2      20  1875           0           0
#> 10       2      20  1876           0           0
#> # ℹ 2,599,456 more rows

# Gleditsch-Ward, don't include most recent years
create_dyadyears(system="gw", mry=FALSE)
#> Joining with `by = join_by(gwcode1, gwcode2, year, microstate1, microstate2)`
#> # A tibble: 2,445,018 × 5
#>    gwcode1 gwcode2  year microstate1 microstate2
#>      <dbl>   <dbl> <int>       <dbl>       <dbl>
#>  1       2      20  1867           0           0
#>  2       2      20  1868           0           0
#>  3       2      20  1869           0           0
#>  4       2      20  1870           0           0
#>  5       2      20  1871           0           0
#>  6       2      20  1872           0           0
#>  7       2      20  1873           0           0
#>  8       2      20  1874           0           0
#>  9       2      20  1875           0           0
#> 10       2      20  1876           0           0
#> # ℹ 2,445,008 more rows

# Gleditsch-Ward, don't include most recent years, directed = FALSE
create_dyadyears(system="gw", mry=FALSE, directed = FALSE)
#> Joining with `by = join_by(gwcode1, gwcode2, year, microstate1, microstate2)`
#> # A tibble: 1,222,509 × 5
#>    gwcode1 gwcode2  year microstate1 microstate2
#>      <dbl>   <dbl> <int>       <dbl>       <dbl>
#>  1       2      20  1867           0           0
#>  2       2      20  1868           0           0
#>  3       2      20  1869           0           0
#>  4       2      20  1870           0           0
#>  5       2      20  1871           0           0
#>  6       2      20  1872           0           0
#>  7       2      20  1873           0           0
#>  8       2      20  1874           0           0
#>  9       2      20  1875           0           0
#> 10       2      20  1876           0           0
#> # ℹ 1,222,499 more rows
# }