clean_rd_data: Data Shape

Description Usage Arguments Examples

View source: R/data-clean.r

Description

Data Shape

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
clean_rd_data(
  basemod,
  covmod,
  data,
  subset,
  weights,
  cluster,
  order = 1,
  cutoff,
  assign,
  bw,
  global = TRUE
)

Arguments

basemod

baseline formula. outcome ~ running variable.

covmod

one-sided formula with covariates on rhs.

data

data.frame

subset

subset condition.

weights

weight variable.

cluster

cluster variable.

order

order of polynomial.

cutoff

numeric of cutoff point. If missing, search option("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, search option("discRD.assign")

bw

numeric vector of bandwidth. If specified, use data whose running variables are within this range will be used. If missing, use data from treatment and control groups where the running variable is closest to the cutoff

global

logical (default is FALSE). Whether to use all observations.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
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(discRD.cutoff = 50, discRD.assign = "smaller")
a <- clean_rd_data(y ~ running + cov1, data = raw, weights = w, order = 2)
str(a)

## End(Not run)

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