Learn R Programming

peacesciencer: Tools and Data for Quantitative Peace Science

peacesciencer is an R package including various functions and data sets to allow easier analyses in the field of quantitative peace science. The goal is to provide an R package that reasonably approximates what made EUGene so attractive to scholars working in the field of quantitative peace science in the early 2000s. EUGene shined because it encouraged replications of conflict models while having the user also generate data from scratch. Likewise, this R package will offer tools to approximate what EUGene did within the R environment (i.e. not requiring Windows for installation).

Installation

You can install this on CRAN, as follows:

install.packages("peacesciencer")

You can install the development version of this package through the devtools package. The development version of the package invariably has more goodies, but may or may not be at various levels of stress-testing.

devtools::install_github("svmiller/peacesciencer")

How to Use {peacesciencer}

New users should read two things to get started. The package’s website has an exhaustive list and description of all the functions and data included in the package. {peacesciencer} has a user’s guide that is worth reading. The user’s guide points to its potential uses and benefits while also offering some encouragement for those completely new to the R programming language. The package is designed to be accessible to those with no prior experience with R, though completely new users who feel lost or overwhelmed should learn about the “tidy” approach to R to help them get started.

The workflow is going to look something like this. First, start with one of two processes to create either dyad-year or state-year data. The dyad-year data are created with the create_dyadyears() function. It has a few optional parameters with hidden defaults. The user can specify what kind of state system (system) data they want to use—either Correlates of War ("cow") or Gleditsch-Ward ("gw"), whether they want to extend the data to the most recently concluded calendar year (mry) (i.e. Correlates of War state system membership data are current as of Dec. 31, 2016 and the script can extend that to the end of the most recently concluded calendar year), and whether the user wants directed or non-directed dyad-year data (directed).

The create_stateyears() works much the same way, though “directed” and “non-directed” make no sense in the state-year context. Both functions default to Correlates of War state system membership data to the most recently concluded calendar year.

Thereafter, the user can specify what additional variables they want added to these dyad-year or state-year data. Do note: the additional functions lean primarily on Correlates of War state code identifiers. Indeed, the bulk of the quantitative peace science data ecosystem is built around the Correlates of War project. The variables the user wants are added in a “pipe” in a process like this. Do note that the user may want to break up the data-generating process into a few manageable “chunks” (e.g. first generating dyad-year data and saving to an object, adding to it piece by piece).

Citing What You Do in {peacesciencer}

You can (and should) cite what you do in {peacesciencer}. The package includes a data frame of a BibTeX file (ps_bib) and a function for finding and returning BibTeX entries that you can include in your projects. This is the ps_cite() function. The ps_cite() function takes a string and does a partial match for relevant keywords (as KEYWORDS) associated with entries in the ps_bib file. For example, you can (and should) cite the package itself.

ps_cite("peacesciencer")
#> @ARTICLE{peacesciencer-package,
#>   AUTHOR = {Steven V. Miller},
#>   JOURNAL = {Conflict Management and Peace Science},
#>   TITLE = {peacesciencer}: An R Package for Quantitative Peace Science Research},
#>   YEAR = {2022},
#>   KEYWORDS = {peacesciencer, add_capital_distance(), add_ccode_to_gw(), add_gwcode_to_cow(), capitals},
#>   URL = {http://svmiller.com/peacesciencer/}}

You can see what are the relevant citations to consider using for the data returned by add_democracy()

