-
Notifications
You must be signed in to change notification settings - Fork 8
/
rddensity_illustration.do
62 lines (53 loc) · 2.72 KB
/
rddensity_illustration.do
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
********************************************************************************
** RDDENSITY Stata Package
** Do-file for Empirical Illustration
** Authors: Matias D. Cattaneo, Michael Jansson and Xinwei Ma
********************************************************************************
** net install rddensity, from(https://raw.githubusercontent.com/rdpackages/rddensity/master/stata) replace
** net install lpdensity, from(https://raw.githubusercontent.com/nppackages/lpdensity/master/stata) replace
********************************************************************************
clear all
set more off
********************************************************************************
** Load data
********************************************************************************
use "rddensity_senate.dta", clear
sum margin
********************************************************************************
** rddensity: default options
********************************************************************************
rddensity margin
********************************************************************************
** rddensity: with plot
********************************************************************************
rddensity margin, plot
rddensity margin, plot plot_range(-50 50) hist_range(-50 50)
********************************************************************************
** rddensity: all statistics & default options
********************************************************************************
rddensity margin, all
********************************************************************************
** rddensity: default statistic, restricted model & plugin standard errors
********************************************************************************
rddensity margin, fitselect(restricted) vce(plugin)
********************************************************************************
** rdbwdensity: default options
********************************************************************************
rdbwdensity margin
********************************************************************************
** rdbwdensity: compute bandwidth and then use for rddensity
********************************************************************************
qui rdbwdensity margin
mat h = e(h)
local hr = h[2,1]
rddensity margin, h(10 `hr')
********************************************************************************
** Other examples
********************************************************************************
rddensity margin, kernel(uniform)
rddensity margin, bwselect(diff)
rddensity margin, h(10 15)
rddensity margin, p(2) q(4)
rddensity margin, c(5) all
rdbwdensity margin, p(3) fitselect(restricted)
rdbwdensity margin, kernel(uniform) vce(jackknife)