global_lm: Global Linear Least Squares to Estimate Local ATE

Description Usage Arguments Examples

View source: R/discRD-global-lm.r

Description

Estimate the local ATE at the treatment assignment threshold by the global least squares method.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
global_lm(
  basemod,
  covmod,
  data,
  subset,
  weights,
  cluster,
  submod,
  onlydmod = TRUE,
  order = c(1, 2),
  cutoff,
  assign,
  se = "HC0",
  cholesky = TRUE
)

Arguments

basemod

baseline formula. outcome ~ running variable.

covmod

(list of) one-sided formula with covariates on rhs. If NULL, covariates are not controlled. If missing, find options("discRD.xmod")

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 getOption("discRD.cutoff").

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 getOption("discRD.assign").

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.

Examples

 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)

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