Bachelor thesis: "The influence of sensational issues on the political agenda setting in social media"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

.Rhistory 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  2. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation")) +
  3. theme(legend.title = element_text(size=14)) +
  4. theme(legend.text = element_text(size=12)) +
  5. theme(axis.text = element_text(size = 18))
  6. g_perday
  7. g_perday <- ggplot(data = stats_melt, aes(x=date,y=value,colour=variable, group=variable)) +
  8. geom_line()+
  9. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  10. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  11. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation")) +
  12. theme(legend.title = element_text(size=14)) +
  13. theme(legend.text = element_text(size=12)) +
  14. theme(axis.title = element_text(size = 18))
  15. g_perday
  16. g_perday <- ggplot(data = stats_melt, aes(x=date,y=value,colour=variable, group=variable)) +
  17. geom_line()+
  18. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  19. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  20. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation")) +
  21. theme(legend.title = element_text(size=14)) +
  22. theme(legend.text = element_text(size=12)) +
  23. theme(axis.title = element_text(size = 12))
  24. g_perday
  25. g_perday <- ggplot(data = stats_melt, aes(x=date,y=value,colour=variable, group=variable)) +
  26. geom_line()+
  27. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  28. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  29. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation")) +
  30. theme(legend.title = element_text(size=14)) +
  31. theme(legend.text = element_text(size=12)) +
  32. theme(axis.title = element_text(size = 13))
  33. g_perday
  34. g_perday <- ggplot(data = stats_melt, aes(x=date,y=value,colour=variable, group=variable)) +
  35. geom_line()+
  36. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  37. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  38. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation")) +
  39. theme(legend.title = element_text(size=14, face="plain")) +
  40. theme(legend.text = element_text(size=12)) +
  41. theme(axis.title = element_text(size = 13))
  42. g_perday
  43. g_perday <- ggplot(data = stats_melt, aes(x=date,y=value,colour=variable, group=variable)) +
  44. geom_line()+
  45. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  46. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  47. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation")) +
  48. theme(legend.title = element_text(size=14)) +
  49. theme(legend.text = element_text(size=12)) +
  50. theme(axis.title = element_text(size = 13))
  51. g_perday
  52. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  53. geom_line() +
  54. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  55. xlab("Zeitraum") + ylab("Entropie") +
  56. scale_colour_discrete(name = "", labels = "Entropie") +
  57. theme(legend.title = element_text(size=14)) +
  58. theme(legend.text = element_text(size=12)) +
  59. theme(axis.title = element_text(size = 13))
  60. g_entrop
  61. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  62. geom_line() +
  63. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  64. xlab("Zeitraum") + ylab("Entropie") +
  65. scale_colour_discrete(name = "", labels = "Entropie")# +
  66. # theme(legend.title = element_text(size=14)) +
  67. # theme(legend.text = element_text(size=12)) +
  68. # theme(axis.title = element_text(size = 13))
  69. g_entrop
  70. detach("package:ggplot2", unload=TRUE)
  71. library("ggplot2", lib.loc="/usr/lib/R/site-library")
  72. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  73. geom_line() +
  74. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  75. xlab("Zeitraum") + ylab("Entropie") +
  76. scale_colour_discrete(name = "", labels = "Entropie")# +
  77. # theme(legend.title = element_text(size=14)) +
  78. # theme(legend.text = element_text(size=12)) +
  79. # theme(axis.title = element_text(size = 13))
  80. g_entrop
  81. theme()
  82. require(stringr)
  83. require(reshape2)
  84. require(ggplot2)
  85. require(vars)
  86. theme()
  87. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  88. geom_line() +
  89. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  90. xlab("Zeitraum") + ylab("Entropie") +
  91. scale_colour_discrete(name = "", labels = "Entropie")# +
  92. # theme(legend.title = element_text(size=14)) +
  93. # theme(legend.text = element_text(size=12)) +
  94. # theme(axis.title = element_text(size = 13))
  95. g_entrop
  96. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  97. geom_line() +
  98. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  99. xlab("Zeitraum") + ylab("Entropie") +
  100. scale_colour_discrete(name = "", labels = "Entropie")
  101. g_entrop
  102. g_perday <- ggplot(data = stats_melt, aes(x=date,y=value,colour=variable, group=variable)) +
  103. geom_line()+
  104. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  105. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  106. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation"))
  107. g_perday
  108. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  109. geom_line() +
  110. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  111. xlab("Zeitraum") + ylab("Entropie") +
  112. scale_colour_discrete(name = "", labels = "Entropie")
  113. g_entrop
  114. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  115. geom_line() +
  116. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1)
  117. g_entrop
  118. stats_entropy <- data.frame(date=drange)
  119. stats_entropy$entropy <- issues_i$entropy
  120. stats_entropy <- melt(stats_entropy, id="date")
  121. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  122. geom_line() +
  123. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  124. xlab("Zeitraum") + ylab("Entropie") +
  125. scale_colour_discrete(name = "", labels = "Entropie")
  126. g_entrop
  127. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  128. geom_line() +
  129. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  130. xlab("Zeitraum") + ylab("Entropie") +
  131. scale_colour_discrete(name = "", labels = "Entropie") +
  132. theme(legend.title = element_text(size=14)) +
  133. theme(legend.text = element_text(size=12)) +
  134. theme(axis.title = element_text(size = 13))
  135. g_entrop
  136. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  137. geom_line() +
  138. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  139. xlab("Zeitraum") + ylab("Entropie") +
  140. scale_colour_discrete(name = "", labels = "Entropie") +
  141. theme(legend.title = element_text(size=14)) +
  142. theme(legend.text = element_text(size=12)) +
  143. theme(axis.title = element_text(size = 14))
  144. g_entrop
  145. g_perday <- ggplot(data = stats_melt, aes(x=date,y=value,colour=variable, group=variable)) +
  146. geom_line()+
  147. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  148. xlab("Zeitraum") + ylab("Tweets pro Tag") +
  149. scale_colour_discrete(name = "Tweets", labels = c("Gesamt", "Allgemein", "Sensation")) +
  150. theme(legend.title = element_text(size=14)) +
  151. theme(legend.text = element_text(size=12)) +
  152. theme(axis.title = element_text(size = 14))
  153. g_perday
  154. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  155. geom_line() +
  156. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  157. xlab("Zeitraum") + ylab("Entropie") +
  158. scale_colour_discrete(name = "", labels = "Entropie") +
  159. theme(legend.title = element_text(size=14)) +
  160. theme(legend.text = element_text(size=12)) +
  161. theme(axis.title = element_text(size = 14))
  162. g_entrop
  163. acc_parties <- data.frame(party = c("cducsu", "spd", "linke", "gruene"))
  164. acc_parties$btw13 <- c(49.3, 30.6, 10.1, 10.0) # seats of party / 631 seats
  165. acc_parties$twitter <- 0
  166. for(p in 1:nrow(acc_parties)) {
  167. acc_parties$twitter[p] <- round(nrow(acc_df[acc_df$party == as.character(acc_parties$party[p]), ]) / 280 * 100)
  168. }
  169. require(jsonlite)
  170. require(stringr)
  171. require(devtools)
  172. require(RTwitterAPI)
  173. acc_df <- read.csv("MdB-twitter.csv")
  174. delrow <- NULL
  175. for(r in 1:nrow(acc_df)) {
  176. acc <- as.character(acc_df$twitter_acc[r])
  177. if(!nzchar(acc)) {
  178. delrow <- c(delrow, r)
  179. }
  180. }
  181. acc_df <- acc_df[-delrow, ]
  182. rm(delrow, r, acc)
  183. acc_df$row.names <- NULL
  184. row.names(acc_df) <- NULL
  185. acc_parties <- data.frame(party = c("cducsu", "spd", "linke", "gruene"))
  186. acc_parties$btw13 <- c(49.3, 30.6, 10.1, 10.0) # seats of party / 631 seats
  187. acc_parties$twitter <- 0
  188. for(p in 1:nrow(acc_parties)) {
  189. acc_parties$twitter[p] <- round(nrow(acc_df[acc_df$party == as.character(acc_parties$party[p]), ]) / 280 * 100)
  190. }
  191. pie(acc_parties$btw13, col=c("black", "red", "purple", "green"), labels = c("CDU/CSU", "SPD", "Die LINKE", "Bündnis 90/Grüne"), clockwise = T,
  192. main = "Seats of parties in the parliament")
  193. pie(acc_parties$twitter, col=c("black", "red", "purple", "green"), labels = c("CDU/CSU", "SPD", "Die LINKE", "Bündnis 90/Grüne"), clockwise = T,
  194. main = "Percentage of parties' MdBs of all Twitter accounts")
  195. pie(acc_parties$btw13, col=c("black", "red", "purple", "green"), labels = c("CDU/CSU", "SPD", "Die LINKE", "Bündnis 90/Grüne"), clockwise = T)
  196. pie(acc_parties$twitter, col=c("black", "red", "purple", "green"), labels = c("CDU/CSU", "SPD", "Die LINKE", "Bündnis 90/Grüne"), clockwise = T)
  197. View(acc_parties)
  198. pie(acc_parties$btw13, col=c("black", "red", "purple", "green"),
  199. labels = c("CDU/CSU (49.3%)", "SPD", "Die LINKE", "Bündnis 90/Grüne"), clockwise = T)
  200. pie(acc_parties$btw13, col=c("black", "red", "purple", "green"),
  201. labels = c("CDU/CSU (49,3%)", "SPD (30,6%)", "Die LINKE (10,1%)", "Bündnis 90/Grüne(10.0%)"),
  202. clockwise = T)
  203. acc_parties <- data.frame(party = c("cducsu", "spd", "gruene", "linke"))
  204. acc_parties$btw13 <- c(49.3, 30.6, 10.0, 10.1) # seats of party / 631 seats
  205. acc_parties$twitter <- 0
  206. for(p in 1:nrow(acc_parties)) {
  207. acc_parties$twitter[p] <- round(nrow(acc_df[acc_df$party == as.character(acc_parties$party[p]), ]) / 280 * 100)
  208. }
  209. pie(acc_parties$btw13, col=c("black", "red", "green", "purple"),
  210. labels = c("CDU/CSU (49,3%)", "SPD (30,6%)", "Bündnis 90/Grüne(10.0%)", "Die LINKE (10,1%)"),
  211. clockwise = T)
  212. pie(acc_parties$btw13, col=c("black", "red", "green", "purple"),
  213. pie(acc_parties$btw13, col=c("black", "red", "green", "purple"),
  214. labels = c("CDU/CSU (49,3%)", "SPD (30,6%)", "Bündnis 90/Grüne(10,0%)", "Die LINKE (10,1%)"),
  215. clockwise = T)
  216. pie(acc_parties$btw13, col=c("black", "red", "green", "purple"),
  217. labels = c("CDU/CSU (49,3%)", "SPD (30,6%)", "Bündnis 90/Grüne(10,0%)", "Die LINKE (10,1%)"),
  218. clockwise = T)
  219. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  220. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  221. clockwise = T)
  222. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  223. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  224. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  225. clockwise = T, init.angle = 90)
  226. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  227. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  228. clockwise = T)
  229. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  230. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  231. clockwise = T, init.angle = 180)
  232. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  233. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  234. clockwise = T, init.angle = 270)
  235. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  236. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  237. clockwise = T, init.angle = 360)
  238. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  239. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  240. clockwise = T, init.angle = 20)
  241. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  242. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  243. clockwise = T, init.angle = 20)
  244. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  245. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  246. clockwise = T, init.angle = 90)
  247. pie(acc_parties$btw13, col=c("black", "red", "green", "purple"),
  248. labels = c("CDU/CSU (49,3%)", "SPD (30,6%)", "Bündnis 90/Grüne(10,0%)", "Die LINKE (10,1%)"),
  249. clockwise = T)
  250. pie(acc_parties$twitter, col=c("black", "red", "green", "purple"),
  251. labels = c("CDU/CSU (36%)", "SPD (30%)", "Bündnis 90/Grüne(19%)", "Die LINKE (15%)"),
  252. clockwise = T)
  253. 2359 / 200 * 100
  254. issues_ts <- as.ts(issues[,2:44])
  255. VARselect(issues_ts, lag.max = 5, type = "both")
  256. vIssues <- VAR(issues_ts, p=5, type="both")
  257. vIssues <- VAR(issues_ts, p=1, type="both")
  258. issues_ts <- as.ts(issues)
  259. VARselect(issues[2:44], lag.max = 8, type = "both")
  260. summary(ur.df(issues_ts[, 2], type ="none", lags=1))
  261. VARselect(issues_ts, lag.max = 5, type = "both")
  262. issues_ts <- as.ts(issues[,2:44])
  263. VARselect(issues_ts, lag.max = 5, type = "both")
  264. VARselect(issues_ts, lag.max = 5, type = "both")
  265. VARselect(issues_ts, lag.max = 5, type = "both")
  266. VARselect(issues_ts, lag.max = 5, type = "both")
  267. VARselect(issues_ts, lag.max = 5, type = "both")
  268. VARselect(issues_ts, lag.max = 5, type = "both")
  269. VARselect(issues_ts, lag.max = 5, type = "both")
  270. summary(ur.df(issues_ts[, 2], type ="none", lags=1))
  271. ur.df(issues_ts[, 2], type ="none", lags=1)
  272. head(issues_ts)
  273. issues_ts$i1.macro
  274. issues_ts[, "i1.macro"]
  275. summary(ur.df(issues_ts[, "i1.macro"], type ="none", lags=1))
  276. ncol(issues_ts)
  277. for(i in 2:ncol(issues_ts)) {
  278. summary(ur.df(issues_ts[, i], type ="none", lags=1))
  279. }
  280. cat(summary(ur.df(issues_ts[, "i1.macro"], type ="none", lags=1)))
  281. paste(summary(ur.df(issues_ts[, "i1.macro"], type ="none", lags=1)))
  282. i
  283. summary(ur.df(issues_ts[, i], type ="none", lags=1))
  284. summary(ur.df(issues_ts[, 1], type ="none", lags=1))
  285. summary(ur.df(issues_ts[, 2], type ="none", lags=1))
  286. summary(ur.df(issues_ts[, 1], type ="none", lags=1))
  287. summary(ur.df(issues_ts[, 1], type ="none", lags=1))
  288. names(issues_ts)
  289. issues_ts[1,]
  290. summary(ur.df(issues_ts[, 1], type ="none", lags=1))
  291. summary(ur.df(issues_ts[, 2], type ="none", lags=1))
  292. summary(ur.df(issues_ts[, 43], type ="none", lags=1))
  293. summary(ur.df(issues_ts[, 43], type ="trend", lags=1))
  294. summary(ur.df(issues_ts[, 43], type ="none", lags=1))
  295. summary(ur.df(issues_ts[, 1], type ="none", lags=1))
  296. ur.df(issues_ts[, 1], type ="none", lags=1)
  297. for(i in 2:ncol(issues_ts)) {
  298. ur.df(issues_ts[, i], type ="none", lags=1)
  299. }
  300. ur.df(issues_ts[, i], type ="none", lags=1)
  301. test <- ur.df(issues_ts[, i], type ="none", lags=1)
  302. test
  303. for(i in 2:ncol(issues_ts)) {
  304. test <- ur.df(issues_ts[, i], type ="none", lags=1)
  305. cat(test)
  306. }
  307. class(test)
  308. as.character(test)
  309. for(i in 2:ncol(issues_ts)) {
  310. test[i] <- ur.df(issues_ts[, i], type ="none", lags=1)
  311. }
  312. ur.df(issues_ts[, 1], type ="none", lags=1)
  313. ur.df(issues_ts[, sprintf("%s", c(1,2,3))], type ="none", lags=1)
  314. ur.df(issues_ts[, sprintf("%i", c(1,2,3))], type ="none", lags=1)
  315. ur.df(issues_ts[, 2], type ="none", lags=1)
  316. ur.df(issues_ts[, 3], type ="none", lags=1)
  317. i <- 0
  318. i <- i + 1
  319. ur.df(issues_ts[, i], type ="none", lags=1)
  320. i <- i + 1
  321. ur.df(issues_ts[, i], type ="none", lags=1)
  322. i <- i + 1
  323. ur.df(issues_ts[, i], type ="none", lags=1)
  324. i <- i + 1
  325. ur.df(issues_ts[, i], type ="none", lags=1)
  326. i <- i + 1
  327. ur.df(issues_ts[, i], type ="none", lags=1)
  328. i <- i + 1
  329. ur.df(issues_ts[, i], type ="none", lags=1)
  330. i <- i + 1
  331. ur.df(issues_ts[, i], type ="none", lags=1)
  332. i <- i + 1
  333. ur.df(issues_ts[, i], type ="none", lags=1)
  334. i <- i + 1
  335. ur.df(issues_ts[, i], type ="none", lags=1)
  336. i <- i + 1
  337. ur.df(issues_ts[, i], type ="none", lags=1)
  338. i <- i + 1
  339. ur.df(issues_ts[, i], type ="none", lags=1)
  340. i <- i + 1
  341. ur.df(issues_ts[, i], type ="none", lags=1)
  342. i <- i + 1
  343. ur.df(issues_ts[, i], type ="none", lags=1)
  344. i <- i + 1
  345. ur.df(issues_ts[, i], type ="none", lags=1)
  346. i <- i + 1
  347. ur.df(issues_ts[, i], type ="none", lags=1)
  348. i <- i + 1
  349. ur.df(issues_ts[, i], type ="none", lags=1)
  350. i <- i + 1
  351. ur.df(issues_ts[, i], type ="none", lags=1)
  352. i <- i + 1
  353. ur.df(issues_ts[, i], type ="none", lags=1)
  354. i <- i + 1
  355. ur.df(issues_ts[, i], type ="none", lags=1)
  356. i <- i + 1
  357. ur.df(issues_ts[, i], type ="none", lags=1)
  358. i <- i + 1
  359. ur.df(issues_ts[, i], type ="none", lags=1)
  360. i <- i + 1
  361. ur.df(issues_ts[, i], type ="none", lags=1)
  362. i <- i + 1
  363. ur.df(issues_ts[, i], type ="none", lags=1)
  364. i <- i + 1
  365. ur.df(issues_ts[, i], type ="none", lags=1)
  366. i <- i + 1
  367. ur.df(issues_ts[, i], type ="none", lags=1)
  368. i <- i + 1
  369. ur.df(issues_ts[, i], type ="none", lags=1)
  370. i <- i + 1
  371. ur.df(issues_ts[, i], type ="none", lags=1)
  372. i <- i + 1
  373. ur.df(issues_ts[, i], type ="none", lags=1)
  374. i <- i + 1
  375. ur.df(issues_ts[, i], type ="none", lags=1)
  376. i <- i + 1
  377. ur.df(issues_ts[, i], type ="none", lags=1)
  378. i <- i + 1
  379. ur.df(issues_ts[, i], type ="none", lags=1)
  380. i <- i + 1
  381. ur.df(issues_ts[, i], type ="none", lags=1)
  382. i <- i + 1
  383. ur.df(issues_ts[, i], type ="none", lags=1)
  384. i <- i + 1
  385. ur.df(issues_ts[, i], type ="none", lags=1)
  386. i <- i + 1
  387. ur.df(issues_ts[, i], type ="none", lags=1)
  388. i <- i + 1
  389. ur.df(issues_ts[, i], type ="none", lags=1)
  390. i <- i + 1
  391. ur.df(issues_ts[, i], type ="none", lags=1)
  392. i <- i + 1
  393. ur.df(issues_ts[, i], type ="none", lags=1)
  394. i <- i + 1
  395. ur.df(issues_ts[, i], type ="none", lags=1)
  396. i <- i + 1
  397. ur.df(issues_ts[, i], type ="none", lags=1)
  398. i <- i + 1
  399. ur.df(issues_ts[, i], type ="none", lags=1)
  400. i <- i + 1
  401. ur.df(issues_ts[, i], type ="none", lags=1)
  402. i <- i + 1
  403. ur.df(issues_ts[, i], type ="none", lags=1)
  404. i <- i + 1
  405. ur.df(issues_ts[, i], type ="none", lags=1)
  406. i
  407. issueheads
  408. length(issuelist[[2]])
  409. # List all issues in one row
  410. for(i in 1:length(issueheads)) {
  411. cat(issueheads[i], "\n")
  412. }
  413. vIssues <- VAR(issues_ts, p=1, type="both")
  414. issues_ts[1:20,1]
  415. issues_ts[,1]
  416. issues_ts[1,]
  417. issues_ts[1:21,]
  418. issues_ts[,1:21]
  419. issues_ts[1,1:21]
  420. issues_ts[1,22:43]
  421. issues_ts[1,22:44]
  422. issues_ts[1,22:43]
  423. plot(irf(vIssues, impulse = names(issues_ts[1:21]), response = names(issues_i[22:43])))
  424. require(stringr)
  425. require(reshape2)
  426. require(ggplot2)
  427. require(vars)
  428. vIssues
  429. plot(irf(vIssues, impulse = names(issues_ts[1:21]), response = names(issues_i[22:43])))
  430. plot(irf(vIssues, impulse = names(issues_ts[1:21]), response = names(issues_ts[22:43])))
  431. issues_s
  432. names(issues_s)
  433. names(issues_s[2:23])
  434. names(issuesi[2:22])
  435. names(issues_i[2:22])
  436. plot(irf(vIssues, impulse = names(issues_s[2:23]), response = names(issues_i[2:22])))
  437. plot(irf(vIssues, impulse = names(issues_s[2:23]), response = names(issues_i[2:22])))
  438. plot(irf(vIssues, impulse = names(issues_s[2:23]), response = names(issues_i[2:22])))
  439. irf(vIssues, impulse = names(issues_s[2:23]), response = names(issues_i[2:22]))
  440. vIRF <- irf(vIssues, impulse = names(issues_s[2:23]), response = names(issues_i[2:22]))
  441. summary(vIRF)
  442. vIRF$irf
  443. vIRF$boot
  444. vIRF$ortho
  445. vIRF$Lower
  446. vIRF$irf[1]
  447. vIRF$irf["s.boko"]
  448. summary(issues$hk)
  449. summary(issues$s.hk)
  450. summary(issues$s.nsa)
  451. summary(issues$s.gaza)
  452. summary(issues$s.boko)
  453. summary(issues$s.ebola)
  454. summary(issues$s.edathy)
  455. summary(issues$s.ferguson)
  456. summary(issues$s.gurlitt)
  457. summary(issues$s.is)
  458. summary(issues$s.pegida)
  459. summary(issues$s.schumi)
  460. summary(issues$s.tebartz)
  461. summary(issues$s.wm)
  462. summary(issues$s.wulff)
  463. plot(vIRF)
  464. names(issues)
  465. summary(issues[2:44])
  466. plot(vIRF)
  467. plot(vIRF, x=300, y=200)
  468. plot(vIRF, res = 300)
  469. plot(vIRF[1])
  470. plot(vIRF$irf[1])
  471. summary(issues[2:44])
  472. ur.df(issues_ts[, i], type ="none", lags=1)
  473. summary(ur.df(issues_ts[, i], type ="none", lags=1))
  474. summary(ur.df(issues_ts[,30], type ="none", lags=1))
  475. summary(issues[2])
  476. stats_entropy
  477. names(issues)
  478. issues_bak <- issues
  479. issues$total <- rowSums(issues[2:ncol(issues)])
  480. issues$entropy <- 0
  481. names(issues)
  482. issues$total <- rowSums(issues[2:ncol(issues)])
  483. issues$entropy <- 0
  484. for(r in 1:nrow(issues)) {
  485. curtotal <- as.numeric(issues$total[r])
  486. curp <- 0
  487. for(c in 2:ncol(issues)) {
  488. curcount <- as.numeric(issues[r,c])
  489. curp[c] <- curcount / curtotal
  490. }
  491. curp <- curp [2:length(curp)-2]
  492. curdrop <- which(curp==0)
  493. curp <- curp[-curdrop]
  494. issues$entropy[r] <- sum(-1 * curp * log(curp))
  495. }
  496. stats_entropy <- data.frame(date=drange)
  497. stats_entropy$entropy <- issues$entropy
  498. stats_entropy <- melt(stats_entropy, id="date")
  499. g_entrop <- ggplot(data = stats_entropy, aes(x=date,y=value,colour=variable, group=variable)) +
  500. geom_line() +
  501. geom_smooth(size=1,formula = y ~ x, method="loess", se=FALSE, color=1) +
  502. xlab("Zeitraum") + ylab("Entropie") +
  503. scale_colour_discrete(name = "", labels = "Entropie") +
  504. theme(legend.title = element_text(size=14)) +
  505. theme(legend.text = element_text(size=12)) +
  506. theme(axis.title = element_text(size = 14))
  507. g_entrop
  508. View(issues)
  509. summary(issues$entropy)
  510. summary(issues$total)
  511. stats_total
  512. summary(issues[2:44])