-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4.1 textDescriptives.do
86 lines (77 loc) · 3.41 KB
/
4.1 textDescriptives.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cls
clear
// set scheme s2color
set scheme s1mono
eststo clear
set graphics on
use ".\data\main.dta", clear
//--------------------------------------------------
// Descriptive charts
//--------------------------------------------------
// Raw word count
sort date
tsset date // Set timeseries to 'natural dates' to get even spacing. As soon as we're not looking solely at financial data, natural dates are the proper series. When generating lags for financial ts, remember to temporarily switch back to the bcal!
label var wordcntfiltered "Word count"
label var paracnt "Paragraph count"
tsline paracnt, yaxis(1) lcolor(maroon) || tsline wordcntfiltered, yaxis(2) lcolor(navy) legend(order(2 "Words (filtered)" 1 "Paragraphs"))
graph export ".\img\desc\totalNumberWords.png", as(png) replace
// ABSOLUTE SENTIMENT WORD COUNT FIGURE
gen rectemp = recession*300-6
twoway (area rectemp date, color(gs14) base(-6)) (tsline poscnt negcnt uncertcnt, ///
lcolor(forest_green cranberry navy)), legend(region(lwidth(0)) label(1 "Recession") label(2 "Positive") label(3 "Negative") label(4 "Uncertain")) ///
ytitle("Word count") xtitle("")
graph export ".\img\desc\abscontentCounts.png", as(png) replace
drop rectemp
// RELATIVE SENTIMENT FIGURE
gen relpos = poscnt/wordcntfiltered
gen relneg = negcnt/wordcntfiltered
gen relunc = uncertcnt/wordcntfiltered
quietly sum relneg
gen rectemp = recession*(r(max)+0.01)
twoway (area rectemp date, color(gs14)) (tsline relpos relneg relunc, lcolor(forest_green cranberry navy)), ///
ytitle("Term fraction") xtitle("") yline(0.06) ///
legend(region(lwidth(0)) label(1 "Recession") label(2 "Positive") label(3 "Negative") label(4 "Uncertain"))
graph export ".\img\desc\relContentCounts.png", as(png) replace
// SUMMARY STATS TABLE
// tsline paracnt, lcolor(navy maroon) ytitle("Total paragraph count") xtitle("")
// graph export ".\img\totalNumberParagraphs.png", as(png) replace
gen avgwordsperpara = wordcntfiltered/paracnt
// gen avgwordsperparaRAW = wordcntraw/paracnt
// tsline avgwordsperpara avgwordsperparaRAW, lcolor(navy maroon) ytitle("Total paragraph count") xtitle("")
// graph export ".\img\avgWordsPerParagraph.png", as(png) replace
estpost sum wordcntfiltered wordcntraw paracnt avgwordsperpara
esttab, cells("mean sd min max") nonumber nomtitle noobs
// NAIVE TONE FIGURE
capture drop rectemp
gen rectemp = recession*15-6
twoway (area rectemp date, color(gs14) base(-6)) (tsline dl_nettone dl_uncert dl_pos dl_neg, lcolor(navy orange forest_green cranberry) legend(region(lwidth(0)) label(1 "Recession"))), ytitle("Tone score") xtitle("") yline(0)
graph export ".\img\desc\naiveToneProg.png", as(png) replace
// TOPIC-TONE FIGURE
set graphics off
local tones "nmfnet nmfpos nmfneg nmfuncert"
graph drop _all
local graphs = ""
foreach var in `tones'{
di "`var'"
local max 0
local min 0
foreach tone of varlist `var'*{
sum `tone'
if `r(max)' > `max'{
local max `r(max)'
}
if `r(min)' < `min'{
local min `r(min)'
}
di "`max' `min'"
}
di "`max' `min'"
capture drop rectemp
gen rectemp = (recession)*(`max'-`min')+`min'
twoway (area rectemp date, color(gs14) base(`min')) (tsline `var'*, lcolor(navy orange forest_green cranberry) legend(region(lwidth(0)) label(1 "Recession"))), ytitle("Tone score") xtitle("") yline(0) name(`var') title(`var')
local graphs "`graphs' `var'"
di "`graphs'"
}
set graphics on
graph combine `graphs', iscale(0.5)
graph export ".\img\desc\topicToneProg.png", as(png) replace