Description Usage Arguments Examples
View source: R/discRD-rdplot.r
Flexible RD Plot
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 | rdplot(object, ...)
## S3 method for class 'list_global_lm'
rdplot(
object,
usemod,
treat_label = c("treated", "control"),
ate_label_size = 5,
ate_label_digits = 3,
ate_label_format,
outcome_label,
ylim,
vjust = 0,
hjust = 0,
xlab = "Running variable",
ylab = "Average",
patchwork = TRUE,
ncol = NULL,
nrow = NULL,
...
)
## S3 method for class 'list_local_lm'
rdplot(
object,
usemod,
treat_label = c("treated", "control"),
ate_label_size = 5,
ate_label_digits = 3,
ate_label_format,
outcome_label,
ylim,
vjust = 0,
hjust = 0,
xlab = "Running variable",
ylab = "Average",
patchwork = TRUE,
ncol = NULL,
nrow = NULL,
force = TRUE,
...
)
|
object |
object |
... |
arguments of |
usemod |
numeric vector. which models do you want to plot? |
treat_label |
string vector of treatment and control label |
ate_label_size |
In-plot text size |
ate_label_digits |
decimal places of in-plot ATE result. |
ate_label_format |
string of label format of in-plot ATE result. The format produces labels according to a unique grammar. If you want to embed a numerical value related to the estimation result, you need to enclose it in .
|
outcome_label |
Outcome label in plot title |
ylim |
numeric vector of limits of y-axis |
vjust |
numeric. Adjust in-plot text vertically |
hjust |
numeric. Adjust in-plot text horizontally |
xlab |
label of x-axis |
ylab |
label of y-axis |
patchwork |
logical.
add a list of plots into one composition by |
ncol |
the dimensions of the grid to create.
argument of |
nrow |
the dimensions of the grid to create.
argument of |
force |
logical. Whether to ignore error about estimation |
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 | running <- sample(1:100, size = 1000, replace = TRUE)
cov1 <- rnorm(1000, sd = 2); cov2 <- rnorm(1000, mean = -1)
y0 <- running + cov1 + cov2 + rnorm(1000, sd = 10)
y1 <- 2 + 1.5 * running + cov1 + cov2 + rnorm(1000, sd = 10)
y <- ifelse(running <= 50, y1, y0)
bin <- ifelse(y > mean(y), 1, 0)
w <- sample(c(1, 0.5), size = 1000, replace = TRUE)
raw <- data.frame(y, bin, running, cov1, cov2, w)
set_optDiscRD(
y + bin ~ running,
discRD.cutoff = 50,
discRD.assign = "smaller"
)
est <- global_lm(data = raw, weights = w)
rdplot(
est,
usemod = c(1, 2),
treat_label = c("Treated", "Control"),
outcome_label = switch(x,
"1" = "Simulated outcome",
"2" = "Simulated outcome > 0"
),
ylab = "Weighted Average",
ate_label_size = 4
)
nonpara <- local_lm(
submod = 1,
data = raw,
kernel = "uniform",
bw = 5,
order = 1:3
)
rdplot(
nonpara,
usemod = 2,
outcome_label = switch(x,
"1" = "Order = 1",
"2" = "Order = 2",
"3" = "Order = 3"
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.