Below are cor.tests for 2016 and 2017 candidates vs. 2018 BPS501 results per precinct. A full list of non protected precinct data is below with 2016, 2017 election results and 2018 BPS bond results. You will need to view this on a wide screen, not a phone. This is stats heavy with no added chit chat.
Gender by Age for all "Good" Ballots
dcast(z1[,.N,.(Gender,Decade=Age%/%10)][order(-N)],Decade ~ Gender,value.var="N",fun.aggregate=sum)[1:10,1:3]Decade F M
1: 1 99 81
2: 2 969 750
3: 3 1417 1166
4: 4 1917 1605
5: 5 2118 1817
6: 6 3494 2887
7: 7 2654 2408
8: 8 983 854
9: 9 282 141
10: 10 6 3
Cor.test with p-values
# Cor.test (with p-values)# Clinton
r7[,.(Clinton,BPS=as.numeric(BPS501_YES))][,cor.test(Clinton,BPS)]
Pearson's product-moment correlation
data: Clinton and BPS
t = 9.1318, df = 85, p-value = 2.92e-14
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.5788824 0.7963225
sample estimates:
cor
0.7037188
# Trump
r7[,.(Trump,BPS=as.numeric(BPS501_NO))][,cor.test(Trump,BPS)]
Pearson's product-moment correlation
data: Trump and BPS
t = 12.616, df = 85, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.7190294 0.8700613
sample estimates:
cor
0.8073887
# Buchanan
r7[,.(Bu=Buchanan,BPS=as.numeric(BPS501_YES))][,cor.test(Bu,BPS)]
Pearson's product-moment correlation
data: Bu and BPS
t = 20.609, df = 85, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.8693339 0.9422843
sample estimates:
cor
0.9128227
# Robinson
r7[,.(Ro=Robinson,BPS=as.numeric(BPS501_NO))][,cor.test(Ro,BPS)]
Pearson's product-moment correlation
data: Ro and BPS
t = 16.904, df = 85, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.8186569 0.9186691
sample estimates:
cor
0.8779106
# Clinton Stein
r7[,.(CS=Clinton + Stein,BPS=as.numeric(BPS501_YES))][,cor.test(CS,BPS)]
Pearson's product-moment correlation
data: CS and BPS
t = 8.5705, df = 85, p-value = 3.998e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.5489351 0.7796804
sample estimates:
cor
0.6808546
# Trump Johnson
r7[,.(TJ=Trump + Johnson,BPS=as.numeric(BPS501_NO))][,cor.test(TJ,BPS)]
Pearson's product-moment correlation
data: TJ and BPS
t = 11.402, df = 85, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.6780010 0.8491518
sample estimates:
cor
0.7775935
Matrix
Index:- TJ (Trump + Johnson)
- CS (Clinton + Stein)
- BPS501_YES (Approved Bellingham PS 501 Bond)
- BPS501_NO (Rejected Bellingham PS 501 Bond)
- PrecinctCount as of 02/2018
- Pct Voted in BPS501
PrecinctID TJ CS Buchanan Robinson BPS501_YES BPS501_NO PrecinctCount PctVoted
1: 134 295 537 257 181 190 150 927 36.7
2: 135 271 402 113 127 81 50 573 22.9
3: 136 238 395 238 204 226 112 1149 29.4
4: 157 127 110 50 71 34 63 296 32.8
5: 159 101 118 48 70 51 41 286 32.2
6: 160 256 504 227 172 205 112 928 34.2
7: 161 172 296 138 114 124 88 584 36.3
8: 162 253 335 164 176 133 118 739 34.0
9: 168 335 468 229 285 221 185 959 42.3
10: 169 300 650 374 220 295 161 1134 40.2
11: 170 159 294 148 151 144 66 521 40.3
12: 171 213 551 285 162 229 108 900 37.4
13: 172 167 280 151 112 101 81 548 33.2
14: 173 201 343 155 184 142 116 634 40.7
15: 174 206 422 155 135 131 70 815 24.7
16: 175 251 540 246 125 206 82 997 28.9
17: 176 195 357 165 133 136 104 676 35.5
18: 177 178 330 162 92 128 74 596 33.9
19: 178 222 569 230 122 177 91 964 27.8
20: 180 156 416 282 117 202 107 653 47.3
21: 181 327 566 238 226 230 164 1113 35.4
22: 202 162 330 172 118 169 66 668 35.2
23: 203 303 477 226 189 194 120 1043 30.1
24: 204 167 302 116 71 93 35 702 18.2
25: 205 171 329 169 106 133 83 613 35.2
26: 206 227 647 325 143 201 89 1162 25.0
27: 207 122 318 213 77 138 55 554 34.8
28: 208 239 827 418 134 266 110 1285 29.3
29: 209 150 529 344 119 235 84 779 40.9
30: 210 85 673 504 95 335 77 972 42.4
31: 211 295 450 160 172 141 106 1083 22.8
32: 212 210 365 141 119 130 67 802 24.6
33: 213 235 617 366 196 310 108 986 42.4
34: 214 101 503 338 86 237 53 671 43.2
35: 215 99 623 379 90 280 58 837 40.4
36: 216 99 550 378 105 278 63 933 36.5
37: 217 204 289 136 128 104 82 616 30.2
38: 218 183 383 116 116 139 44 784 23.3
39: 219 177 457 233 111 165 74 811 29.5
40: 220 232 518 194 156 179 77 990 25.9
41: 221 261 397 197 183 205 99 801 38.0
42: 222 147 715 471 123 368 88 958 47.6
43: 223 64 399 247 50 157 31 556 33.8
44: 224 46 276 118 40 81 22 373 27.6
45: 225 174 904 367 119 260 37 1218 24.4
46: 226 65 541 226 56 122 16 743 18.6
47: 227 141 645 293 86 197 52 841 29.6
48: 228 79 715 387 60 196 32 911 25.0
49: 229 178 652 241 101 160 73 1123 20.7
50: 230 136 474 177 79 96 41 870 15.7
51: 231 204 676 268 133 163 66 1173 19.5
52: 232 269 461 272 177 231 133 879 41.4
53: 233 187 486 270 123 191 92 864 32.8
54: 234 230 468 251 163 226 103 816 40.3
55: 235 135 265 153 112 134 61 513 38.0
56: 237 129 316 262 164 235 115 917 38.2
57: 238 217 312 171 134 136 86 599 37.1
58: 239 230 583 327 154 252 102 1009 35.1
59: 240 196 525 310 127 245 98 855 40.1
60: 241 164 400 212 139 174 62 720 32.8
61: 242 102 337 172 75 159 65 543 41.3
62: 243 194 442 280 129 199 98 777 38.2
63: 244 113 620 339 107 262 61 845 38.2
64: 245 87 598 164 40 81 4 976 8.7
65: 246 85 632 294 65 166 35 832 24.2
66: 247 83 673 280 53 124 19 913 15.7
67: 248 163 505 153 108 149 56 852 24.1
68: 249 231 574 311 144 248 98 981 35.3
69: 250 152 734 463 141 334 150 977 49.5
70: 251 101 516 338 100 270 83 680 51.9
71: 252 26 285 88 27 35 2 456 8.1
72: 253 159 887 282 112 186 28 1205 17.8
73: 254 148 419 226 144 186 68 674 37.7
74: 255 115 423 176 99 143 44 638 29.3
75: 256 102 578 359 76 242 61 794 38.2
76: 257 55 600 228 55 126 25 750 20.1
77: 258 74 751 412 86 249 48 973 30.5
78: 259 101 328 162 113 143 54 553 35.6
79: 260 164 346 240 127 191 99 608 47.7
80: 261 114 392 238 118 220 84 579 52.5
81: 262 111 551 293 84 192 55 761 32.5
82: 263 108 676 297 81 203 37 914 26.3
83: 264 179 475 288 144 227 155 727 52.5
84: 265 144 351 204 121 187 88 601 45.8
85: 266 170 495 306 138 250 108 787 45.5
86: 268 21 20 9 11 5 12 62 27.4
87: 269 22 89 33 16 24 6 150 20.0
PrecinctID TJ CS Buchanan Robinson BPS501_YES BPS501_NO PrecinctCount PctVoted
Mean Variance (mvabund pkg) and Rcorr (Hmisc pkg) with p-values
Mean Variance
CS 473.2989 28642.886
Buchanan 239.5172 9946.834
BPS501_YES 180.9540 5054.742
TJ 166.2069 5140.538
Robinson 118.9310 2295.018
BPS501_NO 76.3908 1449.520
rcorr(as.matrix(r7[,.(Trump,Clinton,Buchanan,Robinson,BPS501_YES,BPS501_NO),]))
Trump Clinton Buchanan Robinson BPS501_YES BPS501_NO
Trump 1.00 0.08 0.02 0.90 0.26 0.81
Clinton 0.08 1.00 0.83 0.18 0.70 0.13
Buchanan 0.02 0.83 1.00 0.20 0.91 0.30
Robinson 0.90 0.18 0.20 1.00 0.47 0.88
BPS501_YES 0.26 0.70 0.91 0.47 1.00 0.53
BPS501_NO 0.81 0.13 0.30 0.88 0.53 1.00
n= 87
P
Trump Clinton Buchanan Robinson BPS501_YES BPS501_NO
Trump 0.4503 0.8546 0.0000 0.0153 0.0000
Clinton 0.4503 0.0000 0.1032 0.0000 0.2353
Buchanan 0.8546 0.0000 0.0591 0.0000 0.0055
Robinson 0.0000 0.1032 0.0591 0.0000 0.0000
BPS501_YES 0.0153 0.0000 0.0000 0.0000 0.0000
BPS501_NO 0.0000 0.2353 0.0055 0.0000 0.0000
Correlation Matrices and Rpart Trees
Click to enlarge.
No comments:
Post a Comment