rdd_gen_reg: General polynomial estimator of the regression discontinuity

Description Usage Arguments Details Value References Examples

View source: R/reg_gen.R

Description

Compute RDD estimate allowing a locally kernel weighted version of any estimation function possibly on the range specified by bandwidth

Usage

1
2
3
4
rdd_gen_reg(rdd_object, fun = glm, covariates = NULL, order = 1,
  bw = NULL, slope = c("separate", "same"), covar.opt = list(strategy =
  c("include", "residual"), slope = c("same", "separate"), bw = NULL), weights,
  ...)

Arguments

rdd_object

Object of class rdd_data created by rdd_data

fun

The function to estimate the parameters

covariates

Formula to include covariates

order

Order of the polynomial regression.

bw

A bandwidth to specify the subset on which the kernel weighted regression is estimated

slope

Whether slopes should be different on left or right (separate), or the same.

covar.opt

Options for the inclusion of covariates. Way to include covariates, either in the main regression (include) or as regressors of y in a first step (residual).

weights

Optional weights to pass to the lm function. Note this cannot be entered together with bw

...

Further arguments passed to fun. See the example.

Details

This function allows the user to use a custom estimating function, instead of the traditional lm(). It is assumed that the custom funciton has following behaviour:

  1. A formula interface, together with a data argument

  2. A weight argument

  3. A coef(summary(x)) returning a data-frame containing a column Estimate

Note that for the last requirement, this can be accomodated by writing a specific rdd_coef function for the class of the object returned by fun.

Value

An object of class rdd_reg_lm and class lm, with specific print and plot methods

References

TODO

Examples

1
2
3
4
5
6
7
8
9
## Step 0: prepare data
data(house)
house_rdd <- rdd_data(y=house$y, x=house$x, cutpoint=0)

## Estimate a local probit:
house_rdd$y <- with(house_rdd, ifelse(y<quantile(y, 0.25), 0,1))
reg_bin_glm <- rdd_gen_reg(rdd_object=house_rdd, fun= glm, family=binomial(link='probit'))
print(reg_bin_glm)
summary(reg_bin_glm)

Example output

Loading required package: AER
Loading required package: car
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-3)
[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: parametric ###
	Polynomial order:  1 
	Slopes:  separate 
	Number of obs: 6558 (left: 2740, right: 3818)

	Coefficient:
  Estimate Std. Error z value  Pr(>|z|)    
D  1.43575    0.08986  15.978 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Call:
fun(formula = y ~ ., family = ..1, data = dat_step1, weights = weights)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.1147  -0.1246   0.1819   0.2210   2.7733  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  0.50217    0.04372  11.485   <2e-16 ***
D            1.43576    0.08986  15.978   <2e-16 ***
x            2.52830    0.14178  17.832   <2e-16 ***
x_right     -2.04918    0.22533  -9.094   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 7376.7  on 6557  degrees of freedom
Residual deviance: 3944.8  on 6554  degrees of freedom
AIC: 3952.8

Number of Fisher Scoring iterations: 6

rddtools documentation built on May 30, 2017, 4:45 a.m.