libraries = c("nleqslv","dplyr","magrittr","tidyr","rEDM","ggplot2","readxl",
              "gridExtra","zoo","scales","humidity")
for(x in libraries) { library(x,character.only=TRUE,warn.conflicts=FALSE,quietly=TRUE) }

### to show the plots as svg-graphics in Jupyter
### although this has some problems when you export the notebook
### to html or other formats
options(jupyter.plot_mimetypes = "image/svg+xml") 

packageVersion('rEDM')

set.seed(599213)

nsurr = 500

'%&%' <- function(x,y)paste0(x,y)
[1] ‘0.7.2’
cntr = "Denmark"
df.long = read.csv('Sugihara2012_dataset.txt',header = TRUE)
df.long %<>%
    filter(country == cntr) %>% 
    filter(year >= 1996)

df.long %>% head
country variable year month day value
Denmark flu 1996 1 1 NaN
Denmark flu 1996 1 8 NaN
Denmark flu 1996 1 15 NaN
Denmark flu 1996 1 22 NaN
Denmark flu 1996 1 29 NaN
Denmark flu 1996 2 5 NaN
df.in = df.long %>%
    select(-country) %>%
    spread(variable,value) %>%
    mutate(date = ISOdate(year,month,day)) %>%
    select(-year,-month,-day) %>%
    select(date,flu,everything())
df.in %>% head
date flu AH PRCP RH T
1996-01-01 12:00:00 NaN 3.314742 6.60 0.827500 27.1
1996-01-08 12:00:00 NaN 4.991437 9.54 0.954702 34.0
1996-01-15 12:00:00 NaN 4.310679 8.50 0.928307 30.9
1996-01-22 12:00:00 NaN 3.044399 7.71 0.790498 26.1
1996-01-29 12:00:00 NaN 3.531248 7.20 0.878098 27.2
1996-02-05 12:00:00 NaN 2.367563 5.40 0.729602 21.8
make_block = function(data,cols,delays,lib=c(1,NROW(data))){
    lib = matrix(lib,ncol = 2)
    data = as.matrix(data)
    ncol = length(cols)
    nrow = dim(data)[1]
    block = array(NA,dim = c(nrow,ncol))
    colnames(block) = 1:ncol
    for (i in 1:ncol){
        I = 1:nrow
        I_delay <- intersect(I,I+delays[i])
        block[I_delay-delays[i],i] = data[I_delay,cols[i]]
        if (delays[i] < 0){
            # remove data points that fall at start of lib segments
            block[lib[,1] - (0:(delays[i]+1)),i] = NA
            colnames(block)[i] = paste(colnames(data)[cols[i]],'_t-',abs(delays[i]),sep="")
        } else if (delays[i] > 0) {
            # remove data points that fall at end of lib segments
            block[lib[,2] - (0:(delays[i]+1)),i] = NA
            colnames(block)[i] <- paste(colnames(data)[cols[i]],'_t+',abs(delays[i]),sep="")
        } else {
            colnames(block)[i] <- paste(colnames(data)[cols[i]],'_t',sep="")
        }
    }
    return(block)
}

We define a function yearday_anom() that computes the seasonal cycle and day-of-year anomaly for a time-series. As described in the main text, this is done with smoothing splines.

Anomaly is the difference between the observed value and the smoothed spline.

yearday_anom = function(t,x){
    # t: date formatted with POSIXt
    # x: time-series values to compute seasonal mean and anomaly
    doy = as.numeric(strftime(t, format = "%j"))
    I_use = which(!is.na(x))
    # create time indices to use for smoothing, replicating data to "wrap around"
    doy_sm = rep(doy[I_use],3) + rep(c(-366,0,366),each=length(I_use))
    x_sm = rep(x[I_use],3)
    xsp = smooth.spline(doy_sm, y = x_sm, w = NULL, spar = 0.8, cv = NA,
        all.knots = TRUE,keep.data = TRUE, df.offset = 0)
    xbar = data.frame(t=t,doy=doy) %>%
        left_join(data.frame(doy=xsp$x,xbar=xsp$y),by='doy') %>%
        select(xbar)
    out = data.frame(t=t,mean=xbar,anomaly=(x - xbar))
    names(out) = c('date','mean','anomaly')
    return(out)
}
out = yearday_anom(df.in$date,df.in$AH)
AH.bar = out$mean
AH.tilde = out$anomaly
options(repr.plot.width=7,repr.plot.height=4.5)
out %>% 
    ggplot(aes(x=date)) +
        geom_line(aes(y=mean)) +
        geom_point(aes(y=mean+anomaly),color="blue",shape=1) +
        labs(x="date",y="Absolute humidity",title=cntr) +
        theme_bw() -> p1_Denmark

p1_Denmark
Warning message:
“Removed 4 rows containing missing values (geom_point).”

png

AH.surrs = do.call(cbind,
    lapply(1:500, function(i) {
        I_na = is.na(AH.tilde)
        out = AH.bar
        out[I_na] = NA
        out[!I_na] = out[!I_na] + sample(AH.tilde[!I_na],sum(!I_na),replace = FALSE)
        return(out)
    })
)
options(repr.plot.width=7,repr.plot.height=5)
plot(df.in$date,df.in$AH,type='l',col='blue',xlab='date',ylab='Absolute Humidity')
lines(df.in$date,AH.surrs[,1],col='red')
legend( x="topright", legend=c("Observed","Seasonal Surrogate"), col=c("blue","red"), lwd=1, lty=c(1,1),bg='white')

png

3. CCM

For set up, we need to determine the set of points to be predicted (pred input) to deal with the fact that many of the influenza time-series have strings of 0 counts. These strings will contain little or no causal information, and more practically can cause problems with how nearest neighbors are calculated for simplex projection when there are many 0 count vectors. We write a function that eliminates all vectors from the prediction that contain a string of at least \(E\) 0’s.

