plot.whatif {WhatIf} | R Documentation |
Plot Cumulative Frequencies of Distances for "whatif" Objects
Description
Generates a cumulative frequency plot of distances from an object of class "whatif". The cumulative frequencies (the fraction of rows in the observed data set with either Gower or (squared) Euclidian distances to the counterfactuals less than the given value on the horizontal axis) appear on the vertical axis.
Usage
## S3 method for class 'whatif'
plot(x, type = "f", numcf = NULL, eps = FALSE, ...)
Arguments
x |
An object of class "whatif", the output of the
function |
type |
A character string; the type of plot of the cumulative frequencies
of the distances to be produced. Possible types are: |
numcf |
A numeric vector; the specific counterfactuals to be plotted.
Each element represents a counterfactual, specifically its row number
from the matrix or data frame of counterfactuals. By default, all
counterfactuals are plotted. Default is |
eps |
A Boolean; should an encapsulated postscript file be
generated? Setting the argument equal to |
... |
Further arguments passed to and from other methods. |
Details
LOWESS scatterplot smoothing using the function lowess
is plotted
in blue. Counterfactuals in the convex hull are plotted with a solid line
and counterfactuals outside of the convex hull with a dashed line.
Value
A graph printed to the screen or an encapsulated postscript file saved
to your working directory. In the latter case, the file name has form
'graph_'type'_'numcf'.eps
', where 'type'
and 'numcf'
are the values of the respective arguments.
Author(s)
Stoll, Heather hstoll@polsci.ucsb.edu, King, Gary king@harvard.edu and Zeng, Langche zeng@ucsd.edu
References
King, Gary and Langche Zeng. 2006. "The Dangers of Extreme Counterfactuals." Political Analysis 14 (2). Available from https://gking.Harvard.Edu.
King, Gary and Langche Zeng. 2007. "When Can History Be Our Guide? The Pitfalls of Counterfactual Inference." International Studies Quarterly 51 (March). Available from https://gking.harvard.edu.
See Also
whatif
,
summary.whatif
,
print.whatif
,
print.summary.whatif
Examples
## Create example data sets and counterfactuals
my.cfact <- matrix(rnorm(3*5), ncol = 5)
my.data <- matrix(rnorm(100*5), ncol = 5)
## Evaluate counterfactuals
my.result <- whatif(data = my.data, cfact = my.cfact, mc.cores = 1)
## Plot cumulative frequencies for the first two counterfactuals (rows
## 1 and 2) in my.cfact
plot(my.result, type = "b", numcf = c(1, 2), mc.cores = 1)