rdtab: Output Table of Regression Discontinuity Design

Description Usage Arguments Examples

View source: R/discRD-rdtab.r

Description

Output Table of Regression Discontinuity Design

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
rdtab(object, ...)

## S3 method for class 'list_local_random'
rdtab(
  object,
  ylab,
  col_lab = list(y = "Outcomes", mean = "Mean", se = "S.E.", n = "N", mean.diff =
    "Mean difference", p = "P-value", treat = "Treated", control = "Control"),
  title = NULL,
  footnote = NULL,
  output = getOption("discRD.table_output"),
  size = getOption("discRD.table_fontsize"),
  digits = 3,
  ...
)

## S3 method for class 'list_global_lm'
rdtab(
  object,
  ylab,
  dlab = "treated",
  olab = "Order of polynomial",
  covariate_labs,
  stars = c(`***` = 0.01, `**` = 0.05, `*` = 0.1),
  gof_omit = "se",
  title = NULL,
  footnote = NULL,
  output = getOption("discRD.table_output"),
  size = getOption("discRD.table_fontsize"),
  digits = 3,
  ...
)

## S3 method for class 'list_local_lm'
rdtab(
  object,
  ylab,
  dlab = "treated",
  olab = "Order of polynomial",
  stars = c(`***` = 0.01, `**` = 0.05, `*` = 0.1),
  gof_omit = "se",
  title = NULL,
  footnote = NULL,
  output = getOption("discRD.table_output"),
  size = getOption("discRD.table_fontsize"),
  digits = 3,
  ...
)

Arguments

object

output object

...

Other arguments to pass to kableExtra::kable_styling

ylab

named string vector with label of outcome variables specified by c("original label" = "new label", ...).

col_lab

named list of column labels (only "list_local_random" class)

  • y: outcome column

  • mean: columns showing average

  • se: columns showing standard error

  • n: columns showing number of obsrevations

  • mean.diff: columns showing mean difference

  • plab: columns of showing p-value of t-test or permutation test

  • treat: label of treatment

  • control: label of control

title

string of table title

footnote

string of footnote

output

string of output format (default is getOption("discRD.table_output"))

size

numeric of font size (default is getOption("discRD.table_fontsize"))

digits

numeric of number of decimal places to display (Default is 3).

dlab

a string of label of treatment variable

olab

a string of label of "Order of polynomial"

covariate_labs

list. You can specify how to display information about whether you are controlling a variable that is not displayed by a factor. For example, list("label 1" = "x1") changes the label of "x1" to "label 1". Also, when specified as list("label" = c ("x1", "x2")), if x1 and x2 are not controlled or the coefficients are not displayed in all models, "x1" and "x2" labels are aggregated into one line with the name "label".

stars

a named numeric vector to indicate statistical significance. "***" = 0.01 means show *** if p-value is less than or equal to 0.01.

gof_omit

string regular expression. Omits all matching gof statistics from the table.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
running <- sample(1:100, size = 1000, replace = TRUE)
cov1 <- rnorm(1000, sd = 2); cov2 <- rnorm(1000, mean = -1)
y0 <- running + cov1 + cov2 + rnorm(1000)
y1 <- 2 + 1.5 * running + cov1 + cov2 + rnorm(1000)
y <- ifelse(running <= 50, y1, y0)
bin <- ifelse(y > mean(y), 1, 0)
raw <- data.frame(y, bin, running, cov1, cov2)

set_optDiscRD(
  y + bin ~ running,
  discRD.cutoff = 50,
  discRD.assign = "smaller"
)

library(modelsummary)
library(magrittr)

ylab <- c("y" = "Simulated Outcome", "bin" = "Binary")
footnote <- paste0(
  "Observations with running variables of -45 to 55 were used.",
  "The treatment variable is determined to take 1",
  "if the running variable is 50 or less."
)

loc <- local_random_test(data = raw, bw = c(-5, 5))
rdtab(loc, ylab, digits = 2, footnote = footnote)


set_optDiscRD(xmod = ~ cov1 + cov2)

est <- global_lm(data = raw)
rdtab(
  est,
  title = "Estimate Local ATE by Global Polynomial Fitting",
  ylab = c("y" = "Simulated Outcome", "bin" = "Simulated Outcome > 0"),
  dlab = "Treatment",
  covariate_labs = list("Covariates" = c("cov1", "cov2")),
  footnote = "***: p < 0.01, **: p < 0.05, *: p < 0.1"
)

locest <- local_lm(data = raw, kernel = "uniform", bw = 3)
rdtab(
  locest,
  title = "Estimate Local ATE by Local Polynomial Fitting",
  ylab = c("y" = "Simulated Outcome", "bin" = "Simulated Outcome > 0"),
  dlab = "Treatment",
  footnote = "***: p < 0.01, **: p < 0.05, *: p < 0.1"
)

KatoPachi/discreteRD documentation built on Feb. 24, 2022, 12:32 a.m.