Nothing
## Paper-exact tests for DMP (2026) Table 1, column (5) -- Republican
## Presidential Vote Share. Source: DMP arXiv:2206.02303v6, page 29.
##
## Each value below is what the paper prints (rounded as shown). The R
## implementation must match within 1 unit in the paper's last digit.
test_that("Table 1 Panel A col(5): beta_med, N, mean(DV)", {
inp <- regsensitivity:::build_dgp_inputs(
bfg_formula(), bfg(), compare = bfg_compare())
dgp <- regsensitivity:::get_dgp(inp)
# Total Frontier Exp. coefficient (paper: 2.055)
expect_equal(dgp$beta_med, 2.055, tolerance = 0.001)
# Number of counties (paper: 2,036)
expect_equal(dgp$n, 2036L)
# Mean of Dep Variable (paper: 60.04)
expect_equal(mean(bfg()$avgrep2000to2016, na.rm = TRUE),
60.04, tolerance = 0.05)
})
test_that("Table 1 Panel C col(5): r-bar_X breakdown point (paper: 80.4%)", {
res <- regsen_bounds(bfg_formula(), bfg(),
compare = bfg_compare(), cbar = 1)
expect_equal(res$breakdown * 100, 80.4, tolerance = 0.1)
})
test_that("Table 1 Panel C col(5): r-bar breakdown along rybar=rxbar (paper: 95.9%)", {
res <- regsen_breakdown(bfg_formula(), bfg(),
compare = bfg_compare(),
cbar = 1,
rybar_expr = function(rx) rx)
expect_equal(res$results$breakdown[1] * 100, 95.9, tolerance = 0.2)
})
test_that("Table 1 Panel B col(5): Oster delta_resid (correct, paper: -23.3)", {
inp <- regsensitivity:::build_dgp_inputs(
bfg_formula(), bfg(), compare = bfg_compare())
dgp <- regsensitivity:::get_dgp(inp)
r2rot <- min(dgp$r_med * 1.3, 1)
res <- regsen_breakdown(bfg_formula(), bfg(),
compare = bfg_compare(),
analysis = "oster",
r2long = r2rot,
beta = bnd_eq(0))
# Paper reports -23.3; our implementation returns the absolute value
# convention from Oster's formula.
expect_equal(abs(res$results$breakdown[1]), 23.3, tolerance = 0.1)
})
test_that("Table 3: partial R^2 of W1k on W1,-k given W0 matches paper exactly", {
# Paper page 32: each W1k regressed on the other W1's after partialling
# out W0 (state FE).
res <- calibrate_partial_r2(bfg_formula(), bfg(),
compare = bfg_compare())
# Look-up table from the paper.
paper <- c(
temp_mean = 0.893,
lat = 0.876,
elev_mean = 0.681,
ave_gyi = 0.648,
rain_mean = 0.560,
d_coa = 0.487,
lon = 0.434,
d_riv = 0.135,
d_lak = 0.100,
log_area_2010= 0.098
)
for (var in names(paper)) {
ours <- res$R2[res$variable == var]
expect_equal(ours, paper[[var]], tolerance = 0.005,
info = paste("variable:", var))
}
})
test_that("Table 4 col(5): rho_k calibration matches paper exactly", {
# Paper page 33: rho_k for Republican Vote Share specification.
res <- calibrate_rho(bfg_formula(), bfg(),
compare = bfg_compare())
paper <- c(
ave_gyi = 118.3,
d_coa = 78.6,
lon = 49.9,
temp_mean = 37.3,
rain_mean = 29.3,
lat = 26.9,
d_riv = 25.0,
log_area_2010 = 22.5,
elev_mean = 20.2,
d_lak = 12.1
)
for (var in names(paper)) {
ours <- res$rho[res$variable == var]
expect_equal(ours, paper[[var]], tolerance = 0.1,
info = paste("variable:", var))
}
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.