whatif.Rd
Implements the methods described in King and Zeng (2007) for evaluating counterfactuals. This function is a duplicate of the whatif
function from the Whatif package (GPL >= 3 license).
whatif( formula = NULL, data, cfact, range = NULL, freq = NULL, nearby = 1, distance = "gower", miss = "list", choice = "both", return.inputs = FALSE, return.distance = FALSE, mc.cores = 2, verbose = TRUE, ... )
formula | An optional formula without a dependent variable that is of class "formula" and that follows standard |
---|---|
data | Either a model output object, or a n-by-k non-character (logical or numeric) matrix or data frame of observed covariate data with n data points or units and k covariates. |
cfact | A |
nearby | An optional scalar indicating which observed data points are considered to be nearby (i.e., withing ‘nearby’ geometric variances of) the counterfactuals. Used to calculate the summary statistic returned by the function: the fraction of the observed data nearby each counterfactual. By default, the geometric variance of the covariate data is used. For example, setting nearby to 2 will identify the proportion of data points within two geometric variances of a counterfactual. Default is |
choice | An optional string indicating which analyses to undertake. The options are either "hull", only perform the convex hull membership test; "distance", do not perform the convex hull test but do everything else, such as calculating the distance between each counterfactual and data point; or "both", undertake both the convex hull test and the distance calculations (i.e., do everything). Default is "both". |
verbose | Logical. Show or hide possible warnings and messages. |
An object of class "whatif".
Gandrud C, King G, Stoll H, Zeng L (2017). WhatIf: Evaluate Counterfactuals. R package version 1.5-9. https://CRAN.R-project.org/package=WhatIf.
King G, Zeng L (2007). When can history be our guide? The pitfalls of counterfactual inference. International Studies Quarterly 51, 183–210. DOI: 10.1111/j.1468-2478.2007.00445.x