WhatIf: Software for Evaluating Counterfactuals

Inferences about counterfactuals are essential for prediction, answering what if questions, and estimating causal effects. However, when the counterfactuals posed are too far from the data at hand, conclusions drawn from well-specified statistical analyses become based largely on speculation hidden in convenient modeling assumptions that few would be willing to defend. Unfortunately, standard statistical approaches assume the veracity of the model rather than revealing the degree of model-dependence, which makes this problem hard to detect. 'WhatIf' offers easy-to-apply methods to evaluate counterfactuals that do not require sensitivity testing over specified classes of models. If an analysis fails the tests offered here, then we know that substantive inferences will be sensitive to at least some modeling choices that are not based on empirical evidence, no matter what method of inference one chooses to use. 'WhatIf' implements the methods for evaluating counterfactuals discussed in Gary King and Langche Zeng, 2006, "The Dangers of Extreme Counterfactuals," Political Analysis 14 (2) <doi:10.1093/pan/mpj004>; and Gary King and Langche Zeng, 2007, "When Can History Be Our Guide? The Pitfalls of Counterfactual Inference," International Studies Quarterly 51 (March) <doi:10.1111/j.1468-2478.2007.00445.x>.

Version: 1.5-11
Depends: R (≥ 3.5.0)
Imports: lpSolve, pbmcapply, parallel
Suggests: testthat (≥ 3.0.0)
Published: 2026-03-25
DOI: 10.32614/CRAN.package.WhatIf
Author: Heather Stoll [aut], Gary King [aut], Langche Zeng [aut], Christopher Gandrud [aut], Ben Sabath [aut], Soubhik Barari [ctb], Katalina Toth [cre]
Maintainer: Katalina Toth <katalinaltoth at gmail.com>
BugReports: https://github.com/IQSS/WhatIf/issues
License: GPL (≥ 3)
URL: https://gking.harvard.edu/whatif
NeedsCompilation: no
Materials: NEWS
CRAN checks: WhatIf results

Documentation:

Reference manual: WhatIf.html , WhatIf.pdf

Downloads:

Package source: WhatIf_1.5-11.tar.gz
Windows binaries: r-devel: not available, r-release: not available, r-oldrel: not available
macOS binaries: r-release (arm64): not available, r-oldrel (arm64): not available, r-release (x86_64): not available, r-oldrel (x86_64): not available
Old sources: WhatIf archive

Linking:

Please use the canonical form https://CRAN.R-project.org/package=WhatIf to link to this page.