-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_posts_count.R
235 lines (215 loc) · 8.48 KB
/
1_posts_count.R
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# analyzing post count
# preparation
library(foreign)
library(stargazer)
setwd("xxx")
posts_count <- read.csv("xxx/post-count.csv")
#View(posts_count)
posts_count$fatinj = posts_count$fatalities + 0.5 * posts_count$injured
### REGRESSION ON NUMBER OF POSTS ###
#---- Preliminary Regressions ---- included only for transparency
# All potential IVs | fatalities and injured
reg1a = lm(count ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
#+ fatinj
#+ islamist_attack
#+ left_attack
#+ right_attack
#+ sep_loy_attack
#+ sep_rep_attack
#+ separatist
, data = posts_count)
# ==> not included
# All potential IVs | fatalities + 0.5 injured
reg1b = lm(count ~
YYYYMM # to control for time
#+ fatalities
#+ injured
+ fatinj # to account for standard explanations
#+ islamist_attack
#+ left_attack
#+ right_attack
#+ sep_loy_attack
#+ sep_rep_attack
#+ separatist
, data = posts_count)
# ==> not included
# All potential IVs | fatalities * injured
reg1c = lm(count ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
+ fatalities * injured
#+ islamist_attack
#+ left_attack
#+ right_attack
#+ sep_loy_attack
#+ sep_rep_attack
#+ separatist
, data = posts_count)
# ==> not included
stargazer(reg1a, reg1b, reg1c,
type="html",
title = "Determinants of the attacks' magnitude",
column.labels = c("Fatalities, injured","Weighed Sum ","Interaction"),
covariate.labels = c("Fatalities * injured", "Fatalities", 'Injured',
"Fatalities + 0.5 * Injured", "Time", "Constant"),
dep.var.caption = "Total number of posts on an attack",
dep.var.labels = "",#Total number of posts on an attack",
dep.var.labels.include = FALSE,
intercept.bottom = TRUE,
model.names = TRUE,
multicolumn = TRUE,
model.numbers = FALSE,
no.space = TRUE,
object.names = FALSE,
order = c('fatalities:injured', 'fatalities', 'injured', 'fatinj',
'YYYYMM', 'Constant'),
star.char = "*",
out = "post_count_1a_1b_1c_new.html")
# ==> fatalities and injured should stay
#---- Actual Regressions ----
# from here only fatalities and injured [= 1a]
# only 'orthodox model'
reg1 = lm(count ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
#+ islamist_attack
#+ left_attack
#+ right_attack
#+ sep_loy_attack
#+ sep_rep_attack
#+ separatist
, data = posts_count)
# Only islamist_attack
reg2 = lm(count ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
+ islamist_attack
#+ left_attack
+ right_attack
#+ sep_loy_attack
#+ sep_rep_attack
#+ separatist
, data = posts_count)
# include all ideologies | also fatalities and injured
reg3 = lm(count ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
+ islamist_attack
+ left_attack
+ right_attack
+ sep_loy_attack
+ sep_rep_attack
#+ separatist
, data = posts_count)
#summary(reg2)
stargazer(reg1, reg2, reg3,
type="html",
title = "Determinants of the attention given to terrorist attacks",
column.labels = c("Model 1","Model 2","Model 3"),
covariate.labels = c("Time", "Fatalities", 'Injured', "Islamist",
"Right", "Left",
"SEP-L", "SEP-R"
),
dep.var.caption = "Total number of posts on an attack",
dep.var.labels = "",#Total number of posts on an attack",
dep.var.labels.include = FALSE,
intercept.bottom = TRUE,
model.names = TRUE,
multicolumn = TRUE,
model.numbers = FALSE,
no.space = TRUE,
object.names = FALSE,
order = c('YYYYMM', 'fatalities', 'injured', 'islamist_attack',
'right_attack', "left_attack",
'sep_loy_attack', 'sep_rep_attack', 'Constant'
),
star.char = "*",
notes = c('',
"SEP-L refers to loyalist attacks in the United Kingdom's separatist conflict in Northern Ireland.",
"SEP-R refers to republican attacks in this conflict.",
'The Variable "SEP-R" is omitted since the 5 dummies referring to the ideology cover the entire data set, and thus R omits the last when calculating the regression.'),
notes.align = "l",
out = "post_count_Models.html")
#----
#Summary Statistics posts_count
stargazer(posts_count,
type = "html",
title="Descriptive statistics for Posts Count",
digits=2,
out="posts_count_des.html",
covariate.labels=c("Index",
"Fatalities", "Injured",
"Islamist attack", "Left attack", "Right attack", "SEP loyalist attack", "SEP Republican attack", "Separatist",
"Time (YYYYMM)", "Terror mentioned", "Post count", "Weighed sum fatalities, injured (factor 0.5)"),
digit.separator = "",
notes = "Note: Each case is one attack. The descriptive statistics refer to attributes of the attack and the number of posts referring to it.")
#----
### REGRESSION ON NUMBER OF terror_mentioned ###
posts_count$isl_fat = posts_count$islamist_attack * posts_count$fatalities
reg11 = lm(terror_mentioned ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
+ islamist_attack
#+ islamist_attack * fatalities
#+ left_attack
#+ right_attack
#+ sep_loy_attack
#+ sep_rep_attack
#+ separatist
, data = posts_count)
reg12 = lm(terror_mentioned ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
+ islamist_attack
+ isl_fat
#+ left_attack
#+ right_attack
#+ sep_loy_attack
#+ sep_rep_attack
#+ separatist
, data = posts_count)
reg13 = lm(terror_mentioned ~
YYYYMM # to control for time
+ fatalities
+ injured # to account for standard explanations
+ islamist_attack
+ isl_fat
+ left_attack
+ right_attack
+ sep_loy_attack
+ sep_rep_attack
#+ separatist
, data = posts_count)
stargazer(reg11, reg12, reg13, type="html",
title = "Determinants of terrorism being mentioned",
column.labels = c("Model 1","Model 2","Model 3"),
dep.var.caption = "Number of mentionings of terrorism",
covariate.labels = c("Time", "Fatalities", 'Injured',
"Islamist", "Islamist * Fatalities",
"Right",
"Left",
"SEP Loyalist", "SEP Republican"),
dep.var.labels.include = FALSE,
intercept.bottom = TRUE,
model.names = TRUE,
multicolumn = TRUE,
model.numbers = FALSE,
no.space = TRUE,
object.names = FALSE,
order = c('YYYYMM', 'fatalities', 'injured', 'islamist_attack',
"isl_fat", 'right_attack', "left_attack",
'sep_loy_attack', 'sep_rep_attack', 'Constant'),
star.char = "*",
notes = c('','Again, "SEP Republican" is omitted by R.'),
notes.align = "l",
out = "post_terrorism_mention.html")
#View(posts_count)