make_pred_nozero = function(time_series,E) {
    I_zero_strings = which(time_series==0)
    I_zero_strings = Reduce(intersect, lapply((0:E),function(offset) I_zero_strings-offset))
    I_zero_strings = c(0,I_zero_strings,NROW(df.in)) # for convenience in next step
    N_zero_strings = length(I_zero_strings)
    lib_nozeroes = cbind(I_zero_strings[1:(N_zero_strings-1)]+1,I_zero_strings[2:(N_zero_strings)]-1)
    lib_out = lib_nozeroes[which(lib_nozeroes[,2] > lib_nozeroes[,1]),]
    return(lib_out)
}
df.in %>% mutate(index=1:n()) %>% filter(index>=600&index<615)
date flu AH PRCP RH T index
2007-06-25 12:00:00 NaN 10.598504 55.70 0.867344 57.60 600
2007-07-02 12:00:00 NaN 11.874325 69.20 0.898884 59.90 601
2007-07-09 12:00:00 NaN 10.996224 59.64 0.846580 59.40 602
2007-07-16 12:00:00 NaN 12.403229 19.48 0.835184 63.40 603
2007-07-23 12:00:00 NaN 11.702477 40.23 0.847995 61.20 604
2007-07-30 12:00:00 NaN 10.683401 42.80 0.779359 61.00 605
2007-08-06 12:00:00 NaN 14.497789 12.50 0.862870 67.15 606
2007-08-13 12:00:00 NaN 11.939355 52.16 0.806622 63.30 607
2007-08-20 12:00:00 NaN 14.267609 11.34 0.915726 64.85 608
2007-08-27 12:00:00 NaN 9.605718 26.29 0.818989 56.40 609
2007-09-03 12:00:00 NaN 9.804182 21.30 0.813357 57.20 610
2007-09-10 12:00:00 NaN 9.695090 17.28 0.835153 56.10 611
2007-09-17 12:00:00 NaN 10.795756 7.14 0.914172 56.60 612
2007-09-24 12:00:00 NaN 10.025608 18.80 0.922036 54.20 613
2007-10-01 12:00:00 NaN 8.960859 40.93 0.899003 51.70 614
I_zero_strings = which(df.in$flu==0)
I_zero_strings
  1. 59
  2. 61
  3. 106
  4. 107
  5. 109
  6. 118
  7. 119
  8. 139
  9. 140
  10. 141
  11. 142
  12. 143
  13. 144
  14. 145
  15. 146
  16. 147
  17. 148
  18. 149
  19. 150
  20. 154
  21. 167
  22. 168
  23. 170
  24. 191
  25. 192
  26. 193
  27. 194
  28. 195
  29. 196
  30. 197
  31. 198
  32. 199
  33. 200
  34. 201
  35. 203
  36. 204
  37. 205
  38. 216
  39. 218
  40. 219
  41. 220
  42. 221
  43. 222
  44. 248
  45. 249
  46. 250
  47. 251
  48. 252
  49. 253
  50. 254
  51. 255
  52. 256
  53. 257
  54. 258
  55. 260
  56. 262
  57. 275
  58. 276
  59. 277
  60. 278
  61. 279
  62. 300
  63. 301
  64. 302
  65. 303
  66. 304
  67. 305
  68. 306
  69. 307
  70. 308
  71. 309
  72. 310
  73. 311
  74. 312
  75. 313
  76. 314
  77. 319
  78. 326
  79. 327
  80. 328
  81. 329
  82. 330
  83. 331
  84. 352
  85. 353
  86. 354
  87. 355
  88. 356
  89. 357
  90. 358
  91. 359
  92. 360
  93. 361
  94. 362
  95. 363
  96. 364
  97. 365
  98. 366
  99. 367
  100. 379
  101. 380
  102. 381
  103. 382
  104. 383
  105. 384
  106. 404
  107. 405
  108. 406
  109. 407
  110. 408
  111. 409
  112. 410
  113. 411
  114. 422
  115. 423
  116. 426
  117. 428
  118. 430
  119. 431
  120. 432
  121. 433
  122. 434
  123. 435
  124. 436
  125. 457
  126. 458
  127. 459
  128. 460
  129. 461
  130. 462
  131. 463
  132. 464
  133. 465
  134. 466
  135. 467
  136. 510
  137. 511
  138. 512
  139. 513
  140. 514
  141. 515
  142. 516
  143. 517
  144. 518
  145. 519
  146. 520
  147. 521
  148. 522
  149. 523
  150. 525
  151. 538
  152. 539
  153. 562
  154. 563
  155. 564
  156. 565
  157. 566
  158. 567
  159. 568
  160. 569
  161. 570
  162. 571
  163. 572
  164. 573
  165. 574
  166. 575
  167. 578
  168. 591
  169. 592
  170. 593
  171. 594
  172. 615
  173. 616
  174. 617
  175. 618
  176. 619
  177. 620
  178. 622
  179. 625
  180. 643
  181. 644
  182. 665
  183. 666
  184. 667
  185. 668
  186. 669
  187. 671
  188. 740
  189. 751
  190. 752
  191. 753
  192. 754
  193. 755
  194. 756
  195. 758
  196. 759
  197. 760
  198. 761
  199. 762
  200. 763
  201. 764
  202. 765
  203. 766
  204. 767
  205. 768
  206. 769
  207. 770
  208. 771
  209. 772
  210. 773
  211. 774
  212. 775
  213. 776
  214. 802
  215. 804
  216. 805
  217. 806
  218. 808
  219. 809
  220. 810
  221. 811
  222. 812
  223. 814
  224. 815
  225. 816
  226. 817
  227. 820
  228. 823
  229. 824
  230. 825
  231. 826
  232. 827
  233. 828
  234. 830
  235. 832
  236. 833
  237. 834
  238. 835
  239. 836
  240. 837
  241. 838
  242. 839
  243. 855
  244. 857
  245. 858
  246. 859
  247. 860
  248. 861
  249. 862
  250. 863
  251. 864
  252. 865
  253. 866
  254. 867
  255. 868
  256. 869
  257. 870
  258. 872
  259. 873
  260. 876
  261. 908
  262. 909
  263. 911
  264. 913
  265. 916
  266. 918
  267. 919
  268. 920
  269. 921
  270. 922
  271. 923
  272. 924
  273. 925
  274. 926
I_zero_strings2 = Reduce(intersect, lapply((0:5),function(offset) I_zero_strings-offset))
I_zero_strings2
  1. 139
  2. 140
  3. 141
  4. 142
  5. 143
  6. 144
  7. 145
  8. 191
  9. 192
  10. 193
  11. 194
  12. 195
  13. 196
  14. 248
  15. 249
  16. 250
  17. 251
  18. 252
  19. 253
  20. 300
  21. 301
  22. 302
  23. 303
  24. 304
  25. 305
  26. 306
  27. 307
  28. 308
  29. 309
  30. 326
  31. 352
  32. 353
  33. 354
  34. 355
  35. 356
  36. 357
  37. 358
  38. 359
  39. 360
  40. 361
  41. 362
  42. 379
  43. 404
  44. 405
  45. 406
  46. 430
  47. 431
  48. 457
  49. 458
  50. 459
  51. 460
  52. 461
  53. 462
  54. 510
  55. 511
  56. 512
  57. 513
  58. 514
  59. 515
  60. 516
  61. 517
  62. 518
  63. 562
  64. 563
  65. 564
  66. 565
  67. 566
  68. 567
  69. 568
  70. 569
  71. 570
  72. 615
  73. 751
  74. 758
  75. 759
  76. 760
  77. 761
  78. 762
  79. 763
  80. 764
  81. 765
  82. 766
  83. 767
  84. 768
  85. 769
  86. 770
  87. 771
  88. 823
  89. 832
  90. 833
  91. 834
  92. 857
  93. 858
  94. 859
  95. 860
  96. 861
  97. 862
  98. 863
  99. 864
  100. 865
  101. 918
  102. 919
  103. 920
  104. 921
