ivqr_eg2: An (second) example data created by simulation.

Description Usage Format Examples

Description

A dataset with 2 endogenous variables to illustrate the usage of the IVQR pacakge.

Usage

1

Format

A data frame with 10000 rows and 4 variables:

y

outcome variable

d

binary endogenous variable

z

binary instrumental variable

x

control variable

...

Examples

 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
# The data generation process 
sim_ivqr_eg2 <- function(n = 10 ^ 4){
  u <- runif(n)
  x <- rbinom(n, 1,0.2)
  z1 <- rbinom(n, 1, 0.37)
  v1 <- rnorm(n)
  d1 <- z1 * (u > 0.5 * v1)
  z2 <- rbinom(n, 1, 0.37)
  v2 <- rnorm(n)
  d2 <- z2 * (u > 0.5 * v1)
  y00 <- 0 + x * 2 + qnorm(u,0,1)
  y10 <- u  + x * 2 + qnorm(u,0,1)
  y01 <- 2 + x * 2 + qnorm(u,0,1)
  y11 <- 2 + u + x * 2 + qnorm(u,0,1)
  y <- d1 * d2 * y11  + (1 - d1) * d2 * y01 + d1 * (1 - d2) * y10 + (1 - d1) * (1 - d2) * y00
  value <- list()
  value$y <- y
  value$d1 <- d1
  value$d2 <- d2
  value$z1 <- z1
  value$z2 <- z2
  value$x <- x
  value <- data.frame(value)
  return(value)
}

yuchang0321/IVQR documentation built on May 29, 2019, 12:19 p.m.