| Title: | Non-Parametric Bounds and Gibbs Sampler for Assessing Priming and Post-Treatment Bias |
|---|---|
| Description: | A set of tools to implement the non-parametric bounds and Bayesian methods for assessing post-treatment bias developed in Blackwell et al (2025) <doi:10.1017/pan.2025.3> |
| Authors: | Matthew Blackwell [aut, cre], Jacob Brown [aut], Sophie Hill [aut], Kosuke Imai [aut], Teppei Yamamoto [aut] |
| Maintainer: | Matthew Blackwell <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.0 |
| Built: | 2026-06-03 10:18:16 UTC |
| Source: | https://github.com/mattblackwell/prepost |
Ponte, Alessandro Del. "The influence of foreign elite rhetoric: National identity, emotions, and attitudes toward austerity." European Union Politics 22.1 (2021): 155-178.
delpontedelponte
A data frame with 707 rows and 53 variables:
Self-reported anger after reading the the article
Binary measure of strength of Italian identity
t=Treatment indicator for if the article praises (1) or blames (0) Italy
Indicator for respondent living in Northern Italy
Answer on a 4-point scale (rescaled to 0-1) to the question "In general, how satisfied or dissatisfied are you with your economic situation?"
Measure of how politically sophisticated the respondent is by correct answers to 2 factual question. Rescaled to 0-1.
Indicator for if the respondent is a regular reader of the Corriere blog where the survey was advertised.
A dataset containing the results of an online survey experiment conducted on Italian respondents who read an article about
https://journals.sagepub.com/doi/suppl/10.1177/1465116520966653
Horowitz, J., Klaus, K. "Can Politicians Exploit Ethnic Grievances? An Experimental Study of Land Appeals in Kenya." Political Behavior 42, 35–58 (2020). https://doi.org/10.1007/s11109-018-9485-1
land_experimentland_experiment
A data frame with 375 rows and 9 variables:
Support for the hypothetical candidate making the appeal
Moderator of interest measuring if the respondent is land insecure
Treatment indicator for land-based appeals
Indicator for if the moderator was measured before (0) or after(1) treatment
Age of the respondent
Indicator for if the respondent identifies as female
Indicator for if the respondent feels close to their own ethnic group
Level of education (1=no schooling, 2 = some primary, 3 = complete primary, 4 = some secondary, 5 = completed secondary, 6 = college, 7 = some university, 8 = completed university)
,
Original treatment variable indicating control (0),land-based appeal (1), and land- and ethnic-based appeals (2).
A dataset containing the results of an experimental study of political appeals about land greivances on candidate support in Kenya
Run post-treatment bounds.
post_bounds( formula, data, moderator, sims = 1000, conf_level = 0.95, moderator_mono = NULL, stable_mod = FALSE, nondiff = FALSE, progress = TRUE )post_bounds( formula, data, moderator, sims = 1000, conf_level = 0.95, moderator_mono = NULL, stable_mod = FALSE, nondiff = FALSE, progress = TRUE )
formula |
A formula with syntax |
data |
A data.frame containing variables in the formula, moderator, and covariates arguments. |
moderator |
A one-sided formuala with syntax |
sims |
An integer indicating the number of simulations for the bootstrap confidence intervals for the bounds. |
conf_level |
A numeric indicating the confidence level for the bootstrap confidence intervals. |
moderator_mono |
A integer or vector of length 2 indicating
if the bounds should assume monotonicity of the effect of the
post-test on the moderator with |
stable_mod |
A logical value indicating if the bounds should assume that the moderator is unaffected by pre-vs-post measurement under the control condition. |
nondiff |
A logical value indicating if the bounds should assume the treatment effect on the moderator is independent of the potential outcomes. |
progress |
A logical indicating if progress bars should be displayed. Defaults to TRUE. |
A list object containing bounds.
data(delponte) post_bounds( formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin, sims = 50 )data(delponte) post_bounds( formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin, sims = 50 )
Run sensitivity analysis on post-measurement design
post_sens( formula, data, moderator, g_by, g_max = 1, q_by, sims = 1000, conf_level = 0.95, moderator_mono = NULL, stable_mod = FALSE, progress = TRUE, solver = "Rglpk" )post_sens( formula, data, moderator, g_by, g_max = 1, q_by, sims = 1000, conf_level = 0.95, moderator_mono = NULL, stable_mod = FALSE, progress = TRUE, solver = "Rglpk" )
formula |
A formula with syntax |
data |
A data.frame containing variables in the formula, moderator, and covariates arguments. |
moderator |
A one-sided formuala with syntax |
g_by |
Numeric indicating the grid spacing for the
|
g_max |
Numeric indicating the maximum value of the |
q_by |
Numeric indicating the grid spacing for the mean of the moderator under a pre-test measurement. |
sims |
An integer indicating the number of simulations for the bootstrap confidence intervals for the bounds. |
conf_level |
A numeric indicating the confidence level for the bootstrap confidence intervals. |
moderator_mono |
A integer or vector of length 2 indicating
if the bounds should assume monotonicity of the effect of the
post-test on the moderator with |
stable_mod |
A logical value indicating if the bounds should assume that the moderator is unaffected by pre-vs-post measurement under the control condition. |
progress |
A logical indicating if progress bars should be displayed. Defaults to TRUE. |
solver |
A character indicating what linear programming solver to use: "Rglpk" (the default) or "lpSolve". |
A list object containing sensitivity output.
data(delponte) post_sens(formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin, g_by = 0.1, sims = 50 )data(delponte) post_sens(formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin, g_by = 0.1, sims = 50 )
Run pre-treatment bounds.
pre_bounds(formula, data, moderator, conf_level = 0.95, outcome_mono = 1L)pre_bounds(formula, data, moderator, conf_level = 0.95, outcome_mono = 1L)
formula |
A formula with syntax |
data |
A data.frame containing variables in the formula, moderator, and covariates arguments. |
moderator |
A one-sided formuala with syntax |
conf_level |
A numeric indicating the confidence level for the bootstrap confidence intervals. |
outcome_mono |
A integer indicating the direction of the priming
monotonicity assumption. The default value |
A list object containing bounds.
data(delponte) pre_bounds( formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin )data(delponte) pre_bounds( formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin )
Run sensitivity analysis on pre-test design
pre_sens( formula, data, moderator, t_by = 0.05, conf_level = 0.95, outcome_mono = 1L )pre_sens( formula, data, moderator, t_by = 0.05, conf_level = 0.95, outcome_mono = 1L )
formula |
A formula with syntax |
data |
A data.frame containing variables in the formula, moderator, and covariates arguments. |
moderator |
A one-sided formuala with syntax |
t_by |
Numeric indicating the grid spacing for the
|
conf_level |
A numeric indicating the confidence level for the bootstrap confidence intervals. |
outcome_mono |
A integer indicating the direction of the priming
monotonicity assumption. The default value |
A list object containing sensitivity output.
pre_sens(formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin, t_by = 0.1 )pre_sens(formula = angry_bin ~ t_commonality, data = delponte, moderator = ~ itaid_bin, t_by = 0.1 )
Run Prepost bounds
prepost_bounds( formula, data, moderator, prepost, sims = 1000, conf_level = 0.95, moderator_mono = NULL, outcome_mono = NULL, stable_mod = FALSE, tau = 0.25, progress = TRUE, solver = "Rglpk" )prepost_bounds( formula, data, moderator, prepost, sims = 1000, conf_level = 0.95, moderator_mono = NULL, outcome_mono = NULL, stable_mod = FALSE, tau = 0.25, progress = TRUE, solver = "Rglpk" )
formula |
A formula with syntax |
data |
A data.frame containing variables in the formula, moderator, and covariates arguments. |
moderator |
A one-sided formuala with syntax |
prepost |
A one-sided formula with syntax ~ z, where z is the indicator variable for whether the moderator was measured pre- or post-treatment. |
sims |
An integer specifying the number of bootstrap replications for the confidence intervals. |
conf_level |
A numeric specifying level for the confidence intervals. |
moderator_mono |
A integer or vector of length 2 indicating
if the bounds should assume monotonicity of the effect of the
post-test on the moderator with |
outcome_mono |
A integer or vector of length 2 indicating if the bounds
should assume monotonicity of the effect of the post-test on the outcome
with |
stable_mod |
A logical value indicating if the bounds should assume that the moderator is unaffected by pre-vs-post measurement under the control condition. |
tau |
A numeric indicating how close the the moment conditions of the estimated bounds have to be from the minimum values in the sample. This allows us to obtain bounds and confidence intevals even when the assumptions are slightly violated due to sampling. |
progress |
A logical indicating if progress bars should be displayed. Defaults to TRUE. |
solver |
A character indicating what linear programming solver to use: "Rglpk" (the default) or "lpSolve". |
A list object containing bounds.
data(land_experiment) prepost_bounds( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, sims = 50 )data(land_experiment) prepost_bounds( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, sims = 50 )
Run Gibbs sampler for the random moderator placement design
prepost_gibbs( formula, data, prepost, moderator, covariates, iter = 1000, thin = 1, burn = 0, offset = 0, monotonicity = TRUE, stable = TRUE, saturated = TRUE, priors )prepost_gibbs( formula, data, prepost, moderator, covariates, iter = 1000, thin = 1, burn = 0, offset = 0, monotonicity = TRUE, stable = TRUE, saturated = TRUE, priors )
formula |
A formula with syntax |
data |
A data.frame containing variables in the formula, moderator, and covariates arguments. |
prepost |
A one-sided formula with syntax |
moderator |
A one-sided formuala with syntax |
covariates |
A one-sided formula with syntax |
iter |
Integer indicating the number of iterations for the Gibbs sampler. |
thin |
Integer indicating how often the Gibbs sampler should save a draw. |
burn |
Integer indicating how many iterations should be performed before saving draws in the Gibbs sampler. |
offset |
A numeric value indicating the center of the prior distribution for the covariate coefficients. |
monotonicity |
A logical signifying whether the model assumes monotonicity. |
stable |
A logical signifying whether the model assumes that the the pre vs post indicator does not affect the moderator under the control condition for treatment. |
saturated |
A logical indicating whether the coefficients on the covariates are allowed to vary by the principal strata. |
priors |
A list object containing the priors for the Gibbs sampler. Priors include beta.precision, psi.precision, alpha, y.alpha, and y.beta. |
A list object containing Gibbs posterior quantities of interest and parameters.
data(land_experiment) prepost_gibbs( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, covariates = ~ educ + age, iter = 50 )data(land_experiment) prepost_gibbs( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, covariates = ~ educ + age, iter = 50 )
Run Gibbs sampler without covariates
prepost_gibbs_nocovar( formula, data, prepost, moderator, iter = 1000, thin = 1, burn = 0, monotonicity = TRUE, stable = TRUE, priors, predictive = FALSE )prepost_gibbs_nocovar( formula, data, prepost, moderator, iter = 1000, thin = 1, burn = 0, monotonicity = TRUE, stable = TRUE, priors, predictive = FALSE )
formula |
A formula with syntax |
data |
A data frame containin the variables in the formula. |
prepost |
A one-sided formula with syntax ~ z, where z is the indicator variable for whether the moderator was measured pre- or post-treatment. |
moderator |
A formuala with syntax ~ d, where d is the moderator variable for the CATE. |
iter |
Numeric, number of iterations for the Gibbs |
thin |
Numeric, thinning parameter for the Gibbs |
burn |
Numeric, burn in rate for the Gibbs |
monotonicity |
A logical signifying whether Gibbs assumes monotonicity. |
stable |
A logical signifying whether Gibbs assumes stability. |
priors |
A list object containing the priors for the Gibbs sampler. Priors include beta.precision, psi.precision, alpha, y.alpha, and y.beta. |
predictive |
A logical indicator for whether to return prior predictive draws ( |
A list object containing Gibbs posterior quantities of interest and parameters.
data(land_experiment) prepost_gibbs_nocovar( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, iter = 50 )data(land_experiment) prepost_gibbs_nocovar( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, iter = 50 )
Run sensitivity analysis for the randomized moderator placement design
prepost_sens( formula, data, moderator, prepost, g_by, g_at, t_by, t_at, sims = 1000, stable_mod = FALSE, conf_level = 0.95, moderator_mono = NULL, outcome_mono = NULL, tau = 0.25, progress = TRUE, solver = "Rglpk" )prepost_sens( formula, data, moderator, prepost, g_by, g_at, t_by, t_at, sims = 1000, stable_mod = FALSE, conf_level = 0.95, moderator_mono = NULL, outcome_mono = NULL, tau = 0.25, progress = TRUE, solver = "Rglpk" )
formula |
A formula with syntax |
data |
A data.frame containing variables in the formula, moderator, and covariates arguments. |
moderator |
A one-sided formuala with syntax |
prepost |
A one-sided formula with syntax ~ z, where z is the indicator variable for whether the moderator was measured pre- or post-treatment. |
g_by |
Numeric indicating the grid spacing for the
|
g_at |
Vector specifying what values to set the |
t_by |
Numeric indicating the grid spacing for the
|
t_at |
Vector specifying what values to set the |
sims |
An integer indicating the number of simulations for the bootstrap confidence intervals for the bounds. |
stable_mod |
A logical value indicating if the bounds should assume that the moderator is unaffected by pre-vs-post measurement under the control condition. |
conf_level |
A numeric indicating the confidence level for the bootstrap confidence intervals. |
moderator_mono |
A integer or vector of length 2 indicating
if the bounds should assume monotonicity of the effect of the
post-test on the moderator with |
outcome_mono |
A integer or vector of length 2 indicating
if the bounds should assume monotonicity of the effect of the
post-test on the outcome with |
tau |
A numeric indicating how close the the moment conditions of the estimated bounds have to be from the minimum values in the sample. This allows us to obtain bounds and confidence intevals even when the assumptions are slightly violated due to sampling. |
progress |
A logical indicating if progress bars should be displayed. Defaults to TRUE. |
solver |
A character indicating what linear programming solver to use: "Rglpk" (the default) or "lpSolve". |
A list object containing sensitivity output.
data(land_experiment) prepost_sens( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, g_by = 0.1, t_at = c(0.25, 1), sims = 50, moderator_mono = NULL )data(land_experiment) prepost_sens( support ~ treat_comb, data = land_experiment, moderator = ~ land_insecure, prepost = ~ prepost, g_by = 0.1, t_at = c(0.25, 1), sims = 50, moderator_mono = NULL )