lapply((0:8),function(offset) I_zero_strings-offset)
    1. 59
    2. 61
    3. 106
    4. 107
    5. 109
    6. 118
    7. 119
    8. 139
    9. 140
    10. 141
    11. 142
    12. 143
    13. 144
    14. 145
    15. 146
    16. 147
    17. 148
    18. 149
    19. 150
    20. 154
    21. 167
    22. 168
    23. 170
    24. 191
    25. 192
    26. 193
    27. 194
    28. 195
    29. 196
    30. 197
    31. 198
    32. 199
    33. 200
    34. 201
    35. 203
    36. 204
    37. 205
    38. 216
    39. 218
    40. 219
    41. 220
    42. 221
    43. 222
    44. 248
    45. 249
    46. 250
    47. 251
    48. 252
    49. 253
    50. 254
    51. 255
    52. 256
    53. 257
    54. 258
    55. 260
    56. 262
    57. 275
    58. 276
    59. 277
    60. 278
    61. 279
    62. 300
    63. 301
    64. 302
    65. 303
    66. 304
    67. 305
    68. 306
    69. 307
    70. 308
    71. 309
    72. 310
    73. 311
    74. 312
    75. 313
    76. 314
    77. 319
    78. 326
    79. 327
    80. 328
    81. 329
    82. 330
    83. 331
    84. 352
    85. 353
    86. 354
    87. 355
    88. 356
    89. 357
    90. 358
    91. 359
    92. 360
    93. 361
    94. 362
    95. 363
    96. 364
    97. 365
    98. 366
    99. 367
    100. 379
    101. 380
    102. 381
    103. 382
    104. 383
    105. 384
    106. 404
    107. 405
    108. 406
    109. 407
    110. 408
    111. 409
    112. 410
    113. 411
    114. 422
    115. 423
    116. 426
    117. 428
    118. 430
    119. 431
    120. 432
    121. 433
    122. 434
    123. 435
    124. 436
    125. 457
    126. 458
    127. 459
    128. 460
    129. 461
    130. 462
    131. 463
    132. 464
    133. 465
    134. 466
    135. 467
    136. 510
    137. 511
    138. 512
    139. 513
    140. 514
    141. 515
    142. 516
    143. 517
    144. 518
    145. 519
    146. 520
    147. 521
    148. 522
    149. 523
    150. 525
    151. 538
    152. 539
    153. 562
    154. 563
    155. 564
    156. 565
    157. 566
    158. 567
    159. 568
    160. 569
    161. 570
    162. 571
    163. 572
    164. 573
    165. 574
    166. 575
    167. 578
    168. 591
    169. 592
    170. 593
    171. 594
    172. 615
    173. 616
    174. 617
    175. 618
    176. 619
    177. 620
    178. 622
    179. 625
    180. 643
    181. 644
    182. 665
    183. 666
    184. 667
    185. 668
    186. 669
    187. 671
    188. 740
    189. 751
    190. 752
    191. 753
    192. 754
    193. 755
    194. 756
    195. 758
    196. 759
    197. 760
    198. 761
    199. 762
    200. 763
    201. 764
    202. 765
    203. 766
    204. 767
    205. 768
    206. 769
    207. 770
    208. 771
    209. 772
    210. 773
    211. 774
    212. 775
    213. 776
    214. 802
    215. 804
    216. 805
    217. 806
    218. 808
    219. 809
    220. 810
    221. 811
    222. 812
    223. 814
    224. 815
    225. 816
    226. 817
    227. 820
    228. 823
    229. 824
    230. 825
    231. 826
    232. 827
    233. 828
    234. 830
    235. 832
    236. 833
    237. 834
    238. 835
    239. 836
    240. 837
    241. 838
    242. 839
    243. 855
    244. 857
    245. 858
    246. 859
    247. 860
    248. 861
    249. 862
    250. 863
    251. 864
    252. 865
    253. 866
    254. 867
    255. 868
    256. 869
    257. 870
    258. 872
    259. 873
    260. 876
    261. 908
    262. 909
    263. 911
    264. 913
    265. 916
    266. 918
    267. 919
    268. 920
    269. 921
    270. 922
    271. 923
    272. 924
    273. 925
    274. 926
    1. 58
    2. 60
    3. 105
    4. 106
    5. 108
    6. 117
    7. 118
    8. 138
    9. 139
    10. 140
    11. 141
    12. 142
    13. 143
    14. 144
    15. 145
    16. 146
    17. 147
    18. 148
    19. 149
    20. 153
    21. 166
    22. 167
    23. 169
    24. 190
    25. 191
    26. 192
    27. 193
    28. 194
    29. 195
    30. 196
    31. 197
    32. 198
    33. 199
    34. 200
    35. 202
    36. 203
    37. 204
    38. 215
    39. 217
    40. 218
    41. 219
    42. 220
    43. 221
    44. 247
    45. 248
    46. 249
    47. 250
    48. 251
    49. 252
    50. 253
    51. 254
    52. 255
    53. 256
    54. 257
    55. 259
    56. 261
    57. 274
    58. 275
    59. 276
    60. 277
    61. 278
    62. 299
    63. 300
    64. 301
    65. 302
    66. 303
    67. 304
    68. 305
    69. 306
    70. 307
    71. 308
    72. 309
    73. 310
    74. 311
    75. 312
    76. 313
    77. 318
    78. 325
    79. 326
    80. 327
    81. 328
    82. 329
    83. 330
    84. 351
    85. 352
    86. 353
    87. 354
    88. 355
    89. 356
    90. 357
    91. 358
    92. 359
    93. 360
    94. 361
    95. 362
    96. 363
    97. 364
    98. 365
    99. 366
    100. 378
    101. 379
    102. 380
    103. 381
    104. 382
    105. 383
    106. 403
    107. 404
    108. 405
    109. 406
    110. 407
    111. 408
    112. 409
    113. 410
    114. 421
    115. 422
    116. 425
    117. 427
    118. 429
    119. 430
    120. 431
    121. 432
    122. 433
    123. 434
    124. 435
    125. 456
    126. 457
    127. 458
    128. 459
    129. 460
    130. 461
    131. 462
    132. 463
    133. 464
    134. 465
    135. 466
    136. 509
    137. 510
    138. 511
    139. 512
    140. 513
    141. 514
    142. 515
    143. 516
    144. 517
    145. 518
    146. 519
    147. 520
    148. 521
    149. 522
    150. 524
    151. 537
    152. 538
    153. 561
    154. 562
    155. 563
    156. 564
    157. 565
    158. 566
    159. 567
    160. 568
    161. 569
    162. 570
    163. 571
    164. 572
    165. 573
    166. 574
    167. 577
    168. 590
    169. 591
    170. 592
    171. 593
    172. 614
    173. 615
    174. 616
    175. 617
    176. 618
    177. 619
    178. 621
    179. 624
    180. 642
    181. 643
    182. 664
    183. 665
    184. 666
    185. 667
    186. 668
    187. 670
    188. 739
    189. 750
    190. 751
    191. 752
    192. 753
    193. 754
    194. 755
    195. 757
    196. 758
    197. 759
    198. 760
    199. 761
    200. 762
    201. 763
    202. 764
    203. 765
    204. 766
    205. 767
    206. 768
    207. 769
    208. 770
    209. 771
    210. 772
    211. 773
    212. 774
    213. 775
    214. 801
    215. 803
    216. 804
    217. 805
    218. 807
    219. 808
    220. 809
    221. 810
    222. 811
    223. 813
    224. 814
    225. 815
    226. 816
    227. 819
    228. 822
    229. 823
    230. 824
    231. 825
    232. 826
    233. 827
    234. 829
    235. 831
    236. 832
    237. 833
    238. 834
    239. 835
    240. 836
    241. 837
    242. 838
    243. 854
    244. 856
    245. 857
    246. 858
    247. 859
    248. 860
    249. 861
    250. 862
    251. 863
    252. 864
    253. 865
    254. 866
    255. 867
    256. 868
    257. 869
    258. 871
    259. 872
    260. 875
    261. 907
    262. 908
    263. 910
    264. 912
    265. 915
    266. 917
    267. 918
    268. 919
    269. 920
    270. 921
    271. 922
    272. 923
    273. 924
    274. 925
    1. 57
    2. 59
    3. 104
    4. 105
    5. 107
    6. 116
    7. 117
    8. 137
    9. 138
    10. 139
    11. 140
    12. 141
    13. 142
    14. 143
    15. 144
    16. 145
    17. 146
    18. 147
    19. 148
    20. 152
    21. 165
    22. 166
    23. 168
    24. 189
    25. 190
    26. 191
    27. 192
    28. 193
    29. 194
    30. 195
    31. 196
    32. 197
    33. 198
    34. 199
    35. 201
    36. 202
    37. 203
    38. 214
    39. 216
    40. 217
    41. 218
    42. 219
    43. 220
    44. 246
    45. 247
    46. 248
    47. 249
    48. 250
    49. 251
    50. 252
    51. 253
    52. 254
    53. 255
    54. 256
    55. 258
    56. 260
    57. 273
    58. 274
    59. 275
    60. 276
    61. 277
    62. 298
    63. 299
    64. 300
    65. 301
    66. 302
    67. 303
    68. 304
    69. 305
    70. 306
    71. 307
    72. 308
    73. 309
    74. 310
    75. 311
    76. 312
    77. 317
    78. 324
    79. 325
    80. 326
    81. 327
    82. 328
    83. 329
    84. 350
    85. 351
    86. 352
    87. 353
    88. 354
    89. 355
    90. 356
    91. 357
    92. 358
    93. 359
    94. 360
    95. 361
    96. 362
    97. 363
    98. 364
    99. 365
    100. 377
    101. 378
    102. 379
    103. 380
    104. 381
    105. 382
    106. 402
    107. 403
    108. 404
    109. 405
    110. 406
    111. 407
    112. 408
    113. 409
    114. 420
    115. 421
    116. 424
    117. 426
    118. 428
    119. 429
    120. 430
    121. 431
    122. 432
    123. 433
    124. 434
    125. 455
    126. 456
    127. 457
    128. 458
    129. 459
    130. 460
    131. 461
    132. 462
    133. 463
    134. 464
    135. 465
    136. 508
    137. 509
    138. 510
    139. 511
    140. 512
    141. 513
    142. 514
    143. 515
    144. 516
    145. 517
    146. 518
    147. 519
    148. 520
    149. 521
    150. 523
    151. 536
    152. 537
    153. 560
    154. 561
    155. 562
    156. 563
    157. 564
    158. 565
    159. 566
    160. 567
    161. 568
    162. 569
    163. 570
    164. 571
    165. 572
    166. 573
    167. 576
    168. 589
    169. 590
    170. 591
    171. 592
    172. 613
    173. 614
    174. 615
    175. 616
    176. 617
    177. 618
    178. 620
    179. 623
    180. 641
    181. 642
    182. 663
    183. 664
    184. 665
    185. 666
    186. 667
    187. 669
    188. 738
    189. 749
    190. 750
    191. 751
    192. 752
    193. 753
    194. 754
    195. 756
    196. 757
    197. 758
    198. 759
    199. 760
    200. 761
    201. 762
    202. 763
    203. 764
    204. 765
    205. 766
    206. 767
    207. 768
    208. 769
    209. 770
    210. 771
    211. 772
    212. 773
    213. 774
    214. 800
    215. 802
    216. 803
    217. 804
    218. 806
    219. 807
    220. 808
    221. 809
    222. 810
    223. 812
    224. 813
    225. 814
    226. 815
    227. 818
    228. 821
    229. 822
    230. 823
    231. 824
    232. 825
    233. 826
    234. 828
    235. 830
    236. 831
    237. 832
    238. 833
    239. 834
    240. 835
    241. 836
    242. 837
    243. 853
    244. 855
    245. 856
    246. 857
    247. 858
    248. 859
    249. 860
    250. 861
    251. 862
    252. 863
    253. 864
    254. 865
    255. 866
    256. 867
    257. 868
    258. 870
    259. 871
    260. 874
    261. 906
    262. 907
    263. 909
    264. 911
    265. 914
    266. 916
    267. 917
    268. 918
    269. 919
    270. 920
    271. 921
    272. 922
    273. 923
    274. 924
    1. 56
    2. 58
    3. 103
    4. 104
    5. 106
    6. 115
    7. 116
    8. 136
    9. 137
    10. 138
    11. 139
    12. 140
    13. 141
    14. 142
    15. 143
    16. 144
    17. 145
    18. 146
    19. 147
    20. 151
    21. 164
    22. 165
    23. 167
    24. 188
    25. 189
    26. 190
    27. 191
    28. 192
    29. 193
    30. 194
    31. 195
    32. 196
    33. 197
    34. 198
    35. 200
    36. 201
    37. 202
    38. 213
    39. 215
    40. 216
    41. 217
    42. 218
    43. 219
    44. 245
    45. 246
    46. 247
    47. 248
    48. 249
    49. 250
    50. 251
    51. 252
    52. 253
    53. 254
    54. 255
    55. 257
    56. 259
    57. 272
    58. 273
    59. 274
    60. 275
    61. 276
    62. 297
    63. 298
    64. 299
    65. 300
    66. 301
    67. 302
    68. 303
    69. 304
    70. 305
    71. 306
    72. 307
    73. 308
    74. 309
    75. 310
    76. 311
    77. 316
    78. 323
    79. 324
    80. 325
    81. 326
    82. 327
    83. 328
    84. 349
    85. 350
    86. 351
    87. 352
    88. 353
    89. 354
    90. 355
    91. 356
    92. 357
    93. 358
    94. 359
    95. 360
    96. 361
    97. 362
    98. 363
    99. 364
    100. 376
    101. 377
    102. 378
    103. 379
    104. 380
    105. 381
    106. 401
    107. 402
    108. 403
    109. 404
    110. 405
    111. 406
    112. 407
    113. 408
    114. 419
    115. 420
    116. 423
    117. 425
    118. 427
    119. 428
    120. 429
    121. 430
    122. 431
    123. 432
    124. 433
    125. 454
    126. 455
    127. 456
    128. 457
    129. 458
    130. 459
    131. 460
    132. 461
    133. 462
    134. 463
    135. 464
    136. 507
    137. 508
    138. 509
    139. 510
    140. 511
    141. 512
    142. 513
    143. 514
    144. 515
    145. 516
    146. 517
    147. 518
    148. 519
    149. 520
    150. 522
    151. 535
    152. 536
    153. 559
    154. 560
    155. 561
    156. 562
    157. 563
    158. 564
    159. 565
    160. 566
    161. 567
    162. 568
    163. 569
    164. 570
    165. 571
    166. 572
    167. 575
    168. 588
    169. 589
    170. 590
    171. 591
    172. 612
    173. 613
    174. 614
    175. 615
    176. 616
    177. 617
    178. 619
    179. 622
    180. 640
    181. 641
    182. 662
    183. 663
    184. 664
    185. 665
    186. 666
    187. 668
    188. 737
    189. 748
    190. 749
    191. 750
    192. 751
    193. 752
    194. 753
    195. 755
    196. 756
    197. 757
    198. 758
    199. 759
    200. 760
    201. 761
    202. 762
    203. 763
    204. 764
    205. 765
    206. 766
    207. 767
    208. 768
    209. 769
    210. 770
    211. 771
    212. 772
    213. 773
    214. 799
    215. 801
    216. 802
    217. 803
    218. 805
    219. 806
    220. 807
    221. 808
    222. 809
    223. 811
    224. 812
    225. 813
    226. 814
    227. 817
    228. 820
    229. 821
    230. 822
    231. 823
    232. 824
    233. 825
    234. 827
    235. 829
    236. 830
    237. 831
    238. 832
    239. 833
    240. 834
    241. 835
    242. 836
    243. 852
    244. 854
    245. 855
    246. 856
    247. 857
    248. 858
    249. 859
    250. 860
    251. 861
    252. 862
    253. 863
    254. 864
    255. 865
    256. 866
    257. 867
    258. 869
    259. 870
    260. 873
    261. 905
    262. 906
    263. 908
    264. 910
    265. 913
    266. 915
    267. 916
    268. 917
    269. 918
    270. 919
    271. 920
    272. 921
    273. 922
    274. 923
    1. 55
    2. 57
    3. 102
    4. 103
    5. 105
    6. 114
    7. 115
    8. 135
    9. 136
    10. 137
    11. 138
    12. 139
    13. 140
    14. 141
    15. 142
    16. 143
    17. 144
    18. 145
    19. 146
    20. 150
    21. 163
    22. 164
    23. 166
    24. 187
    25. 188
    26. 189
    27. 190
    28. 191
    29. 192
    30. 193
    31. 194
    32. 195
    33. 196
    34. 197
    35. 199
    36. 200
    37. 201
    38. 212
    39. 214
    40. 215
    41. 216
    42. 217
    43. 218
    44. 244
    45. 245
    46. 246
    47. 247
    48. 248
    49. 249
    50. 250
    51. 251
    52. 252
    53. 253
    54. 254
    55. 256
    56. 258
    57. 271
    58. 272
    59. 273
    60. 274
    61. 275
    62. 296
    63. 297
    64. 298
    65. 299
    66. 300
    67. 301
    68. 302
    69. 303
    70. 304
    71. 305
    72. 306
    73. 307
    74. 308
    75. 309
    76. 310
    77. 315
    78. 322
    79. 323
    80. 324
    81. 325
    82. 326
    83. 327
    84. 348
    85. 349
    86. 350
    87. 351
    88. 352
    89. 353
    90. 354
    91. 355
    92. 356
    93. 357
    94. 358
    95. 359
    96. 360
    97. 361
    98. 362
    99. 363
    100. 375
    101. 376
    102. 377
    103. 378
    104. 379
    105. 380
    106. 400
    107. 401
    108. 402
    109. 403
    110. 404
    111. 405
    112. 406
    113. 407
    114. 418
    115. 419
    116. 422
    117. 424
    118. 426
    119. 427
    120. 428
    121. 429
    122. 430
    123. 431
    124. 432
    125. 453
    126. 454
    127. 455
    128. 456
    129. 457
    130. 458
    131. 459
    132. 460
    133. 461
    134. 462
    135. 463
    136. 506
    137. 507
    138. 508
    139. 509
    140. 510
    141. 511
    142. 512
    143. 513
    144. 514
    145. 515
    146. 516
    147. 517
    148. 518
    149. 519
    150. 521
    151. 534
    152. 535
    153. 558
    154. 559
    155. 560
    156. 561
    157. 562
    158. 563
    159. 564
    160. 565
    161. 566
    162. 567
    163. 568
    164. 569
    165. 570
    166. 571
    167. 574
    168. 587
    169. 588
    170. 589
    171. 590
    172. 611
    173. 612
    174. 613
    175. 614
    176. 615
    177. 616
    178. 618
    179. 621
    180. 639
    181. 640
    182. 661
    183. 662
    184. 663
    185. 664
    186. 665
    187. 667
    188. 736
    189. 747
    190. 748
    191. 749
    192. 750
    193. 751
    194. 752
    195. 754
    196. 755
    197. 756
    198. 757
    199. 758
    200. 759
    201. 760
    202. 761
    203. 762
    204. 763
    205. 764
    206. 765
    207. 766
    208. 767
    209. 768
    210. 769
    211. 770
    212. 771
    213. 772
    214. 798
    215. 800
    216. 801
    217. 802
    218. 804
    219. 805
    220. 806
    221. 807
    222. 808
    223. 810
    224. 811
    225. 812
    226. 813
    227. 816
    228. 819
    229. 820
    230. 821
    231. 822
    232. 823
    233. 824
    234. 826
    235. 828
    236. 829
    237. 830
    238. 831
    239. 832
    240. 833
    241. 834
    242. 835
    243. 851
    244. 853
    245. 854
    246. 855
    247. 856
    248. 857
    249. 858
    250. 859
    251. 860
    252. 861
    253. 862
    254. 863
    255. 864
    256. 865
    257. 866
    258. 868
    259. 869
    260. 872
    261. 904
    262. 905
    263. 907
    264. 909
    265. 912
    266. 914
    267. 915
    268. 916
    269. 917
    270. 918
    271. 919
    272. 920
    273. 921
    274. 922
    1. 54
    2. 56
    3. 101
    4. 102
    5. 104
    6. 113
    7. 114
    8. 134
    9. 135
    10. 136
    11. 137
    12. 138
    13. 139
    14. 140
    15. 141
    16. 142
    17. 143
    18. 144
    19. 145
    20. 149
    21. 162
    22. 163
    23. 165
    24. 186
    25. 187
    26. 188
    27. 189
    28. 190
    29. 191
    30. 192
    31. 193
    32. 194
    33. 195
    34. 196
    35. 198
    36. 199
    37. 200
    38. 211
    39. 213
    40. 214
    41. 215
    42. 216
    43. 217
    44. 243
    45. 244
    46. 245
    47. 246
    48. 247
    49. 248
    50. 249
    51. 250
    52. 251
    53. 252
    54. 253
    55. 255
    56. 257
    57. 270
    58. 271
    59. 272
    60. 273
    61. 274
    62. 295
    63. 296
    64. 297
    65. 298
    66. 299
    67. 300
    68. 301
    69. 302
    70. 303
    71. 304
    72. 305
    73. 306
    74. 307
    75. 308
    76. 309
    77. 314
    78. 321
    79. 322
    80. 323
    81. 324
    82. 325
    83. 326
    84. 347
    85. 348
    86. 349
    87. 350
    88. 351
    89. 352
    90. 353
    91. 354
    92. 355
    93. 356
    94. 357
    95. 358
    96. 359
    97. 360
    98. 361
    99. 362
    100. 374
    101. 375
    102. 376
    103. 377
    104. 378
    105. 379
    106. 399
    107. 400
    108. 401
    109. 402
    110. 403
    111. 404
    112. 405
    113. 406
    114. 417
    115. 418
    116. 421
    117. 423
    118. 425
    119. 426
    120. 427
    121. 428
    122. 429
    123. 430
    124. 431
    125. 452
    126. 453
    127. 454
    128. 455
    129. 456
    130. 457
    131. 458
    132. 459
    133. 460
    134. 461
    135. 462
    136. 505
    137. 506
    138. 507
    139. 508
    140. 509
    141. 510
    142. 511
    143. 512
    144. 513
    145. 514
    146. 515
    147. 516
    148. 517
    149. 518
    150. 520
    151. 533
    152. 534
    153. 557
    154. 558
    155. 559
    156. 560
    157. 561
    158. 562
    159. 563
    160. 564
    161. 565
    162. 566
    163. 567
    164. 568
    165. 569
    166. 570
    167. 573
    168. 586
    169. 587
    170. 588
    171. 589
    172. 610
    173. 611
    174. 612
    175. 613
    176. 614
    177. 615
    178. 617
    179. 620
    180. 638
    181. 639
    182. 660
    183. 661
    184. 662
    185. 663
    186. 664
    187. 666
    188. 735
    189. 746
    190. 747
    191. 748
    192. 749
    193. 750
    194. 751
    195. 753
    196. 754
    197. 755
    198. 756
    199. 757
    200. 758
    201. 759
    202. 760
    203. 761
    204. 762
    205. 763
    206. 764
    207. 765
    208. 766
    209. 767
    210. 768
    211. 769
    212. 770
    213. 771
    214. 797
    215. 799
    216. 800
    217. 801
    218. 803
    219. 804
    220. 805
    221. 806
    222. 807
    223. 809
    224. 810
    225. 811
    226. 812
    227. 815
    228. 818
    229. 819
    230. 820
    231. 821
    232. 822
    233. 823
    234. 825
    235. 827
    236. 828
    237. 829
    238. 830
    239. 831
    240. 832
    241. 833
    242. 834
    243. 850
    244. 852
    245. 853
    246. 854
    247. 855
    248. 856
    249. 857
    250. 858
    251. 859
    252. 860
    253. 861
    254. 862
    255. 863
    256. 864
    257. 865
    258. 867
    259. 868
    260. 871
    261. 903
    262. 904
    263. 906
    264. 908
    265. 911
    266. 913
    267. 914
    268. 915
    269. 916
    270. 917
    271. 918
    272. 919
    273. 920
    274. 921
    1. 53
    2. 55
    3. 100
    4. 101
    5. 103
    6. 112
    7. 113
    8. 133
    9. 134
    10. 135
    11. 136
    12. 137
    13. 138
    14. 139
    15. 140
    16. 141
    17. 142
    18. 143
    19. 144
    20. 148
    21. 161
    22. 162
    23. 164
    24. 185
    25. 186
    26. 187
    27. 188
    28. 189
    29. 190
    30. 191
    31. 192
    32. 193
    33. 194
    34. 195
    35. 197
    36. 198
    37. 199
    38. 210
    39. 212
    40. 213
    41. 214
    42. 215
    43. 216
    44. 242
    45. 243
    46. 244
    47. 245
    48. 246
    49. 247
    50. 248
    51. 249
    52. 250
    53. 251
    54. 252
    55. 254
    56. 256
    57. 269
    58. 270
    59. 271
    60. 272
    61. 273
    62. 294
    63. 295
    64. 296
    65. 297
    66. 298
    67. 299
    68. 300
    69. 301
    70. 302
    71. 303
    72. 304
    73. 305
    74. 306
    75. 307
    76. 308
    77. 313
    78. 320
    79. 321
    80. 322
    81. 323
    82. 324
    83. 325
    84. 346
    85. 347
    86. 348
    87. 349
    88. 350
    89. 351
    90. 352
    91. 353
    92. 354
    93. 355
    94. 356
    95. 357
    96. 358
    97. 359
    98. 360
    99. 361
    100. 373
    101. 374
    102. 375
    103. 376
    104. 377
    105. 378
    106. 398
    107. 399
    108. 400
    109. 401
    110. 402
    111. 403
    112. 404
    113. 405
    114. 416
    115. 417
    116. 420
    117. 422
    118. 424
    119. 425
    120. 426
    121. 427
    122. 428
    123. 429
    124. 430
    125. 451
    126. 452
    127. 453
    128. 454
    129. 455
    130. 456
    131. 457
    132. 458
    133. 459
    134. 460
    135. 461
    136. 504
    137. 505
    138. 506
    139. 507
    140. 508
    141. 509
    142. 510
    143. 511
    144. 512
    145. 513
    146. 514
    147. 515
    148. 516
    149. 517
    150. 519
    151. 532
    152. 533
    153. 556
    154. 557
    155. 558
    156. 559
    157. 560
    158. 561
    159. 562
    160. 563
    161. 564
    162. 565
    163. 566
    164. 567
    165. 568
    166. 569
    167. 572
    168. 585
    169. 586
    170. 587
    171. 588
    172. 609
    173. 610
    174. 611
    175. 612
    176. 613
    177. 614
    178. 616
    179. 619
    180. 637
    181. 638
    182. 659
    183. 660
    184. 661
    185. 662
    186. 663
    187. 665
    188. 734
    189. 745
    190. 746
    191. 747
    192. 748
    193. 749
    194. 750
    195. 752
    196. 753
    197. 754
    198. 755
    199. 756
    200. 757
    201. 758
    202. 759
    203. 760
    204. 761
    205. 762
    206. 763
    207. 764
    208. 765
    209. 766
    210. 767
    211. 768
    212. 769
    213. 770
    214. 796
    215. 798
    216. 799
    217. 800
    218. 802
    219. 803
    220. 804
    221. 805
    222. 806
    223. 808
    224. 809
    225. 810
    226. 811
    227. 814
    228. 817
    229. 818
    230. 819
    231. 820
    232. 821
    233. 822
    234. 824
    235. 826
    236. 827
    237. 828
    238. 829
    239. 830
    240. 831
    241. 832
    242. 833
    243. 849
    244. 851
    245. 852
    246. 853
    247. 854
    248. 855
    249. 856
    250. 857
    251. 858
    252. 859
    253. 860
    254. 861
    255. 862
    256. 863
    257. 864
    258. 866
    259. 867
    260. 870
    261. 902
    262. 903
    263. 905
    264. 907
    265. 910
    266. 912
    267. 913
    268. 914
    269. 915
    270. 916
    271. 917
    272. 918
    273. 919
    274. 920
    1. 52
    2. 54
    3. 99
    4. 100
    5. 102
    6. 111
    7. 112
    8. 132
    9. 133
    10. 134
    11. 135
    12. 136
    13. 137
    14. 138
    15. 139
    16. 140
    17. 141
    18. 142
    19. 143
    20. 147
    21. 160
    22. 161
    23. 163
    24. 184
    25. 185
    26. 186
    27. 187
    28. 188
    29. 189
    30. 190
    31. 191
    32. 192
    33. 193
    34. 194
    35. 196
    36. 197
    37. 198
    38. 209
    39. 211
    40. 212
    41. 213
    42. 214
    43. 215
    44. 241
    45. 242
    46. 243
    47. 244
    48. 245
    49. 246
    50. 247
    51. 248
    52. 249
    53. 250
    54. 251
    55. 253
    56. 255
    57. 268
    58. 269
    59. 270
    60. 271
    61. 272
    62. 293
    63. 294
    64. 295
    65. 296
    66. 297
    67. 298
    68. 299
    69. 300
    70. 301
    71. 302
    72. 303
    73. 304
    74. 305
    75. 306
    76. 307
    77. 312
    78. 319
    79. 320
    80. 321
    81. 322
    82. 323
    83. 324
    84. 345
    85. 346
    86. 347
    87. 348
    88. 349
    89. 350
    90. 351
    91. 352
    92. 353
    93. 354
    94. 355
    95. 356
    96. 357
    97. 358
    98. 359
    99. 360
    100. 372
    101. 373
    102. 374
    103. 375
    104. 376
    105. 377
    106. 397
    107. 398
    108. 399
    109. 400
    110. 401
    111. 402
    112. 403
    113. 404
    114. 415
    115. 416
    116. 419
    117. 421
    118. 423
    119. 424
    120. 425
    121. 426
    122. 427
    123. 428
    124. 429
    125. 450
    126. 451
    127. 452
    128. 453
    129. 454
    130. 455
    131. 456
    132. 457
    133. 458
    134. 459
    135. 460
    136. 503
    137. 504
    138. 505
    139. 506
    140. 507
    141. 508
    142. 509
    143. 510
    144. 511
    145. 512
    146. 513
    147. 514
    148. 515
    149. 516
    150. 518
    151. 531
    152. 532
    153. 555
    154. 556
    155. 557
    156. 558
    157. 559
    158. 560
    159. 561
    160. 562
    161. 563
    162. 564
    163. 565
    164. 566
    165. 567
    166. 568
    167. 571
    168. 584
    169. 585
    170. 586
    171. 587
    172. 608
    173. 609
    174. 610
    175. 611
    176. 612
    177. 613
    178. 615
    179. 618
    180. 636
    181. 637
    182. 658
    183. 659
    184. 660
    185. 661
    186. 662
    187. 664
    188. 733
    189. 744
    190. 745
    191. 746
    192. 747
    193. 748
    194. 749
    195. 751
    196. 752
    197. 753
    198. 754
    199. 755
    200. 756
    201. 757
    202. 758
    203. 759
    204. 760
    205. 761
    206. 762
    207. 763
    208. 764
    209. 765
    210. 766
    211. 767
    212. 768
    213. 769
    214. 795
    215. 797
    216. 798
    217. 799
    218. 801
    219. 802
    220. 803
    221. 804
    222. 805
    223. 807
    224. 808
    225. 809
    226. 810
    227. 813
    228. 816
    229. 817
    230. 818
    231. 819
    232. 820
    233. 821
    234. 823
    235. 825
    236. 826
    237. 827
    238. 828
    239. 829
    240. 830
    241. 831
    242. 832
    243. 848
    244. 850
    245. 851
    246. 852
    247. 853
    248. 854
    249. 855
    250. 856
    251. 857
    252. 858
    253. 859
    254. 860
    255. 861
    256. 862
    257. 863
    258. 865
    259. 866
    260. 869
    261. 901
    262. 902
    263. 904
    264. 906
    265. 909
    266. 911
    267. 912
    268. 913
    269. 914
    270. 915
    271. 916
    272. 917
    273. 918
    274. 919
    1. 51
    2. 53
    3. 98
    4. 99
    5. 101
    6. 110
    7. 111
    8. 131
    9. 132
    10. 133
    11. 134
    12. 135
    13. 136
    14. 137
    15. 138
    16. 139
    17. 140
    18. 141
    19. 142
    20. 146
    21. 159
    22. 160
    23. 162
    24. 183
    25. 184
    26. 185
    27. 186
    28. 187
    29. 188
    30. 189
    31. 190
    32. 191
    33. 192
    34. 193
    35. 195
    36. 196
    37. 197
    38. 208
    39. 210
    40. 211
    41. 212
    42. 213
    43. 214
    44. 240
    45. 241
    46. 242
    47. 243
    48. 244
    49. 245
    50. 246
    51. 247
    52. 248
    53. 249
    54. 250
    55. 252
    56. 254
    57. 267
    58. 268
    59. 269
    60. 270
    61. 271
    62. 292
    63. 293
    64. 294
    65. 295
    66. 296
    67. 297
    68. 298
    69. 299
    70. 300
    71. 301
    72. 302
    73. 303
    74. 304
    75. 305
    76. 306
    77. 311
    78. 318
    79. 319
    80. 320
    81. 321
    82. 322
    83. 323
    84. 344
    85. 345
    86. 346
    87. 347
    88. 348
    89. 349
    90. 350
    91. 351
    92. 352
    93. 353
    94. 354
    95. 355
    96. 356
    97. 357
    98. 358
    99. 359
    100. 371
    101. 372
    102. 373
    103. 374
    104. 375
    105. 376
    106. 396
    107. 397
    108. 398
    109. 399
    110. 400
    111. 401
    112. 402
    113. 403
    114. 414
    115. 415
    116. 418
    117. 420
    118. 422
    119. 423
    120. 424
    121. 425
    122. 426
    123. 427
    124. 428
    125. 449
    126. 450
    127. 451
    128. 452
    129. 453
    130. 454
    131. 455
    132. 456
    133. 457
    134. 458
    135. 459
    136. 502
    137. 503
    138. 504
    139. 505
    140. 506
    141. 507
    142. 508
    143. 509
    144. 510
    145. 511
    146. 512
    147. 513
    148. 514
    149. 515
    150. 517
    151. 530
    152. 531
    153. 554
    154. 555
    155. 556
    156. 557
    157. 558
    158. 559
    159. 560
    160. 561
    161. 562
    162. 563
    163. 564
    164. 565
    165. 566
    166. 567
    167. 570
    168. 583
    169. 584
    170. 585
    171. 586
    172. 607
    173. 608
    174. 609
    175. 610
    176. 611
    177. 612
    178. 614
    179. 617
    180. 635
    181. 636
    182. 657
    183. 658
    184. 659
    185. 660
    186. 661
    187. 663
    188. 732
    189. 743
    190. 744
    191. 745
    192. 746
    193. 747
    194. 748
    195. 750
    196. 751
    197. 752
    198. 753
    199. 754
    200. 755
    201. 756
    202. 757
    203. 758
    204. 759
    205. 760
    206. 761
    207. 762
    208. 763
    209. 764
    210. 765
    211. 766
    212. 767
    213. 768
    214. 794
    215. 796
    216. 797
    217. 798
    218. 800
    219. 801
    220. 802
    221. 803
    222. 804
    223. 806
    224. 807
    225. 808
    226. 809
    227. 812
    228. 815
    229. 816
    230. 817
    231. 818
    232. 819
    233. 820
    234. 822
    235. 824
    236. 825
    237. 826
    238. 827
    239. 828
    240. 829
    241. 830
    242. 831
    243. 847
    244. 849
    245. 850
    246. 851
    247. 852
    248. 853
    249. 854
    250. 855
    251. 856
    252. 857
    253. 858
    254. 859
    255. 860
    256. 861
    257. 862
    258. 864
    259. 865
    260. 868
    261. 900
    262. 901
    263. 903
    264. 905
    265. 908
    266. 910
    267. 911
    268. 912
    269. 913
    270. 914
    271. 915
    272. 916
    273. 917
    274. 918

