gen_data: Generate Simulation Data for a Sharp RDD with Mismeasured...

View source: R/gen_data.R

gen_dataR Documentation

Generate Simulation Data for a Sharp RDD with Mismeasured Running Variable

Description

Generate Simulation Data for a Sharp RDD with Mismeasured Running Variable

Usage

gen_data(n, sigma, cutoff, lower = FALSE, u_dist = c("gauss", "lap"),
  x_dist = c("gauss", "exp", "unif", "gaussmix"), mu_x = 0, sd_x = 1,
  rate_x = 1, min_x = -sqrt(3), max_x = sqrt(3), nmix = 5,
  mu_min = -1.5, mu_max = 1.5, sds = 0.25, ...)

Arguments

n

sample size

sigma

standard deviation of the measurement error term

cutoff

threshold value for the assignment

lower

if TRUE, then those with x < cutoff are assigned (i.e. d = 1). Otherwise those with x > cutoff are assigned.

u_dist

distribution of the measurement error. Only "gauss" or "lap" is supported.

x_dist

distribution of the true running variable. Either "gauss", "gaussmix" or any function that a generate random sample.

mu_x, sd_x

mean and standard deviation of gaussian distribution. Used if x_dist is 'gauss'

rate_x

rate parameter used when x_dist is 'exp'

min_x, max_x

min and max parameter used when x_dist is 'unif'

nmix, mu_min, mu_max, sds

parameters used when x_dist is 'gaussmix'. nmix is the number of mixture. mu_min and mu_max is the range of means. sds is the standard deviations.

...

additional argument to be passed to the generator function for running variable

Value

list of 4 numeric vectors of length n.

  • d: assignment variable

  • w: observed running variable

  • x: true running variable

  • u: measurement error

Examples

gen_data(100, 0.2, 0)
gen_data(100, 0.2, 1, u_dist = "lap", x_dist = "exp")

kota7/rddsigma documentation built on June 14, 2025, 11:08 a.m.