-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.R
More file actions
165 lines (136 loc) · 5.22 KB
/
test.R
File metadata and controls
165 lines (136 loc) · 5.22 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
########### TEST ###########
library(stargazer)
source("TANF_clean.r")
csp <- read_csv("Input Data/correlatesofstatepolicyprojectv2_1.csv") %>%
select(state, year, ranney4_control) %>%
filter(year > 1996) %>%
mutate(year = year +1) %>%
filter(year < 2014) %>%
mutate(year = as.character(year)) %>%
filter(state != "District of Columbia") %>%
arrange(year) %>%
mutate(state_id = rep(state.abb, 16))
test <- read.dta13("Input Data/caughey_warshaw_summary.dta") %>%
as.tibble() %>%
mutate(year = as.numeric(as.character(year))) %>%
mutate(stpo = as.character(stpo)) %>%
rename(state_id = stpo) %>%
filter(year > 1996) %>%
mutate(year = year + 1) %>% #IV t - 1 == DV t
filter(year < 2014) %>%
select(1:8) %>%
mutate(year = as.character(year))
avg_props_pdata <- avg_props_pdata %>%
filter(STATE != "DIST.OF COLUMBIA") %>%
ungroup() %>%
arrange(year) %>%
mutate(state_id = rep(state.abb, 16)) %>%
mutate(service = cc + pregnancy + shortben + tax + work) %>%
mutate(ba_dif = ba - service) %>%
arrange(STATE) %>%
group_by(STATE) %>%
mutate(ba_dif_before = dplyr::lag(ba_dif, n = 1)) %>%
mutate(ba_dif_before2 = dplyr::lag(ba_dif, n = 2)) %>%
ungroup()
avg_props_pdata <- left_join(test, avg_props_pdata, by = c("year", "state_id"))
anti_join(test, avg_props_pdata, by = c("year", "state_id"))
avg_props_pdata <- left_join(csp, avg_props_pdata, by = c("year", "state_id"))
anti_join(csp, avg_props_pdata, by = c("year", "state_id"))
p1 <- felm(ba_dif ~ african_americans + hispanics + ranney4_control + unemployment +
pcpi_regional + fiscal_stability + caseload + wpr
| STATE + year | 0 | STATE,
data = avg_props_pdata)
stargazer(p1,
title = "Regression Output",
dep.var.labels = "Basic Assistance minus WORSSI",
covariate.labels = c("Percent of caseload that is African American",
"Percent of caseload that is Hispanic",
"Policy liberalism",
"Unemployment rate",
"Per capita income (in thousands)",
"Fiscal balance as a percent of spending",
"Percent change in caseload",
"Work participation rate",
"Difference in prior year"),
header = FALSE,
star.cutoffs = c(.05),
notes = "*p < 0.05; SEs clustered by state",
notes.append = FALSE,
notes.align = "r",
model.numbers = FALSE,
initial.zero = FALSE,
column.sep.width = "1pt",
font.size = "small",
type = "latex",
out = "Figures and Tables/Table1_test.html")
library(plm)
pwartest(ba_dif ~ african_americans + hispanics + ranney4_control + unemployment +
pcpi_regional + fiscal_stability + caseload + wpr +
ba_dif_before + factor(avg_props_pdata$state),
data = avg_props_pdata)
detach("package:plm", unload=TRUE)
#p3 <- felm(ba_dif ~ policyeconlib_est
# | STATE + year | 0 | STATE,
# data = avg_props_pdata)
#
#p4 <- felm(ba_dif ~ policyeconlib_est + african_americans
# | STATE + year | 0 | STATE,
# data = avg_props_pdata)
#
#p5 <- felm(ba_dif ~ policyeconlib_est + african_americans + policyeconlib_est*african_americans
# | STATE + year | 0 | STATE,
# data = avg_props_pdata)
#
#p6 <- felm(ba_dif ~ ranney4_control
# | STATE + year | 0 | STATE,
# data = avg_props_pdata)
#
#p7 <- felm(ba_dif ~ ranney4_control + african_americans
# | STATE + year | 0 | STATE,
# data = avg_props_pdata)
#
#p8 <- felm(ba_dif ~ ranney4_control + african_americans + ranney4_control*african_americans
# | STATE + year | 0 | STATE,
# data = avg_props_pdata)
#
#stargazer(p3, p4, p5, p6, p7, p8,
# title = "Regression Output",
# column.labels = NULL,
# dep.var.labels = "Basic Assistance minus WORSSI",
# add.lines = list(c("Time FEs", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"),
# c("State FEs", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes")),
# header = FALSE,
# star.cutoffs = c(.05),
# notes = "*p < 0.05; SEs clustered by state",
# notes.append = FALSE,
# notes.align = "r",
# model.numbers = FALSE,
# initial.zero = FALSE,
# column.sep.width = "1pt",
# font.size = "small",
# type = "latex",
# out = "Figures and Tables/Table2_test.html")
#
#
#
#
#
#
#
#
#boom <- spread(ann_means_vis, category, value) %>%
# mutate(dif = ba - service)
#
#boom %>%
# ggplot(aes(year, dif, group = 1)) +
# geom_line() +
# labs(title = "Basic assistance minus WORSSI",
# subtitle = "FY 1998 - 2013",
# x = NULL,
# y = NULL) +
# scale_y_continuous(labels = scales::percent_format(1),
# limits = c(-.20,.40),
# breaks = seq(-.20, .40, .20),
# expand = c(0,0)) +
# scale_x_discrete(breaks = c("1998", "2003", "2008", "2013"),
# labels = c("1998", "2003", "2008", "2013"))