Reduce is from the functional programming module of R ## Iterative function application: Funcall = function(f, …) f(…) ## Compute log(exp(acos(cos(0)) Reduce(Funcall, list(log, exp, acos, cos), 0, right = TRUE)

I_zero_strings = I_zero_strings2
I_zero_strings = c(0,I_zero_strings,NROW(df.in)) # for convenience in next step
I_zero_strings
  1. 0
  2. 139
  3. 140
  4. 141
  5. 142
  6. 143
  7. 144
  8. 145
  9. 191
  10. 192
  11. 193
  12. 194
  13. 195
  14. 196
  15. 248
  16. 249
  17. 250
  18. 251
  19. 252
  20. 253
  21. 300
  22. 301
  23. 302
  24. 303
  25. 304
  26. 305
  27. 306
  28. 307
  29. 308
  30. 309
  31. 326
  32. 352
  33. 353
  34. 354
  35. 355
  36. 356
  37. 357
  38. 358
  39. 359
  40. 360
  41. 361
  42. 362
  43. 379
  44. 404
  45. 405
  46. 406
  47. 430
  48. 431
  49. 457
  50. 458
  51. 459
  52. 460
  53. 461
  54. 462
  55. 510
  56. 511
  57. 512
  58. 513
  59. 514
  60. 515
  61. 516
  62. 517
  63. 518
  64. 562
  65. 563
  66. 564
  67. 565
  68. 566
  69. 567
  70. 568
  71. 569
  72. 570
  73. 615
  74. 751
  75. 758
  76. 759
  77. 760
  78. 761
  79. 762
  80. 763
  81. 764
  82. 765
  83. 766
  84. 767
  85. 768
  86. 769
  87. 770
  88. 771
  89. 823
  90. 832
  91. 833
  92. 834
  93. 857
  94. 858
  95. 859
  96. 860
  97. 861
  98. 862
  99. 863
  100. 864
  101. 865
  102. 918
  103. 919
  104. 920
  105. 921
  106. 970
