Skip to content

Commit

Permalink
Terra
Browse files Browse the repository at this point in the history
  • Loading branch information
svmiller committed Apr 8, 2024
1 parent dd071d2 commit ff96b2e
Show file tree
Hide file tree
Showing 51 changed files with 507 additions and 101 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Additions include:

- `african_coups`: a data set on the correlates of African coups from 1960 to 1975 (1982). Useful for replication of an old debate, and for pedagogical instruction about linear models (especially about interactions).
- `DCE12`: a data set on domestic conflict events in 2012, useful for teaching about regression of count data.
- `DAPO`: a data set on the determinants of public opinion in seven Arab countries.
- `EBJ`: a data set on the economic benefits of post-conflict justice institutions.
Expand Down
8 changes: 5 additions & 3 deletions R/rd-DAPO.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ NULL
#' \item{\code{capsub}}{the composite index of national capabilities (capability ratio) of the subject country}
#' \item{\code{capobj}}{the composite index of national capabilities (capability ratio) of the object country}
#' \item{\code{securtie}}{a dummy variable indicating at least an informal security tie between the subject and object}
#' \item{\code{dyadtrde}}{the volume of dyadic trade between subject and object}
#' \item{\code{export}}{the volume of exports from the subject to the object}
#' \item{\code{import}}{the volume of imports to the subject from the object}
#' \item{\code{subgdp}}{the gross domestic product (GDP) of the subject}
Expand All @@ -26,8 +25,11 @@ NULL
#'
#' Exact coding issues/peculiarities are best addressed by reading the reference
#' article. To maximally reproduce the article's analyses, the user will need
#' to create some variables. However, I think this is a learning experience for
#' students.
#' to create some variables. The information is here, but you'll need to create
#' a variable for dyadic trade (and as a percentage of the subject's GDP),
#' GDP-adjusted imports, a means to filter out Israel from the analysis, and
#' some of the information reported in Table 1. However, I think this is a
#' learning experience for students.
#'
#' @references
#'
Expand Down
2 changes: 1 addition & 1 deletion R/rd-ESS10NO.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NULL
#' Norwegian Attitudes toward European Integration (2021-2022)
#'
#' This is a simple data set to illustrate the use of sampling weights from
#' the European Social Survey.
#' the European Social Survey.
#'
#' @format A data frame with 1,411 observations on the following 24 variables.
#' \describe{
Expand Down
81 changes: 81 additions & 0 deletions R/rd-african_coups.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#' @importFrom tibble tibble
NULL

#' Modeling Coups in Africa, 1960 to 1975 (1982)
#'
#' A data set on modeling coups in Africa using data from the period between
#' 1960 to 1975 (1982). These data offer a partial replication of Jackman
#' (1978).
#'
#' @format A data frame with the following 10 variables.
#' \describe{
#' \item{\code{iso3c}}{a three-character ISO code for state identification}
#' \item{\code{country}}{an English country name}
#' \item{\code{jci}}{Jackman's (1978) coup index from 1960 to 1975}
#' \item{\code{tmis}}{Johnson et al.'s (1986) total military involvement score}
#' \item{\code{agperc}}{an estimate of the percentage of the country's labor force in agriculture}
#' \item{\code{literacy_cnts}}{an estimate of countrywide literacy from around 1965}
#' \item{\code{literacy_ba}}{another estimate of countrywide literacy from around 1965}
#' \item{\code{leperc}}{an estimate of the size of the largest ethnic group, as a percentage}
#' \item{\code{partydom}}{the percentage of the vote received by the largest party in the country prior to independence}
#' \item{\code{turnout}}{the turnout (as a percentage) at the independence referendum}
#' }
#'
#' @details
#'
#' Data exist for instructional purposes, especially about modeling interactions.
#' Reading Jackman (1978) and Johnson et al. (1986) will provide more information
#' about the stake of this debate.
#'
#' English country names are country names from around the time of publication.
#' Take note of older names of "Dahomey", "Swaziland", "Upper Volta", and "Zaire."
#' The three-character ISO codes are current, though it comes with the
#' acknowledgment that Dahomey used to have a different ISO code.
#'
#' Jackman (1978) is deceptively opaque on what he's doing for the ethnic group
#' variable and arguably misleads on what his turnout variable is actually from.
#' In the case of the ethnic group variable, it's the difference between saying
#' the largest ethnic group in Rwanda is 98% of the population versus 80% of
#' the population. I'm uncertain with what he's doing with what Morrison et al.
#' (1989) define as "ethnic clusters".
#'
#' Mercifully, the coup variables come from a replication by Johnson et al. (1986).
#' The bulk of this is arguably lost to history.
#'
#' Ideally, I'd have Morrison's (1972) \emph{Black Africa}, but I do not. I have
#' a copy of a 1989 update, though. That's what I consulted in constructing
#' this data set.
#'
#' Related: the agricultural variable is a midway point between columns B and
#' columns C in Table 3.11 of Morrison et al. (1989). I do not think this is too
#' far removed from what Jackman was looking at in an older version of the same
#' data, but there will be slight differences. It's the difference of "these
#' variables came from 1966" versus "this is an imputation of 1960 to 1970". The
#' latter is what I offer here.
#'
#' The literacy variables have suffices communicating where I obtained them. The
#' Cross-National Time Series Database has a variable effectively communicating
#' this information that I was using first. These data come 1965 in that data set.
#' Jackman and Johnson et al. are assuredly using Morrison's almanac. That
#' information is in Table 4.11 or Morrison et al. (1989).
#'
#' Ethiopia is conspicuously missing in the party dominance variable.
#'
#' I am 99.9% sure the turnout variable is Table 5.9 in Morrison et al. (1989).
#' Jackman (1978) says this is from *before* independence but I'm confident he
#' meant it was the turnout at the independence referendum.
#'
#' @references
#'
#' Jackman, Robert W. 1978. "The Predictability of Coups d'etat: A Model with
#' African Data." \emph{American Political Science Review} 72(4): 1262-75.
#'
#' Johnson, Thomas H., Robert O. Slater, and Pat McGowan. 1986. "Explaining
#' African Military Coups d'Etat, 1960-1982." \emph{American Political Science
#' Review} 80(4): 225-49.
#'
#' Morrison, Donald George, Robert Cameron Mitchell, and John Naber Paden. 1989.
#' \emph{Black Africa: A Comparative Handbook} (2nd ed.). New York, NY: The Free
#' Press.

