Diffusion Index and graph in via a ggplot
# Diffusion Index and graph in via a ggplot
ts_info(UNRATE)
The UNRATE series is a xts object with 1 variable and 179 observations
Frequency: monthly
Start time: 2010-01-01
End time: 2024-11-01
ts_info(CES0500000003)
The CES0500000003 series is a xts object with 1 variable and 179 observations
Frequency: monthly
Start time: 2010-01-01
End time: 2024-11-01
ts_info(CPIAUCSL)
The CPIAUCSL series is a xts object with 1 variable and 179 observations
Frequency: monthly
Start time: 2010-01-01
End time: 2024-11-01
unemp = UNRATE
avghr = CES0500000003
cpi = CPIAUCSL
ts_info(unemp)
The unemp series is a xts object with 1 variable and 179 observations
Frequency: monthly
Start time: 2010-01-01
End time: 2024-11-01
ts_info(avghr)
The avghr series is a xts object with 1 variable and 179 observations
Frequency: monthly
Start time: 2010-01-01
End time: 2024-11-01
ts_info(cpi)
The cpi series is a xts object with 1 variable and 179 observations
Frequency: monthly
Start time: 2010-01-01
End time: 2024-11-01
#covert to ts
unemp <- unemp["2010-01-01/2024-10-01"] |> ts_ts()
avghr <- avghr["2010-01-01/2024-10-01"] |> ts_ts()
cpi <- cpi["2010-01-01/2024-10-01"] |> ts_ts()
#
#assemble it
mydata = cbind.data.frame(unemp,avghr,cpi)
head(mydata,3)
#' Obtain first differences
mydf = mydata %>%
mutate(unempD1 = tsibble::difference(unemp, differences = 1),
avghrD1 = tsibble::difference(avghr, differences = 1),
cpiD1 = tsibble::difference(cpi, differences = 1)) %>%
dplyr::select(c(unempD1, avghrD1, cpiD1)) |> na.omit()
colSums(is.na(mydf))
unempD1 avghrD1 cpiD1
0 0 0
# Convert to either up or down
head(mydf,3)
mydf_df = ifelse(mydf > 0, 1, -1 )
mydf_df
unempD1 avghrD1 cpiD1
2 -1 1 -1
3 1 1 1
4 -1 1 1
5 -1 1 -1
6 -1 -1 -1
7 -1 1 1
8 1 1 1
9 -1 1 1
10 -1 1 1
11 1 -1 1
12 -1 1 1
13 -1 1 1
14 -1 1 1
15 -1 -1 1
16 1 1 1
17 -1 1 1
18 1 1 -1
19 -1 1 1
20 -1 -1 1
21 -1 1 1
22 -1 1 1
23 -1 -1 1
24 -1 1 1
25 -1 1 1
26 -1 1 1
27 -1 1 1
28 -1 1 1
29 -1 1 -1
30 -1 1 -1
31 -1 1 1
32 -1 -1 1
33 -1 1 1
34 -1 -1 1
35 -1 1 -1
36 1 1 -1
37 1 1 1
38 -1 1 1
39 -1 1 -1
40 1 1 -1
41 -1 1 1
42 -1 1 1
43 -1 1 1
44 -1 1 1
45 -1 1 1
46 -1 1 1
47 -1 1 1
48 -1 1 1
49 -1 1 1
50 1 1 1
51 -1 -1 1
52 -1 1 1
53 1 1 1
54 -1 1 1
55 1 1 1
56 -1 1 -1
57 -1 1 1
58 -1 1 -1
59 1 1 -1
60 -1 -1 -1
61 1 1 -1
62 -1 1 1
63 -1 1 1
64 -1 1 1
65 1 1 1
66 -1 -1 1
67 -1 1 1
68 -1 1 -1
69 -1 1 -1
70 -1 1 1
71 1 1 1
72 -1 -1 -1
73 -1 1 -1
74 1 -1 -1
75 1 1 1
76 1 1 1
77 -1 1 1
78 1 1 1
79 -1 1 -1
80 1 1 1
81 1 1 1
82 -1 1 1
83 -1 1 1
84 -1 1 1
85 -1 1 1
86 -1 1 1
87 -1 1 -1
88 -1 1 1
89 -1 1 -1
90 -1 1 1
91 -1 1 1
92 1 1 1
93 -1 1 1
94 -1 -1 1
95 -1 1 1
96 -1 1 1
97 -1 1 1
98 1 1 1
99 -1 1 1
100 -1 1 1
101 -1 1 1
102 1 1 1
103 -1 1 1
104 -1 1 1
105 -1 1 1
106 1 1 1
107 -1 1 -1
108 1 1 1
109 1 1 -1
110 -1 1 1
111 -1 1 1
112 -1 -1 1
113 -1 1 1
114 -1 1 -1
115 1 1 1
116 -1 1 1
117 -1 1 1
118 1 1 1
119 -1 1 1
120 -1 1 1
121 -1 1 1
122 -1 1 1
123 1 1 -1
124 1 1 -1
125 -1 -1 -1
126 -1 -1 1
127 -1 -1 1
128 -1 1 1
129 -1 1 1
130 -1 1 1
131 -1 1 1
132 -1 1 1
133 -1 1 1
134 -1 1 1
135 -1 -1 1
136 -1 1 1
137 -1 1 1
138 1 1 1
139 -1 1 1
140 -1 1 1
141 -1 1 1
142 -1 1 1
143 -1 1 1
144 -1 1 1
145 1 1 1
146 -1 1 1
147 -1 1 1
148 1 1 1
149 -1 1 1
150 -1 1 1
151 -1 1 -1
152 1 1 1
153 -1 1 1
154 1 1 1
155 -1 1 1
156 -1 1 1
157 -1 1 1
158 1 1 1
159 -1 1 1
160 -1 1 1
161 1 1 1
162 -1 1 1
163 -1 1 1
164 1 1 1
165 -1 1 1
166 -1 1 1
167 -1 1 1
168 -1 1 1
169 -1 1 1
170 1 1 1
171 -1 1 1
172 1 1 1
173 1 1 1
174 1 1 -1
175 1 1 1
176 -1 1 1
177 -1 1 1
178 -1 1 1
table(mydf_df)
mydf_df
-1 1
182 349
#convert to up,down, or no change
mydf_mat = apply(mydf, 2, sign)
table(mydf_mat)
mydf_mat
-1 0 1
132 50 349
mydf_mat
unempD1 avghrD1 cpiD1
2 0 1 -1
3 1 1 1
4 0 1 1
5 -1 1 -1
6 -1 0 -1
7 0 1 1
8 1 1 1
9 0 1 1
10 -1 1 1
11 1 -1 1
12 -1 1 1
13 -1 1 1
14 -1 1 1
15 0 0 1
16 1 1 1
17 -1 1 1
18 1 1 0
19 -1 1 1
20 0 -1 1
21 0 1 1
22 -1 1 1
23 -1 -1 1
24 -1 1 1
25 -1 1 1
26 0 1 1
27 -1 1 1
28 0 1 1
29 0 1 -1
30 0 1 -1
31 0 1 1
32 -1 -1 1
33 -1 1 1
34 0 -1 1
35 -1 1 -1
36 1 1 -1
37 1 1 1
38 -1 1 1
39 -1 1 -1
40 1 1 -1
41 -1 1 1
42 0 1 1
43 -1 1 1
44 -1 1 1
45 0 1 1
46 0 1 1
47 -1 1 1
48 -1 1 1
49 -1 1 1
50 1 1 1
51 0 -1 1
52 -1 1 1
53 1 1 1
54 -1 1 1
55 1 1 1
56 -1 1 -1
57 -1 1 1
58 -1 1 -1
59 1 1 -1
60 -1 -1 -1
61 1 1 -1
62 -1 1 1
63 -1 1 1
64 0 1 1
65 1 1 1
66 -1 0 1
67 -1 1 1
68 -1 1 -1
69 -1 1 -1
70 0 1 1
71 1 1 1
72 -1 -1 -1
73 -1 1 -1
74 1 0 -1
75 1 1 1
76 1 1 1
77 -1 1 1
78 1 1 1
79 -1 1 -1
80 1 1 1
81 1 1 1
82 -1 1 1
83 -1 1 1
84 0 1 1
85 0 1 1
86 -1 1 1
87 -1 1 -1
88 0 1 1
89 0 1 -1
90 -1 1 1
91 0 1 1
92 1 1 1
93 -1 1 1
94 -1 0 1
95 0 1 1
96 -1 1 1
97 -1 1 1
98 1 1 1
99 -1 1 1
100 0 1 1
101 -1 1 1
102 1 1 1
103 -1 1 1
104 0 1 1
105 -1 1 1
106 1 1 1
107 0 1 -1
108 1 1 1
109 1 1 -1
110 -1 1 1
111 0 1 1
112 -1 -1 1
113 -1 1 1
114 0 1 -1
115 1 1 1
116 -1 1 1
117 -1 1 1
118 1 1 1
119 0 1 1
120 0 1 1
121 0 1 1
122 -1 1 1
123 1 1 -1
124 1 1 -1
125 -1 -1 -1
126 -1 -1 1
127 -1 0 1
128 -1 1 1
129 -1 1 1
130 -1 1 1
131 -1 1 1
132 0 1 1
133 -1 1 1
134 -1 1 1
135 -1 0 1
136 0 1 1
137 -1 1 1
138 1 1 1
139 -1 1 1
140 -1 1 1
141 -1 1 1
142 -1 1 1
143 -1 1 1
144 -1 1 1
145 1 1 1
146 -1 1 1
147 -1 1 1
148 1 1 1
149 -1 1 1
150 0 1 1
151 -1 1 -1
152 1 1 1
153 -1 1 1
154 1 1 1
155 0 1 1
156 -1 1 1
157 -1 1 1
158 1 1 1
159 -1 1 1
160 -1 1 1
161 1 1 1
162 -1 1 1
163 -1 1 1
164 1 1 1
165 0 1 1
166 0 1 1
167 -1 1 1
168 0 1 1
169 0 1 1
170 1 1 1
171 -1 1 1
172 1 1 1
173 1 1 1
174 1 1 -1
175 1 1 1
176 -1 1 1
177 -1 1 1
178 0 1 1
pos = apply(mydf_mat, 1, function(row) sum(row>0) ) # counts the positive
neg = apply(mydf_mat, 1, function(row) sum(row<0) ) # counts the negatives
#pos = apply(mydf, 1, function(row) sum(row>0) ) # counts the positive
#neg = apply(mydf, 1, function(row) sum(row<0) ) # counts the negatives
tot = pos + neg
(index = (pos/tot - neg/tot))
2 3 4 5 6 7 8
0.0000000 1.0000000 1.0000000 -0.3333333 -1.0000000 1.0000000 1.0000000
9 10 11 12 13 14 15
1.0000000 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 1.0000000
16 17 18 19 20 21 22
1.0000000 0.3333333 1.0000000 0.3333333 0.0000000 1.0000000 0.3333333
23 24 25 26 27 28 29
-0.3333333 0.3333333 0.3333333 1.0000000 0.3333333 1.0000000 0.0000000
30 31 32 33 34 35 36
0.0000000 1.0000000 -0.3333333 0.3333333 0.0000000 -0.3333333 0.3333333
37 38 39 40 41 42 43
1.0000000 0.3333333 -0.3333333 0.3333333 0.3333333 1.0000000 0.3333333
44 45 46 47 48 49 50
0.3333333 1.0000000 1.0000000 0.3333333 0.3333333 0.3333333 1.0000000
51 52 53 54 55 56 57
0.0000000 0.3333333 1.0000000 0.3333333 1.0000000 -0.3333333 0.3333333
58 59 60 61 62 63 64
-0.3333333 0.3333333 -1.0000000 0.3333333 0.3333333 0.3333333 1.0000000
65 66 67 68 69 70 71
1.0000000 0.0000000 0.3333333 -0.3333333 -0.3333333 1.0000000 1.0000000
72 73 74 75 76 77 78
-1.0000000 -0.3333333 0.0000000 1.0000000 1.0000000 0.3333333 1.0000000
79 80 81 82 83 84 85
-0.3333333 1.0000000 1.0000000 0.3333333 0.3333333 1.0000000 1.0000000
86 87 88 89 90 91 92
0.3333333 -0.3333333 1.0000000 0.0000000 0.3333333 1.0000000 1.0000000
93 94 95 96 97 98 99
0.3333333 0.0000000 1.0000000 0.3333333 0.3333333 1.0000000 0.3333333
100 101 102 103 104 105 106
1.0000000 0.3333333 1.0000000 0.3333333 1.0000000 0.3333333 1.0000000
107 108 109 110 111 112 113
0.0000000 1.0000000 0.3333333 0.3333333 1.0000000 -0.3333333 0.3333333
114 115 116 117 118 119 120
0.0000000 1.0000000 0.3333333 0.3333333 1.0000000 1.0000000 1.0000000
121 122 123 124 125 126 127
1.0000000 0.3333333 0.3333333 0.3333333 -1.0000000 -0.3333333 0.0000000
128 129 130 131 132 133 134
0.3333333 0.3333333 0.3333333 0.3333333 1.0000000 0.3333333 0.3333333
135 136 137 138 139 140 141
0.0000000 1.0000000 0.3333333 1.0000000 0.3333333 0.3333333 0.3333333
142 143 144 145 146 147 148
0.3333333 0.3333333 0.3333333 1.0000000 0.3333333 0.3333333 1.0000000
149 150 151 152 153 154 155
0.3333333 1.0000000 -0.3333333 1.0000000 0.3333333 1.0000000 1.0000000
156 157 158 159 160 161 162
0.3333333 0.3333333 1.0000000 0.3333333 0.3333333 1.0000000 0.3333333
163 164 165 166 167 168 169
0.3333333 1.0000000 1.0000000 1.0000000 0.3333333 1.0000000 1.0000000
170 171 172 173 174 175 176
1.0000000 0.3333333 1.0000000 1.0000000 0.3333333 1.0000000 0.3333333
177 178
0.3333333 1.0000000
table(index)
index
-1 -0.333333333333333 0 0.333333333333333
4 15 14 77
1
67
str(index)
Named num [1:177] 0 1 1 -0.333 -1 ...
- attr(*, "names")= chr [1:177] "2" "3" "4" "5" ...
Date = seq.Date(from = as.Date("2010-05-1"), length.out = 177, by = "month")
length(Date)
[1] 177
index_df <- data.frame(index = index, time = Date)
cbind(mydf_mat, pos, neg, tot, index)
unempD1 avghrD1 cpiD1 pos neg tot index
2 0 1 -1 1 1 2 0.0000000
3 1 1 1 3 0 3 1.0000000
4 0 1 1 2 0 2 1.0000000
5 -1 1 -1 1 2 3 -0.3333333
6 -1 0 -1 0 2 2 -1.0000000
7 0 1 1 2 0 2 1.0000000
8 1 1 1 3 0 3 1.0000000
9 0 1 1 2 0 2 1.0000000
10 -1 1 1 2 1 3 0.3333333
11 1 -1 1 2 1 3 0.3333333
12 -1 1 1 2 1 3 0.3333333
13 -1 1 1 2 1 3 0.3333333
14 -1 1 1 2 1 3 0.3333333
15 0 0 1 1 0 1 1.0000000
16 1 1 1 3 0 3 1.0000000
17 -1 1 1 2 1 3 0.3333333
18 1 1 0 2 0 2 1.0000000
19 -1 1 1 2 1 3 0.3333333
20 0 -1 1 1 1 2 0.0000000
21 0 1 1 2 0 2 1.0000000
22 -1 1 1 2 1 3 0.3333333
23 -1 -1 1 1 2 3 -0.3333333
24 -1 1 1 2 1 3 0.3333333
25 -1 1 1 2 1 3 0.3333333
26 0 1 1 2 0 2 1.0000000
27 -1 1 1 2 1 3 0.3333333
28 0 1 1 2 0 2 1.0000000
29 0 1 -1 1 1 2 0.0000000
30 0 1 -1 1 1 2 0.0000000
31 0 1 1 2 0 2 1.0000000
32 -1 -1 1 1 2 3 -0.3333333
33 -1 1 1 2 1 3 0.3333333
34 0 -1 1 1 1 2 0.0000000
35 -1 1 -1 1 2 3 -0.3333333
36 1 1 -1 2 1 3 0.3333333
37 1 1 1 3 0 3 1.0000000
38 -1 1 1 2 1 3 0.3333333
39 -1 1 -1 1 2 3 -0.3333333
40 1 1 -1 2 1 3 0.3333333
41 -1 1 1 2 1 3 0.3333333
42 0 1 1 2 0 2 1.0000000
43 -1 1 1 2 1 3 0.3333333
44 -1 1 1 2 1 3 0.3333333
45 0 1 1 2 0 2 1.0000000
46 0 1 1 2 0 2 1.0000000
47 -1 1 1 2 1 3 0.3333333
48 -1 1 1 2 1 3 0.3333333
49 -1 1 1 2 1 3 0.3333333
50 1 1 1 3 0 3 1.0000000
51 0 -1 1 1 1 2 0.0000000
52 -1 1 1 2 1 3 0.3333333
53 1 1 1 3 0 3 1.0000000
54 -1 1 1 2 1 3 0.3333333
55 1 1 1 3 0 3 1.0000000
56 -1 1 -1 1 2 3 -0.3333333
57 -1 1 1 2 1 3 0.3333333
58 -1 1 -1 1 2 3 -0.3333333
59 1 1 -1 2 1 3 0.3333333
60 -1 -1 -1 0 3 3 -1.0000000
61 1 1 -1 2 1 3 0.3333333
62 -1 1 1 2 1 3 0.3333333
63 -1 1 1 2 1 3 0.3333333
64 0 1 1 2 0 2 1.0000000
65 1 1 1 3 0 3 1.0000000
66 -1 0 1 1 1 2 0.0000000
67 -1 1 1 2 1 3 0.3333333
68 -1 1 -1 1 2 3 -0.3333333
69 -1 1 -1 1 2 3 -0.3333333
70 0 1 1 2 0 2 1.0000000
71 1 1 1 3 0 3 1.0000000
72 -1 -1 -1 0 3 3 -1.0000000
73 -1 1 -1 1 2 3 -0.3333333
74 1 0 -1 1 1 2 0.0000000
75 1 1 1 3 0 3 1.0000000
76 1 1 1 3 0 3 1.0000000
77 -1 1 1 2 1 3 0.3333333
78 1 1 1 3 0 3 1.0000000
79 -1 1 -1 1 2 3 -0.3333333
80 1 1 1 3 0 3 1.0000000
81 1 1 1 3 0 3 1.0000000
82 -1 1 1 2 1 3 0.3333333
83 -1 1 1 2 1 3 0.3333333
84 0 1 1 2 0 2 1.0000000
85 0 1 1 2 0 2 1.0000000
86 -1 1 1 2 1 3 0.3333333
87 -1 1 -1 1 2 3 -0.3333333
88 0 1 1 2 0 2 1.0000000
89 0 1 -1 1 1 2 0.0000000
90 -1 1 1 2 1 3 0.3333333
91 0 1 1 2 0 2 1.0000000
92 1 1 1 3 0 3 1.0000000
93 -1 1 1 2 1 3 0.3333333
94 -1 0 1 1 1 2 0.0000000
95 0 1 1 2 0 2 1.0000000
96 -1 1 1 2 1 3 0.3333333
97 -1 1 1 2 1 3 0.3333333
98 1 1 1 3 0 3 1.0000000
99 -1 1 1 2 1 3 0.3333333
100 0 1 1 2 0 2 1.0000000
101 -1 1 1 2 1 3 0.3333333
102 1 1 1 3 0 3 1.0000000
103 -1 1 1 2 1 3 0.3333333
104 0 1 1 2 0 2 1.0000000
105 -1 1 1 2 1 3 0.3333333
106 1 1 1 3 0 3 1.0000000
107 0 1 -1 1 1 2 0.0000000
108 1 1 1 3 0 3 1.0000000
109 1 1 -1 2 1 3 0.3333333
110 -1 1 1 2 1 3 0.3333333
111 0 1 1 2 0 2 1.0000000
112 -1 -1 1 1 2 3 -0.3333333
113 -1 1 1 2 1 3 0.3333333
114 0 1 -1 1 1 2 0.0000000
115 1 1 1 3 0 3 1.0000000
116 -1 1 1 2 1 3 0.3333333
117 -1 1 1 2 1 3 0.3333333
118 1 1 1 3 0 3 1.0000000
119 0 1 1 2 0 2 1.0000000
120 0 1 1 2 0 2 1.0000000
121 0 1 1 2 0 2 1.0000000
122 -1 1 1 2 1 3 0.3333333
123 1 1 -1 2 1 3 0.3333333
124 1 1 -1 2 1 3 0.3333333
125 -1 -1 -1 0 3 3 -1.0000000
126 -1 -1 1 1 2 3 -0.3333333
127 -1 0 1 1 1 2 0.0000000
128 -1 1 1 2 1 3 0.3333333
129 -1 1 1 2 1 3 0.3333333
130 -1 1 1 2 1 3 0.3333333
131 -1 1 1 2 1 3 0.3333333
132 0 1 1 2 0 2 1.0000000
133 -1 1 1 2 1 3 0.3333333
134 -1 1 1 2 1 3 0.3333333
135 -1 0 1 1 1 2 0.0000000
136 0 1 1 2 0 2 1.0000000
137 -1 1 1 2 1 3 0.3333333
138 1 1 1 3 0 3 1.0000000
139 -1 1 1 2 1 3 0.3333333
140 -1 1 1 2 1 3 0.3333333
141 -1 1 1 2 1 3 0.3333333
142 -1 1 1 2 1 3 0.3333333
143 -1 1 1 2 1 3 0.3333333
[ reached getOption("max.print") -- omitted 35 rows ]
ma_index = zoo::rollmean(index, 7, align = "right")
length(index)
[1] 177
ggplot(index_df, aes(x = time, y=index) ) +
geom_line(color = "darkblue") +
geom_hline(yintercept = 0, color = "darkred") +
labs(title = "US Economy Diffusion Index", x = "Observation", y = "Index Value") +
theme_minimal()
Diffusion Index and graph in via a ggplot with a built in smoother or you create the smoother.
#Diffusion Index and graph in via a ggplot with a built in smoother or you create the smoother.
g1 = ggplot(index_df, aes(x = time, y = index)) +
geom_line(color = "darkblue")+
geom_hline(yintercept = 0, color = "darkred")+
geom_smooth(colour = "darkgreen") +
labs( title = "US Economy Diffusion Index with Smoother") +
xlab("Months") +
ylab("Change")+
theme(axis.line.x = element_line(size= 0.75, colour = "black"),
axis.line.y = element_line(size= 0.75, colour = "black"),
legend.position = "bottom",
legend.direction = "horizontal", element_blank()) +
theme_tufte()
g1
Chicago Fed National Activity Index: Diffusion Index (CFNAIDIFF)
cfnaid = CFNAIDIFF
ts_info(CFNAIDIFF)
The CFNAIDIFF series is a xts object with 1 variable and 178 observations
Frequency: monthly
Start time: 2010-01-01
End time: 2024-10-01
#convert to ts
cfnaid <- cfnaid["2010-01-01/2024-10-01"] |> ts_ts()
length(cfnaid)
[1] 178
# Convert cfnaid to a data frame
cfnaid_df <- data.frame(Date = Date, cfnaid = as.numeric(cfnaid[-c(1)]))
g2 = ggplot(cfnaid_df, aes(x = Date, y = cfnaid)) +
geom_line(color = "orangered")+
geom_hline(yintercept = 0, color = "darkred") +
geom_smooth(colour = "darkgreen") +
labs( title = "Chicago Fed National Activity Index: Diffusion Index with smoother") +
xlab("Months") +
ylab("Change")+
theme(axis.line.x = element_line(size= 0.75, colour = "black"),
axis.line.y = element_line(size= 0.75, colour = "black"),
legend.position = "bottom",
legend.direction = "horizontal", element_blank()) +
theme_tufte()
g2
grid.arrange(g1, g2, nrow = 2)
correlation_df = cbind.data.frame(mydata,cfnaid)
correlation_coefficient = cor(correlation_df)
correlation_coefficient
unemp avghr cpi cfnaid
unemp 1.0000000 -0.59759267 -0.62428677 0.19477706
avghr -0.5975927 1.00000000 0.98786874 -0.04384157
cpi -0.6242868 0.98786874 1.00000000 -0.07225501
cfnaid 0.1947771 -0.04384157 -0.07225501 1.00000000
corrplot(correlation_coefficient, method = "color")
combined_data <- data.frame(Date = Date,
`US Economy Diffusion Index` = index,
`Chicago Fed National Activity Diffusion Index` = cfnaid[-1])
ggplot(combined_data) +
geom_line(aes(x = Date, y = US.Economy.Diffusion.Index,
color = "US Economy Diffusion Index")) +
geom_line(aes(x = Date, y = Chicago.Fed.National.Activity.Diffusion.Index,
color = "Chicago Fed National Activity Diffusion Index")) +
geom_hline(yintercept = 0, color = "darkred") +
labs(title = "Comparison of US Economy Diffusion Index and Chicago Fed National Activity Diffusion Index",
x = "Months", y = "Change", color = "Index Type") +
scale_color_manual(values = c("US Economy Diffusion Index" = "darkblue",
"Chicago Fed National Activity Diffusion Index" = "orangered")) +
theme(axis.line.x = element_line(size = 0.75, colour = "black"),
axis.line.y = element_line(size = 0.75, colour = "black")) +
theme_tufte()+
theme(legend.position = "top",
plot.title = element_text(size = 12))
NA
NA
NA
NA