N_zero_strings = length(I_zero_strings)
N_zero_strings

106

lib_nozeroes = cbind(I_zero_strings[1:(N_zero_strings-1)]+1,I_zero_strings[2:(N_zero_strings)]-1)
lib_nozeroes %>% head(16)
1 138
140 139
141 140
142 141
143 142
144 143
145 144
146 190
192 191
193 192
194 193
195 194
196 195
197 247
249 248
250 249
lib_out = lib_nozeroes[which(lib_nozeroes[,2] > lib_nozeroes[,1]),]
lib_out
1 138
146 190
197 247
254 299
310 325
327 351
363 378
380 403
407 429
432 456
463 509
519 561
571 614
616 750
752 757
772 822
824 831
835 856
866 917
922 969

3.a Determine optimal \(E\) for CCM

We now determine the proper embedding dimension for cross-mapping following the procedure of Deyle et al. (2016). We determine \(E^*\) that gives optimal prediction of cross-mapping lagged 1 week. Note that we specificy the lib_size to be the largest possible number of points in the library (even though the actual number will be smaller because of NAs and the zero strings). This is for convenience so that the code will automatically use the largest possible lib_size.

block_temp = df.in %>% select(flu,AH)
lib_ccm = c(1,NROW(df.in))

Emax=8

out.temp = do.call(
    rbind,
    lapply(1:Emax, function(E_i) {
        pred_ccm = make_pred_nozero(block_temp$flu,E_i)
        ccm(block=block_temp,
            E=E_i,
            lib=lib_ccm,
            pred=pred_ccm,
            lib_sizes = NROW(block_temp),
            exclusion_radius=0,
            random_libs = FALSE,
            num_sample=1,
            tp = -1,
            lib_column = 1,
            target_column = 2, 
            silent = TRUE) }
    )
)

