Skip to contents

The didnpplot take output created by didnpreg and produces plots of Heterogeneous Treatment Effects with their corresponding confidence bounds. Average effects per group are produced for discrete covariates and a continuum of effects are produced for continuous covariates.

Usage

didnpplot(
  obj,
  type = "hte",
  level = 95,
  by = NULL,
  by.continuous.scale = NULL,
  over = NULL,
  xlab = "",
  ylab = "ATET",
  over.lab = "ATET over",
  over.ci.lab = "Conf.Int.",
  point.size = 3,
  line.width = 2,
  xaxis.label.angle = 0,
  add.zero.line = TRUE,
  by.labels.values = NULL,
  over.labels.values = NULL,
  text_size = 17,
  print.level = 1
)

Arguments

obj

an object of class "didnp".

type

type of the plot. Default is 'hte'

by

The categorical or continuous variable used in the regression analysis should be specified. The length of the vector should be equal to n1 = n10 + n11 if the option TTx = "TTb" was selected when running didnpreg, or n11 if the option TTx = "TTa" was chosen.

by.continuous.scale

The scale of a continuous variable can be set to three values. (1) Setting it to NULL implies that each unique value in the ‘by’ variable will be treated separately. (2) If you set it to a numeric vector of length 1 or a scalar, it will split the range of the continuous ‘by’ variable into the number of intervals specified by by.continuous.scale. (3) If you set it to a numeric vector, it will split the continuous ‘by’ variable into intervals defined by the specified vector. The default value is NULL.

over

The categorical variable used in the regression analysis should be specified. The length of the vector should be equal to n1 = n10 + n11 if the option TTx = "TTb" was selected when running didnpreg, or n11 if the option TTx = "TTa" was chosen.

xlab

Label for horizontal axis. Default is "".

ylab

Label for vertical axis. Default is "ATET".

over.lab

Label for the legend. The default is "ATET over".

over.ci.lab

Label for the legend. The default is "Conf.Int.".

point.size

of ATET. Default is 3.

line.width

of ATET for the numeric "by". Default is 2.

xaxis.label.angle

The angle of the axis. Default is 0.

add.zero.line

add a solid horizontal line at 0. Default is TRUE.

by.labels.values

For the categorical 'by" variable, the dataframe should have two columns. The first column should contain unique values for the 'by' variable, while the second column should contain corresponding values that would be displayed on a graph. By default, 'by.labels.values' is set to NULL, which means that the unique values from the 'by' variable will be used.

over.labels.values

For the categorical 'over' variable, the dataframe should have two columns. The first column should contain unique values for the 'over' variable, while the second column should contain corresponding values that would be displayed on a graph. By default, 'over.labels.values' is set to NULL, which means that the unique values from the 'over' variable will be used.

text_size

for ggplot object. Default is 17.

print.level

The amount of printed output can be set to 0, 1, or 2. When set to 0, nothing is printed. When set to 1, only the structure of the work is printed. When set to 2, both the structure and the additional working are printed. The default value is 1.

Value

didnpplot returns a dataframe containing containing the following columns:

plot.aggplot object
data.adata used to produce plot.a
plot.bggplot object for TTb if TTb = TRUE was used in running didnpreg
data.adata used to produce plot.b

Details

Vector "by" (and "over") must be of length of TTa.i if TTb = FALSE was used in running didnpreg and of length of TTb.i if TTb = TRUE was used in running didnpreg

References

... (...). This. Journal of , 1(1), 1-1 https://doi.org/10.

Author

Oleg Badunenko oleg.badunenko@brunel.ac.uk,

Daniel J. Henderson djhender@cba.ua.edu,

Stefan Sperlich stefan.sperlich@unige.ch

Examples

if (FALSE) { # \dontrun{
  data(DACAsub, package = "didnp")
  # will get a data frame 'DACAsub' with 330106 rows and 18 columns

  # get the subsample
  DACAsub$mysmpl <- mysmpl <-
    DACAsub$a1922==1 & !is.na(DACAsub$a1922) &
    DACAsub$htus==1 & !is.na(DACAsub$htus)

  # generate 'treatment_period'
  DACAsub$treatment_period <- ifelse(DACAsub[,"year"]>2011,1,0)

  # define formula with the weight
  form1 <- inschool ~ fem + race + var.bpl + state + age + yrimmig +
    ageimmig | inschool | year | elig | treatment_period | perwt

  tym1a <- didnpreg(
    form1,
    data = DACAsub,
    subset = mysmpl,
    bwmethod = "opt",
    boot.num = 399,
    TTb = FALSE,
    print.level = 1,
    cores = 4)

  # Print the summary
  summary(tym1a)

} # }