ps_cite("add_democracy()")
#> @UNPUBLISHED{coppedgeetal2020vdem,
#>   AUTHOR = {Michael Coppedge and John Gerring and Carl Henrik Knutsen and Staffan I. Lindberg and Jan Teorell and David Altman and Michael Bernhard and M. Steven Fish and Adam Glynn and Allen Hicken and Anna Luhrmann and Kyle L. Marquardt and Kelly McMann and Pamela Paxton and Daniel Pemstein and Brigitte Seim and Rachel Sigman and Svend-Erik Skaaning and Jeffrey Staton and Agnes Cornell and Lisa Gastaldi and Haakon Gjerl{\o}w and Valeriya Mechkova and Johannes von R{\"o}mer and Aksel Sundtr{\"o}m and Eitan Tzelgov and Luca Uberti and Yi-ting Wang and Tore Wig and Daniel Ziblatt},
#>   NOTE = {Varieties of Democracy ({V}-{D}em) Project},
#>   TITLE = {V-Dem Codebook v10},
#>   YEAR = {2020},
#>   KEYWORDS = {add_democracy(), v-dem, varieties of democracy}} 
#> 
#> @UNPUBLISHED{marquez2016qme,
#>   AUTHOR = {Xavier Marquez},
#>   NOTE = {Available at SSRN: http://ssrn.com/abstract=2753830},
#>   TITLE = {A Quick Method for Extending the {U}nified {D}emocracy {S}cores},
#>   YEAR = {2016},
#>   KEYWORDS = {add_democracy(), UDS, Unified Democracy Scores},
#>   URL = {http://dx.doi.org/10.2139/ssrn.2753830}} 
#> 
#> @UNPUBLISHED{marshalletal2017p,
#>   AUTHOR = {Monty G. Marshall and Ted Robert Gurr and Keith Jaggers},
#>   NOTE = {University of Maryland, Center for International Development and Conflict Management},
#>   TITLE = {Polity {IV} Project: Political Regime Characteristics and Transitions, 1800-2016},
#>   YEAR = {2017},
#>   KEYWORDS = {add_democracy(), polity}} 
#> 
#> @ARTICLE{pemsteinetal2010dc,
#>   AUTHOR = {Pemstein, Daniel and Stephen A. Meserve and James Melton},
#>   JOURNAL = {Political Analysis},
#>   NUMBER = {4},
#>   PAGES = {426--449},
#>   TITLE = {Democratic Compromise: A Latent Variable Analysis of Ten Measures of Regime Type},
#>   VOLUME = {18},
#>   YEAR = {2010},
#>   KEYWORDS = {add_democracy(), UDS, Unified Democracy Scores},
#>   OWNER = {steve},
#>   TIMESTAMP = {2011.01.30}}

You can also return partial matches to see what citations are associated with, say, alliance data in this package.

ps_cite("alliance")
#> @BOOK{gibler2009ima,
#>   AUTHOR = {Douglas M. Gibler},
#>   PUBLISHER = {Washington DC: CQ Press},
#>   TITLE = {International Military Alliances, 1648-2008},
#>   YEAR = {2009},
#>   KEYWORDS = {add_cow_alliance()}} 
#> 
#> @ARTICLE{leedsetal2002atop,
#>   AUTHOR = {Bretty Ashley Leeds and Jeffrey M. Ritter and Sara McLaughlin Mitchell and Andrew G. Long},
#>   JOURNAL = {International Interactions},
#>   PAGES = {237--260},
#>   TITLE = {Alliance Treaty Obligations and Provisions, 1815-1944},
#>   VOLUME = {28},
#>   YEAR = {2002},
#>   KEYWORDS = {add_atop_alliance()}}

This function might expand in complexity in future releases, but you can use it right now for finding appropriate citations. You an also scan the ps_bib data to see what is in there.

Issues/Requests

{peacesciencer} is already more than capable to meet a wide variety of needs in the peace science community. Users are free to raise an issue on the project’s Github if some feature is not performing as they think it should or if there are additions they would like to see.

Copy Link

Version

Install

install.packages('peacesciencer')

Monthly Downloads

362

Version

1.2.0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Steven Miller

Last Published

July 17th, 2025

Functions in peacesciencer (1.2.0)

add_creg_fractionalization

Add fractionalization/polarization estimates from CREG to a data frame
add_igos

