plot.whatif: Plot Cumulative Frequencies of Distances for "whatif" Objects

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/plot.whatif.R

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

1
2
## 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 whatif.

type

A character string; the type of plot of the cumulative frequencies of the 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 the value of the first element of the argument numcf unless all counterfactuals were plotted, in which case 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.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
##  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)

WhatIf documentation built on Nov. 14, 2020, 5:13 p.m.

Related to plot.whatif in WhatIf...