out.temp
E tau tp num_neighbors lib_column target_column lib_size num_pred rho mae rmse
1 1 -1 2 1 2 614 400 0.17910471 1.843047 2.501677
2 1 -1 3 1 2 594 400 0.05135658 1.951606 2.597812
3 1 -1 4 1 2 577 399 0.22749008 1.751233 2.342287
4 1 -1 5 1 2 559 399 0.04313842 1.883103 2.497428
5 1 -1 6 1 2 542 406 0.06881939 2.056252 2.737585
6 1 -1 7 1 2 526 416 0.29636337 1.700103 2.285878
7 1 -1 8 1 2 510 415 0.34598041 1.645424 2.229613
8 1 -1 9 1 2 494 415 0.32404071 1.673133 2.290292
E_star = out.temp$E[which.max(out.temp$rho)]
E_star

7

3.b Calculate CCM for real data

We then measure the un-lagged cross-map skill with this value of \(E^*\).

pred_ccm = make_pred_nozero(block_temp$flu,E_star)
df.out.ccm = ccm(block=block_temp,
                    E=E_star,
                    lib=lib_ccm,
                    pred = pred_ccm,
                    lib_sizes = NROW(block_temp),
                    exclusion_radius=0,
                    random_libs = FALSE,
                    num_sample=1,
                    tp = 0, 
                    silent = TRUE)