Add Correlates of War international governmental organizations (IGOs) data to dyad-year or state-year data.
add_gml_mids

Add Gibler-Miller-Little (GML) Militarized Interstate Dispute (MID) data to a data frame
add_democracy

Add democracy information to a data frame
add_latent_territorial_threat

Add estimated latent territorial threat to a data frame
add_spells

Add "Spells" to Data
add_lwuf

Add Estimates of Leader Willingness to Use Force to Leader-Year Data
add_strategic_rivalries

Add Thompson et al. (2021) strategic rivalry data to state-year or dyad-year data frame
add_nmc

Add Correlates of War National Military Capabilities Data
add_minimum_distance

Add minimum distance data to your data frame
add_sdp_gdp

Add (Surplus and Gross) Domestic Product Data (DEPRECATED)
add_sim_gdp_pop

Add Simulated GDP, Population, and GDP per Capita Data
cow_majors

Correlates of War Major Powers Data (1816-2016)
cow_mid_ddydisps

Directed Dyadic Dispute-Year Data with No Duplicate Dyad-Years (CoW-MID, v. 5.0)
archigos

Archigos: A (Subset of a) Dataset on Political Leaders
archigossums

Archigos Yearly Leader Turnover: A Summary
add_peace_years

Add Peace Years to Your Conflict Data
add_rugged_terrain

Add rugged terrain information to a data frame
atop_alliance

Alliance Treaty Obligations and Provisions (ATOP) Project Data (v. 5.1)
cow_capitals

A complete list of capitals and capital transitions for Correlates of War state system members
add_ucdp_acd

Add UCDP Armed Conflict Data to state-year data frame
add_ucdp_onsets

Add UCDP onsets to state-year data
cow_igo_ndy

Correlates of War Non-Directed Dyad-Year International Governmental Organizations (IGOs) Data
cow_igo_sy

Correlates of War State-Year International Governmental Organizations (IGOs) Data
cow_states

Correlates of War State System Membership Data (1816-2016)
cow_ddy

A directed dyad-year data frame of Correlates of War state system members
cow_contdir

Correlates of War Direct Contiguity Data (v. 3.2)
create_dyadyears

Create dyad-years from state system membership data
cow_war_intra

Correlates of War Intra-State War Data (v. 4.1)
cow_war_inter

Correlates of War Inter-State War Data (v. 4.0)
cow_trade_sy

Correlates of War National Trade Data Set (v. 4.0)
cow_mid_dirdisps

Directed Dyadic Dispute-Year Data (CoW-MID, v. 5.0)
cow_mid_disps

Abbreviated CoW-MID Dispute-level Data (v. 5.0)
declare_attributes

Declare peacesciencer-specific attributes to data
create_leaderdyadyears

Create leader-dyad-years from the Archigos data
create_leaderdays

Create leader-days from leader data
create_leaderyears

Create leader-years from leader data
creg

Composition of Religious and Ethnic Groups (CREG) Fractionalization/Polarization Estimates
create_stateyears

Create state-years from state system membership data
create_statedays

Create state-days from state system membership data
data-deprecated

Data sets that have been deprecated
false_gw_dyads

False Gleditsch-Ward Directed Dyad-Years
false_cow_dyads

False Correlates of War Directed Dyad-Years
cow_mindist

The Minimum Distance Between States in the Correlates of War System, 1886-2019
cow_nmc

Correlates of War National Military Capabilities Data
download_extdata

Download Some Extra Data for Peace Science Research
gml_mid_dirleaderdisps

Directed Leader-Dyadic Dispute-Year Data (GML, v. 2.2.1, Archigos v. 4.1)
gml_mid_disps

Abbreviated GML MID Dispute-level Data (v. 2.2.1)
grh_arms_races

Conventional Arms Races During Periods of Rivalry
gml_part

Participant Summaries of the GML-MID Data
filter_prd

Filter dyad-year data to include just politically relevant dyads
gml_mid_ddlydisps

