Add estimated latent territorial threat to a data frame
Source:R/add_latent_territorial_threat.R
add_latent_territorial_threat.Rd
add_latent_territorial_threat()
allows you to add estimates of latent,
external territorial threat to a dyad-year, leader-year, or leader-dyad-year,
or state-year data frame. The estimates come by way of Miller (2022).
Arguments
- data
a data frame with appropriate peacesciencer attributes
- slice
takes one of 'first' or 'last', determines behavior for when there is a change in a contiguity relationship in a given dyad in a given year. If 'first', the earlier contiguity relationship is recorded. If 'last', the latest contiguity relationship is recorded.
- mry
logical, defaults to
FALSE
. IfTRUE
, the data carry forward the identity of the major powers to the most recently concluded calendar year. IfFALSE
, the panel honors the right bound of the data's temporal domain and creates NAs for observations past it.
Value
add_latent_territorial_threat()
takes a data frame and adds
estimates of latent, external territorial threat derived from a random item
response model (as described by Miller (2022)).
Details
The data are stored in terrthreat in this package, which also communicates what the variables are and what they mean in the case of overlapping column names. Miller (2022) describes the random item response model in more detail.
The standard caveat applies that the data are fundamentally state-year (though derived from dyad-year analyses). Extensions to leader-level data sets should be understood as approximate. For example, it's reasonable to infer the territorial threat for Germany under Friedrich Ebert in 1918 would differ from what Wilhelm II would've experienced in the same year. However, the data would have no way of knowing that (as they are).
References
Miller, Steven V. 2022. "A Random Item Response Model of External Territorial Threat, 1816-2010" Journal of Global Security Studies 7(4): ogac012.
Examples
# \donttest{
# just call `library(tidyverse)` at the top of the your script
library(magrittr)
cow_ddy %>% add_latent_territorial_threat()
#> # A tibble: 2,214,930 × 19
#> ccode1 ccode2 year lterrthreat1 sd1 lwr1 upr1 m_lterrthreat1 m_sd1
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 2 20 1920 0.679 0.0591 0.585 0.775 0.661 0.0707
#> 2 2 20 1921 0.504 0.0606 0.403 0.600 0.456 0.0677
#> 3 2 20 1922 0.744 0.0603 0.651 0.849 0.725 0.0657
#> 4 2 20 1923 0.762 0.0593 0.665 0.856 0.737 0.0674
#> 5 2 20 1924 0.739 0.0581 0.648 0.836 0.723 0.0650
#> 6 2 20 1925 0.650 0.0593 0.556 0.747 0.626 0.0682
#> 7 2 20 1926 0.699 0.0589 0.602 0.797 0.643 0.0653
#> 8 2 20 1927 0.483 0.0598 0.387 0.584 0.433 0.0687
#> 9 2 20 1928 0.483 0.0572 0.392 0.580 0.431 0.0643
#> 10 2 20 1929 0.460 0.0578 0.368 0.555 0.419 0.0658
#> # ℹ 2,214,920 more rows
#> # ℹ 10 more variables: m_lwr1 <dbl>, m_upr1 <dbl>, lterrthreat2 <dbl>,
#> # sd2 <dbl>, lwr2 <dbl>, upr2 <dbl>, m_lterrthreat2 <dbl>, m_sd2 <dbl>,
#> # m_lwr2 <dbl>, m_upr2 <dbl>
create_stateyears() %>% add_latent_territorial_threat()
#> Joining with `by = join_by(ccode, year)`
#> # A tibble: 17,511 × 11
#> ccode cw_name year lterrthreat sd lwr upr m_lterrthreat m_sd
#> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 2 United Stat… 1816 0.268 0.119 0.0918 0.466 NA NA
#> 2 2 United Stat… 1817 0.190 0.114 0.00330 0.378 NA NA
#> 3 2 United Stat… 1818 0.266 0.117 0.0717 0.448 NA NA
#> 4 2 United Stat… 1819 0.192 0.117 0.00393 0.381 NA NA
#> 5 2 United Stat… 1820 0.150 0.122 -0.0550 0.356 NA NA
#> 6 2 United Stat… 1821 0.146 0.121 -0.0601 0.348 NA NA
#> 7 2 United Stat… 1822 0.149 0.119 -0.0489 0.344 NA NA
#> 8 2 United Stat… 1823 0.146 0.119 -0.0566 0.334 NA NA
#> 9 2 United Stat… 1824 0.137 0.117 -0.0506 0.331 NA NA
#> 10 2 United Stat… 1825 0.132 0.118 -0.0645 0.334 NA NA
#> # ℹ 17,501 more rows
#> # ℹ 2 more variables: m_lwr <dbl>, m_upr <dbl>
# }