df.out.ccm
E tau tp num_neighbors lib_column target_column lib_size num_pred rho mae rmse
7 1 0 8 1 2 510 415 0.3955595 1.560958 2.186334
df.out.ccm.surr = data.frame()

for (i_surr in 1:dim(AH.surrs)[2]) {
    block_temp = data.frame(flu=df.in$flu,AH=AH.surrs[,i_surr])
    out.temp = do.call(
        rbind,
        lapply(1:8, function(E_i){
            pred_ccm = make_pred_nozero(block_temp$flu,E_i)
            ccm(block=block_temp,
                E=E_i,
                lib=lib_ccm,
                pred=pred_ccm,
                lib_sizes = NROW(block_temp),
                exclusion_radius=0,
                random_libs = FALSE,
                num_sample=1,
                tp = -1,
                lib_column = 1,
                target_column = 2, 
                silent=TRUE)
            }
        )
    )
    
    E_star = out.temp$E[which.max(out.temp$rho)]
    pred_ccm = make_pred_nozero(block_temp$flu,E_star)
    out.temp = ccm(block = block_temp,
                    E = E_star,
                    lib = lib_ccm,
                    pred = pred_ccm,
                    lib_sizes = NROW(block_temp),
                    exclusion_radius = 0,
                    random_libs = FALSE,
                    num_sample=1,
                    tp = 0,
                    silent=TRUE)
    df.out.ccm.surr <- df.out.ccm.surr %>% bind_rows(out.temp)
} # for i_surr
options(repr.plot.width=3.5,repr.plot.height=5)
boxplot(df.out.ccm.surr$rho, ylab='rho (CCM)', xlab=cntr, main='Flu cross-map AH')
points(1,df.out.ccm$rho, pch=8, col='red', cex=2, lwd=2)

png

df.out.ccm
E tau tp num_neighbors lib_column target_column lib_size num_pred rho mae rmse
7 1 0 8 1 2 510 415 0.3955595 1.560958 2.186334