Directed Leader-Dyadic Dispute-Year Data with No Duplicate Leader-Dyad-Years (GML, v. 2.2.1, Archigos v. 4.1)
gml_mid_ddydisps

Directed Dyadic Dispute-Year Data with No Duplicate Dyad-Years (GML, v. 2.2.1)
hief

Historical Index of Ethnic Fractionalization data
gw_mindist

The Minimum Distance Between States in the Gleditsch-Ward System, 1886-2019
ps_data_version

The Version Numbers for Data Included in peacesciencer
ps_cite

Get BibTeX Entries Associated with peacesciencer Data and Functions
ps_bib

A BibTeX Data Frame of Citations
gml_dirdisp

Directed dispute-year data (Gibler, Miller, and Little, 2016)
leader_codes

A Data Set of Leader Codes Across Archigos 4.1, Archigos 2.9, and the LEAD Data
gw_states

Gleditsch-Ward (Independent States) System Membership Data (1816-2017)
whittle_conflicts_duration

Whittle Duplicate Conflict-Years by Conflict Duration
whittle_conflicts_fatality

Whittle Duplicate Conflict-Years by Highest Fatality
ps_version

Get Version Information About Data Included in peacesciencer
ucdp_onsets

UCDP Onset Data (v. 19.1)
td_rivalries

Thompson and Dreyer's (2012) Strategic Rivalries, 1494-2010
tss_rivalries

Thompson et al. (2021) Strategic Rivalries, 1494-2020
whittle_conflicts_reciprocation

Whittle Duplicate Conflict-Years by Conflict Reciprocation
whittle_conflicts_hostility

Whittle Duplicate Conflict-Years by Conflict Hostility
gw_capitals

A complete list of capitals and capital transitions for Gleditsch-Ward state system members
ucdp_acd

UCDP Armed Conflict Data (ACD) (v. 25.1)
lwuf

Leader Willingness to Use Force
whittle_conflicts_jds

Whittle Duplicate Conflict-Years by Just Dropping Something ("JDS")
gw_ddy

A directed dyad-year data frame of Gleditsch-Ward state system members
maoz_powers

Zeev Maoz' Regional/Global Power Data
rugged

Rugged/Mountainous Terrain Data
show_duplicates

Show Duplicate Observations in Your Dyad-Year or State-Year Data Frame
whittle_conflicts_startmonth

Whittle Duplicate Conflict-Years by Lowest Start Month
whittle_conflicts_onsets

Whittle Unique Conflict Onset-Years from Conflict-Year Data
terrthreat

Estimates from a Random Item Response Model of External Territorial Threat, 1816-2010
add_cow_alliance

Add Correlates of War alliance data to a data frame (DEPRECATED)
add_archigos

Add Archigos political leader information to dyad-year and state-year data
add_contiguity

Add Correlates of War direct contiguity information to a data frame
add_cow_mids

Add Correlates of War (CoW) Militarized Interstate Dispute (MID) data to dyad-year data frame
add_cow_majors

Add Correlates of War major power information to a data frame
add_cow_trade

Add Correlates of War trade data to a data frame
add_capital_distance

Add capital-to-capital distance to a data frame
add_ccode_to_gw

Add Correlates of War state system codes to your data with Gleditsch-Ward state codes.
LEAD

(An Abbreviation of) The LEAD Data Set
add_atop_alliance

Add Alliance Treaty Obligations and Provisions (ATOP) alliance data to a dyad-year data frame
add_lead

Add (Select) Leader Experience and Attribute Descriptions (LEAD) Data to Leader-Year or Leader-Dyad-Year Data
add_cow_wars

Add Correlates of War war data to dyad-year or state-year data frame.
add_fpsim

Add dyadic foreign policy similarity measures to your data
add_gwcode_to_cow

Add Gleditsch-Ward state system codes to your data with Correlates of War state codes.