plot.discreteQ: Plotting uniform bands for quantile and quantile effect...

Description Usage Arguments Details Value Examples

View source: R/plot.discreteQ.R

Description

Plots point estimates and uniform bands for quantile functions and quantile effect functions of possibly discrete outcomes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## S3 method for class 'discreteQ'
plot(
  x,
  ...,
  which = NULL,
  xlim = NULL,
  ylim = NULL,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  add = FALSE,
  col.l = "dark blue",
  col.b = "light blue",
  shift = NULL,
  lty.l = 1,
  lwd.l = 1,
  lty.b = 1,
  lwd.b = 5,
  support = NULL
)

Arguments

x

an object produced by discreteQ.

...

other graphical parameters passed to plot.

which

specifies the function for which the results are plotted. Possible values are (depending on the characteristics of the discreteQ object): "Q0", "Q1", "Qc", "QTE", "decomposition", "observed", "composition", "unexplained". See ‘Details’ below.

xlim

the x limits (x1, x2) of the plot. By default, this corresponds to the range of quantiles specified by the argument q.range when calling discreteQ. It is not allowed to specify wider x limits than q.range because the uniform bands cover the functions only over this range.

ylim

the y limits of the plot.

main

the title of the plot. If which="decomposition" then main must be a character vector of length 4 for the 4 panels of the figure. Sensible default values are provided.

xlab

a label for the x axis.

ylab

a label for the y axis.

add

logical; if TRUE only add to an existing plot.

col.l

color used for the line representing the point estimates. If which="decomposition" then col.l must be a color vector of length 3 for the three quantile functions.

col.b

color used for the confidence bands. If which="decomposition" then col.b must be a color vector of length 3 for the three quantile functions.

shift

scalar shifting the QF and the bands. Useful if add=TRUE and the functions overlap.

lty.l

line type.

lwd.l

line width.

lty.b

line types for the uniform bands.

lwd.b

line width for the confidence bands.

support

type of support restriction. If support="empirical", it is assumed that the support of the function(s) of interest (Q0, Q1, Qc, QTE, etc.) is equal to the support of the outcome in the sample. Alternatively, no restriction on the support is assumed if support="continuous". Finally, support may directly contain the vector of all values that the relevant function (Q0, Q1 or QTE) can take. By default, support="empirical" if there are less than 200 points in the empirical support and support="continuous" otherwise.

Details

plot.discreteQ will produce different types of plots depending on the type of the discreteQ object and on the value of the argument which. If the unconditional quantile function of the outcome (i.e. no treatment was provided) has been estimated, then the only possibility consists in plotting the estimated quantile function and its confidence bands. If a treatment variable has been provided by decomposition=FALSE, then by default the quantile treatment effect function is plotted but it is also possible to plot the quantile functions of the control (which="Q0") and treated outcomes (which="Q1"). If decomposition=TRUE, by default a matrix of 4 plots is produced: all three quantile functions in the top-left panel, the observed difference in the top-right panel, the composition effect in the bottom-right panel and the unexplained component in the bottom-right panel. It is possible to plot any of these components by setting the argument which to one of the following values: "Q0", "Q1", "Qc", "observed", "composition", "unexplained".

None.

Value

None.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
set.seed(1234)
outcome <- rpois(100, 3)
results1 <- discreteQ(outcome)
plot(results1)

set.seed(1234)
treatment <- c(rep(0,100), rep(1,100))
reg <- rbinom(200, 1, 0.4+treatment*0.2)
outcome <- rpois(200, lambda = 2+4*reg)
results2 <- discreteQ(outcome, treatment, cbind(1, reg))
plot(results2)
plot(results2, which="Q0")
plot(results2, which="Q1", add=TRUE, shift=0.2, col.l="dark green", col.b="light green")

set.seed(1234)
group <- c(rep(0,100), rep(1,100))
reg <- rbinom(200, 1, 0.4+group*0.2)
outcome <- rpois(200, lambda = exp(-2+4*reg))
results3 <- discreteQ(outcome, group, cbind(1, reg), decomposition=TRUE)
plot(results3)
plot(results3, which="composition")

bmelly/discreteQ documentation built on May 22, 2021, 7:55 a.m.