"african_coups"
48 changes: 48 additions & 0 deletions data-raw/african_coups/african_coups.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
CNTS <- readxl::read_excel("/home/steve/Dropbox/data/cnts/CNTSDATA.xls")
library(tidyverse)

# CNTS %>%
# mutate(iso3c = countrycode::countrycode(country, "country.name", "iso3c")) %>%
# #select(country, iso3c, year, polit01:polit15) %>%
# mutate(iso3c = case_when(
# country == "CEN AFR REP" ~ "CAF",
# country == "CEN AFR EMP" ~ "CAF",
# country == "ETH'PIA FDR" ~ "ETH",
# country == "ETH'PIA PDR" ~ "ETH",
# TRUE ~ iso3c
# )) %>%
# mutate(iso2c = countrycode::countrycode(iso3c, "iso3c", "iso2c")) %>%
# filter(year %in% c(1964:1966)) %>%
# select(country, year, iso2c, iso3c, industry3, school12) %>%
# # Take ag from 1966 if you can. Take school from 1965 if you can.
# filter(iso3c %in% c("MDG", "GNQ", "GNB",
# "COM", "SYC", "ZWE",
# "ANG", "MOZ", "STP", "BWA",
# "CPV", "DJI", "LSO", "MUS",
# "SWZ"))



readxl::read_excel("/home/steve/Dropbox/projects/stevedata/data-raw/african_coups/african_coups.xlsx") %>%
arrange(iso3c) %>%
select(iso3c, everything(), -agperc_cnts) %>%
rename(agperc = agperc_ba) -> african_coups


save(african_coups, file="data/african_coups.rda")

#
# mutate(ddd = 100 - agperc_ba) %>%
# mutate(m = ddd+literacy_ba,
# p = ifelse(turnout >= 20, 1, 0),
# c = ifelse(leperc >= 44, 1, 0)) -> A
#
#
# broom::tidy(M1 <- lm(jci ~ m*partydom*leperc, A))
# broom::tidy(M2 <- lm(jci ~ m + c + partydom + p + partydom*p + c*partydom + c*p, A))
# broom::tidy(M3 <- lm(jci ~ m + c + partydom + p, A))



sbroom::augment(M1) %>%
ggplot(.,aes(.fitted, jci)) + geom_point()
Binary file added data-raw/african_coups/african_coups.xlsx
Binary file not shown.
Binary file modified data/DAPO.rda
Binary file not shown.
Binary file modified data/ESS10NO.rda
Binary file not shown.
Binary file added data/african_coups.rda
Binary file not shown.
Loading

0 comments on commit ff96b2e

Please sign in to comment.