~dricottone/replications

replications/AS08/Figure 3.do -rw-r--r-- 1.4 KiB
eadd78eeDominic Ricottone Add README 2 days ago
                                                                                
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
clear all
cd "../data/anes"

*do "anes 2004 cumulative infile.do"
*svyset VCF0006A [pweight=VCF0009A], vce(linearized)

use "anes_timeseries_cdf_stata_20220916.dta"
svyset VCF0006a [pweight=VCF0009z], vce(linearized)

capture rename VCF0006a VCF0006A

recode VCF0301 (0=.), generate(party)
recode VCF0803 (0 9=.), generate(libcons)

/*
// Computing directly
forvalues y=1972(2)2004 {
	quietly corr party libcons if VCF0004==`y'
	di "`y' " r(C)[1,2]
}

// Compare Pearson and Spearman correlations
forvalues y=1972(2)2004 {
	quietly spearman party libcons if VCF0004==`y'
	local s=r(rho)
	quietly corr party libcons if VCF0004==`y'
	local p=r(rho)
	di "`y' `p' `s'"
}
forvalues y=2008(4)2020 {
	quietly spearman party libcons if VCF0004==`y'
	local s=r(rho)
	quietly corr party libcons if VCF0004==`y'
	local p=r(rho)
	di "`y' `p' `s'"
}
*/

// Replication
rangestat (corr) party libcons, interval(VCF0004 0 0)
graph twoway line corr_x VCF0004 if 1972<=VCF0004 & VCF0004<=2004, connect(direct) xlabel(1972(4)2004) xmtick(1972(2)2004)

// Replication with a better scale
graph twoway line corr_x VCF0004 if 1972<=VCF0004 & VCF0004<=2004, connect(direct) xlabel(1972(4)2004) xmtick(1972(2)2004) ylabel(0(.5)1) ymtick(0(.1)1)

/*
// Check against direct computations
contract VCF0004 corr_x
browse
*/

// Extension
graph twoway line corr_x VCF0004 if 1972<=VCF0004, connect(direct) xlabel(1972(4)2020) xmtick(1972(2)2020) ylabel(0(.5)1) ymtick(0(.1)1)