Description Usage Arguments Examples
View source: R/discRD-global-lm.r
Estimate the local ATE at the treatment assignment threshold by the global least squares method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
basemod |
baseline formula. |
covmod |
(list of) one-sided formula with
covariates on rhs.
If NULL, covariates are not controlled.
If missing, find |
data |
data.frame which you want to use. |
subset |
subset condition. |
weights |
weight variable. |
cluster |
cluster variable. |
submod |
numeric vector. Which baseline model you want to use. |
onlydmod |
logical (default is TRUE). Whether to estimate a model without covariates. |
order |
numeric vector of global polynomial orders. |
cutoff |
numeric of cutoff points
If missing, try to find |
assign |
assignment rule of treatment.
If "greater",
treated whose running variable is greater than or equal to cutoff.
If "smaller",
treated whose running variable is less than or equal to cutoff.
If missing, try to find |
se |
character. How to calculate robust variance-covariance matrix ("HC0", "HC1", "HC2", "HCj", "HC3", and "HC4") If "standard", calculate conventional variance-covariance matrix |
cholesky |
logical (default is TRUE). When solving normal equation, use cholesky decomposition. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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,
covmod = list(~cov1, ~ cov1 + cov2),
discRD.cutoff = 50,
discRD.assign = "smaller"
)
global <- global_lm(data = raw)
str(global_lm(submod = 1, data = raw))
str(global_lm(submod = 1, order = 3, data = raw))
str(global_lm(data = raw, cutoff = 30))
est2 <- global_lm(data = raw, se = "HC1", weights = w)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.