gen_mc_ik: Generate Monte Carlo simulations of Imbens and Kalyanaraman

Description Usage Arguments Value Examples

View source: R/gen_mc_ik.R

Description

Generate the simulations reported in Imbens and Kalyanaraman (2012)

Usage

1
2
3
4
5
6
7
gen_mc_ik(
  n = 200,
  version = 1,
  sd = 0.1295,
  output = c("data.frame", "rdd_data"),
  size
)

Arguments

n

The size of sampel to generate

version

The MC version of Imbens and Kalnayaraman (between 1 and 4).

sd

The standard deviation of the error term.

output

Whether to return a data-frame, or already a rdd_data

size

The size of the effect, this depends on the specific version, defaults are as in ik: 0.04, NULL, 0.1, 0.1

Value

An data frame with x and y variables.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mc1_dat <- gen_mc_ik()
MC1_rdd <- rdd_data(y=mc1_dat$y, x=mc1_dat$x, cutpoint=0)

## Use np regression:
reg_nonpara <- rdd_reg_np(rdd_object=MC1_rdd)
reg_nonpara

# Represent the curves:
plotCu <- function(version=1, xlim=c(-0.1,0.1)){
  res <- gen_mc_ik(sd=0.0000001, n=1000, version=version)
  res <- res[order(res$x),]
  ylim <- range(subset(res, x>=min(xlim) & x<=max(xlim), 'y'))
  plot(res, type='l', xlim=xlim, ylim=ylim, main=paste('DGP', version))
  abline(v=0)
  xCut <- res[which(res$x==min(res$x[res$x>=0]))+c(0,-1),]
  points(xCut, col=2)
}
layout(matrix(1:4,2, byrow=TRUE))
plotCu(version=1)
plotCu(version=2)
plotCu(version=3)
plotCu(version=4)
layout(matrix(1))

Example output

Loading required package: AER
Loading required package: car
Loading required package: carData
Loading required package: lmtest
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: sandwich
Loading required package: survival
Loading required package: np
Nonparametric Kernel Methods for Mixed Datatypes (version 0.60-9)
[vignette("np_faq",package="np") provides answers to frequently asked questions]
[vignette("np",package="np") an overview]
[vignette("entropy_np",package="np") an overview of entropy-based methods]
### RDD regression: nonparametric local linear###
	Bandwidth:  0.5619287 
	Number of obs: 131 (left: 91, right: 40)

	Coefficient:
  Estimate Std. Error z value Pr(>|z|)
D 0.044306   0.057304  0.7732   0.4394

rddtools documentation built on Jan. 10, 2022, 5:07 p.m.