plot.whatif {WhatIf} | R Documentation |
Generates a cumulative frequency plot of Gower distances from an object of class "whatif". The cumulative frequencies (the fraction of rows in the observed data set with Gower distances to the counterfactuals less than the given value on the horizontal axis) appear on the vertical axis.
## S3 method for class 'whatif': plot(x, type = "f", numcf = NULL, eps = FALSE, ...)
x |
An object of class "whatif", the output of the
function whatif . |
type |
A character string; the type of plot of the cumulative frequencies of the Gower distances to be produced. Possible types are: "f" for cumulative frequencies only; "l" for LOWESS smoothing of cumulative frequencies only; and "b" for both cumulative frequencies and LOWESS smoothing. The default is "f". |
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 NULL. |
eps |
A Boolean; should an encapsulated postscript file be
generated? Setting the argument equal to TRUE generates an
.eps file, which is saved to your working directory with
file name of form graph_'type'_'numcf'.eps , where
'type' and 'numcf' are the values of the respective
arguments. Specifically, 'numcf' takes as the value of
the first element of the argument numcf . If all counterfactuals
were plotted, "all" appears in the place of 'numcf'. Default is FALSE,
which instead prints the graph to the screen. |
... |
Further arguments passed to and from other methods. |
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.
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.
Stoll, Heather hstoll@polsci.ucsb.edu, King, Gary king@harvard.edu and Zeng, Langche zeng@ucsd.edu
King, Gary and Langche Zeng. 2006a. "The Dangers of Extreme Counterfactuals." Political Analysis, forthcoming. Preprint available from http://GKing.Harvard.Edu.
King, Gary and Langche Zeng. 2006b. "When Can History Be Our Guide? The Pitfalls of Counterfactual Inference." International Studies Quarterly, forthcoming. Preprint available from http://gking.harvard.edu.
whatif
,
summary.whatif
,
print.whatif
,
print.summary.whatif
## 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) ## Plot cumulative frequencies for the first two counterfactuals (rows ## 1 and 2) in my.cfact plot(my.result, type = "b", numcf = c(1, 2))