-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.html
998 lines (987 loc) · 65.1 KB
/
README.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
@font-face {
font-family: octicons-link;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm1ozezUeLEaUjhaDSuXHwVRgvLJn1tQ7xiuVv/ocTRF42mNgZGBgYGbwZOBiAAFGJBIMAAizAFoAAABiAGIAznjaY2BkYGAA4in8zwXi+W2+MjCzMIDApSwvXzC97Z4Ig8N/BxYGZgcgl52BCSQKAA3jCV8CAABfAAAAAAQAAEB42mNgZGBg4f3vACQZQABIMjKgAmYAKEgBXgAAeNpjYGY6wTiBgZWBg2kmUxoDA4MPhGZMYzBi1AHygVLYQUCaawqDA4PChxhmh/8ODDEsvAwHgMKMIDnGL0x7gJQCAwMAJd4MFwAAAHjaY2BgYGaA4DAGRgYQkAHyGMF8NgYrIM3JIAGVYYDT+AEjAwuDFpBmA9KMDEwMCh9i/v8H8sH0/4dQc1iAmAkALaUKLgAAAHjaTY9LDsIgEIbtgqHUPpDi3gPoBVyRTmTddOmqTXThEXqrob2gQ1FjwpDvfwCBdmdXC5AVKFu3e5MfNFJ29KTQT48Ob9/lqYwOGZxeUelN2U2R6+cArgtCJpauW7UQBqnFkUsjAY/kOU1cP+DAgvxwn1chZDwUbd6CFimGXwzwF6tPbFIcjEl+vvmM/byA48e6tWrKArm4ZJlCbdsrxksL1AwWn/yBSJKpYbq8AXaaTb8AAHja28jAwOC00ZrBeQNDQOWO//sdBBgYGRiYWYAEELEwMTE4uzo5Zzo5b2BxdnFOcALxNjA6b2ByTswC8jYwg0VlNuoCTWAMqNzMzsoK1rEhNqByEyerg5PMJlYuVueETKcd/89uBpnpvIEVomeHLoMsAAe1Id4AAAAAAAB42oWQT07CQBTGv0JBhagk7HQzKxca2sJCE1hDt4QF+9JOS0nbaaYDCQfwCJ7Au3AHj+LO13FMmm6cl7785vven0kBjHCBhfpYuNa5Ph1c0e2Xu3jEvWG7UdPDLZ4N92nOm+EBXuAbHmIMSRMs+4aUEd4Nd3CHD8NdvOLTsA2GL8M9PODbcL+hD7C1xoaHeLJSEao0FEW14ckxC+TU8TxvsY6X0eLPmRhry2WVioLpkrbp84LLQPGI7c6sOiUzpWIWS5GzlSgUzzLBSikOPFTOXqly7rqx0Z1Q5BAIoZBSFihQYQOOBEdkCOgXTOHA07HAGjGWiIjaPZNW13/+lm6S9FT7rLHFJ6fQbkATOG1j2OFMucKJJsxIVfQORl+9Jyda6Sl1dUYhSCm1dyClfoeDve4qMYdLEbfqHf3O/AdDumsjAAB42mNgYoAAZQYjBmyAGYQZmdhL8zLdDEydARfoAqIAAAABAAMABwAKABMAB///AA8AAQAAAAAAAAAAAAAAAAABAAAAAA==) format('woff');
}
body {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
color: #333;
font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 16px;
line-height: 1.6;
word-wrap: break-word;
}
a {
background-color: transparent;
}
a:active,
a:hover {
outline: 0;
}
strong {
font-weight: bold;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
img {
border: 0;
}
hr {
box-sizing: content-box;
height: 0;
}
pre {
overflow: auto;
}
code,
kbd,
pre {
font-family: monospace, monospace;
font-size: 1em;
}
input {
color: inherit;
font: inherit;
margin: 0;
}
html input[disabled] {
cursor: default;
}
input {
line-height: normal;
}
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}
* {
box-sizing: border-box;
}
input {
font: 13px / 1.4 Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
a {
color: #4078c0;
text-decoration: none;
}
a:hover,
a:active {
text-decoration: underline;
}
hr {
height: 0;
margin: 15px 0;
overflow: hidden;
background: transparent;
border: 0;
border-bottom: 1px solid #ddd;
}
hr:before {
display: table;
content: "";
}
hr:after {
display: table;
clear: both;
content: "";
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 15px;
margin-bottom: 15px;
line-height: 1.1;
}
h1 {
font-size: 30px;
}
h2 {
font-size: 21px;
}
h3 {
font-size: 16px;
}
h4 {
font-size: 14px;
}
h5 {
font-size: 12px;
}
h6 {
font-size: 11px;
}
blockquote {
margin: 0;
}
ul,
ol {
padding: 0;
margin-top: 0;
margin-bottom: 0;
}
ol ol,
ul ol {
list-style-type: lower-roman;
}
ul ul ol,
ul ol ol,
ol ul ol,
ol ol ol {
list-style-type: lower-alpha;
}
dd {
margin-left: 0;
}
code {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 12px;
}
pre {
margin-top: 0;
margin-bottom: 0;
font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
.select::-ms-expand {
opacity: 0;
}
.octicon {
font: normal normal normal 16px/1 octicons-link;
display: inline-block;
text-decoration: none;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.octicon-link:before {
content: '\f05c';
}
.markdown-body:before {
display: table;
content: "";
}
.markdown-body:after {
display: table;
clear: both;
content: "";
}
.markdown-body>*:first-child {
margin-top: 0 !important;
}
.markdown-body>*:last-child {
margin-bottom: 0 !important;
}
a:not([href]) {
color: inherit;
text-decoration: none;
}
.anchor {
display: inline-block;
padding-right: 2px;
margin-left: -18px;
}
.anchor:focus {
outline: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 1em;
margin-bottom: 16px;
font-weight: bold;
line-height: 1.4;
}
h1 .octicon-link,
h2 .octicon-link,
h3 .octicon-link,
h4 .octicon-link,
h5 .octicon-link,
h6 .octicon-link {
color: #000;
vertical-align: middle;
visibility: hidden;
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
text-decoration: none;
}
h1:hover .anchor .octicon-link,
h2:hover .anchor .octicon-link,
h3:hover .anchor .octicon-link,
h4:hover .anchor .octicon-link,
h5:hover .anchor .octicon-link,
h6:hover .anchor .octicon-link {
visibility: visible;
}
h1 {
padding-bottom: 0.3em;
font-size: 2.25em;
line-height: 1.2;
border-bottom: 1px solid #eee;
}
h1 .anchor {
line-height: 1;
}
h2 {
padding-bottom: 0.3em;
font-size: 1.75em;
line-height: 1.225;
border-bottom: 1px solid #eee;
}
h2 .anchor {
line-height: 1;
}
h3 {
font-size: 1.5em;
line-height: 1.43;
}
h3 .anchor {
line-height: 1.2;
}
h4 {
font-size: 1.25em;
}
h4 .anchor {
line-height: 1.2;
}
h5 {
font-size: 1em;
}
h5 .anchor {
line-height: 1.1;
}
h6 {
font-size: 1em;
color: #777;
}
h6 .anchor {
line-height: 1.1;
}
p,
blockquote,
ul,
ol,
dl,
table,
pre {
margin-top: 0;
margin-bottom: 16px;
}
hr {
height: 4px;
padding: 0;
margin: 16px 0;
background-color: #e7e7e7;
border: 0 none;
}
ul,
ol {
padding-left: 2em;
}
ul ul,
ul ol,
ol ol,
ol ul {
margin-top: 0;
margin-bottom: 0;
}
li>p {
margin-top: 16px;
}
dl {
padding: 0;
}
dl dt {
padding: 0;
margin-top: 16px;
font-size: 1em;
font-style: italic;
font-weight: bold;
}
dl dd {
padding: 0 16px;
margin-bottom: 16px;
}
blockquote {
padding: 0 15px;
color: #777;
border-left: 4px solid #ddd;
}
blockquote>:first-child {
margin-top: 0;
}
blockquote>:last-child {
margin-bottom: 0;
}
table {
display: block;
width: 100%;
overflow: auto;
word-break: normal;
word-break: keep-all;
}
table th {
font-weight: bold;
}
table th,
table td {
padding: 6px 13px;
border: 1px solid #ddd;
}
table tr {
background-color: #fff;
border-top: 1px solid #ccc;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
img {
max-width: 100%;
box-sizing: content-box;
background-color: #fff;
}
code {
padding: 0;
padding-top: 0.2em;
padding-bottom: 0.2em;
margin: 0;
font-size: 85%;
background-color: rgba(0,0,0,0.04);
border-radius: 3px;
}
code:before,
code:after {
letter-spacing: -0.2em;
content: "\00a0";
}
pre>code {
padding: 0;
margin: 0;
font-size: 100%;
word-break: normal;
white-space: pre;
background: transparent;
border: 0;
}
.highlight {
margin-bottom: 16px;
}
.highlight pre,
pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border-radius: 3px;
}
.highlight pre {
margin-bottom: 0;
word-break: normal;
}
pre {
word-wrap: normal;
}
pre code {
display: inline;
max-width: initial;
padding: 0;
margin: 0;
overflow: initial;
line-height: inherit;
word-wrap: normal;
background-color: transparent;
border: 0;
}
pre code:before,
pre code:after {
content: normal;
}
kbd {
display: inline-block;
padding: 3px 5px;
font-size: 11px;
line-height: 10px;
color: #555;
vertical-align: middle;
background-color: #fcfcfc;
border: solid 1px #ccc;
border-bottom-color: #bbb;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #bbb;
}
.pl-c {
color: #969896;
}
.pl-c1,
.pl-s .pl-v {
color: #0086b3;
}
.pl-e,
.pl-en {
color: #795da3;
}
.pl-s .pl-s1,
.pl-smi {
color: #333;
}
.pl-ent {
color: #63a35c;
}
.pl-k {
color: #a71d5d;
}
.pl-pds,
.pl-s,
.pl-s .pl-pse .pl-s1,
.pl-sr,
.pl-sr .pl-cce,
.pl-sr .pl-sra,
.pl-sr .pl-sre {
color: #183691;
}
.pl-v {
color: #ed6a43;
}
.pl-id {
color: #b52a1d;
}
.pl-ii {
background-color: #b52a1d;
color: #f8f8f8;
}
.pl-sr .pl-cce {
color: #63a35c;
font-weight: bold;
}
.pl-ml {
color: #693a17;
}
.pl-mh,
.pl-mh .pl-en,
.pl-ms {
color: #1d3e81;
font-weight: bold;
}
.pl-mq {
color: #008080;
}
.pl-mi {
color: #333;
font-style: italic;
}
.pl-mb {
color: #333;
font-weight: bold;
}
.pl-md {
background-color: #ffecec;
color: #bd2c00;
}
.pl-mi1 {
background-color: #eaffea;
color: #55a532;
}
.pl-mdr {
color: #795da3;
font-weight: bold;
}
.pl-mo {
color: #1d3e81;
}
kbd {
display: inline-block;
padding: 3px 5px;
font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
line-height: 10px;
color: #555;
vertical-align: middle;
background-color: #fcfcfc;
border: solid 1px #ccc;
border-bottom-color: #bbb;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #bbb;
}
.task-list-item {
list-style-type: none;
}
.task-list-item+.task-list-item {
margin-top: 3px;
}
.task-list-item input {
margin: 0 0.35em 0.25em -1.6em;
vertical-align: middle;
}
:checked+.radio-label {
z-index: 1;
position: relative;
border-color: #4078c0;
}
.sourceLine {
display: inline-block;
}
code .kw { color: #000000; }
code .dt { color: #ed6a43; }
code .dv { color: #009999; }
code .bn { color: #009999; }
code .fl { color: #009999; }
code .ch { color: #009999; }
code .st { color: #183691; }
code .co { color: #969896; }
code .ot { color: #0086b3; }
code .al { color: #a61717; }
code .fu { color: #63a35c; }
code .er { color: #a61717; background-color: #e3d2d2; }
code .wa { color: #000000; }
code .cn { color: #008080; }
code .sc { color: #008080; }
code .vs { color: #183691; }
code .ss { color: #183691; }
code .im { color: #000000; }
code .va {color: #008080; }
code .cf { color: #000000; }
code .op { color: #000000; }
code .bu { color: #000000; }
code .ex { color: #000000; }
code .pp { color: #999999; }
code .at { color: #008080; }
code .do { color: #969896; }
code .an { color: #008080; }
code .cv { color: #008080; }
code .in { color: #008080; }
</style>
<style>
body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
padding-top: 0px;
}
</style>
</head>
<body>
<!-- README.md is generated from README.Rmd. Please edit that file -->
<h1 id="gpmodels">gpmodels</h1>
<h2 id="a-grammar-of-prediction-models">A Grammar of Prediction Models</h2>
<p>This package provides a grammar for data preparation and evaluation of fixed-origin and rolling-origin prediction models using data collected at irregular intervals.</p>
<!-- badges: start -->
<p><a href="https://www.tidyverse.org/lifecycle/#maturing"><img src="data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTE2IiBoZWlnaHQ9IjIwIiByb2xlPSJpbWciIGFyaWEtbGFiZWw9ImxpZmVjeWNsZTogbWF0dXJpbmciPjx0aXRsZT5saWZlY3ljbGU6IG1hdHVyaW5nPC90aXRsZT48bGluZWFyR3JhZGllbnQgaWQ9InMiIHgyPSIwIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjYmJiIiBzdG9wLW9wYWNpdHk9Ii4xIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLW9wYWNpdHk9Ii4xIi8+PC9saW5lYXJHcmFkaWVudD48Y2xpcFBhdGggaWQ9InIiPjxyZWN0IHdpZHRoPSIxMTYiIGhlaWdodD0iMjAiIHJ4PSIzIiBmaWxsPSIjZmZmIi8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjcikiPjxyZWN0IHdpZHRoPSI1NSIgaGVpZ2h0PSIyMCIgZmlsbD0iIzU1NSIvPjxyZWN0IHg9IjU1IiB3aWR0aD0iNjEiIGhlaWdodD0iMjAiIGZpbGw9IiMwMDdlYzYiLz48cmVjdCB3aWR0aD0iMTE2IiBoZWlnaHQ9IjIwIiBmaWxsPSJ1cmwoI3MpIi8+PC9nPjxnIGZpbGw9IiNmZmYiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZvbnQtZmFtaWx5PSJWZXJkYW5hLEdlbmV2YSxEZWphVnUgU2FucyxzYW5zLXNlcmlmIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBmb250LXNpemU9IjExMCI+PHRleHQgYXJpYS1oaWRkZW49InRydWUiIHg9IjI4NSIgeT0iMTUwIiBmaWxsPSIjMDEwMTAxIiBmaWxsLW9wYWNpdHk9Ii4zIiB0cmFuc2Zvcm09InNjYWxlKC4xKSIgdGV4dExlbmd0aD0iNDUwIj5saWZlY3ljbGU8L3RleHQ+PHRleHQgeD0iMjg1IiB5PSIxNDAiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiBmaWxsPSIjZmZmIiB0ZXh0TGVuZ3RoPSI0NTAiPmxpZmVjeWNsZTwvdGV4dD48dGV4dCBhcmlhLWhpZGRlbj0idHJ1ZSIgeD0iODQ1IiB5PSIxNTAiIGZpbGw9IiMwMTAxMDEiIGZpbGwtb3BhY2l0eT0iLjMiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiB0ZXh0TGVuZ3RoPSI1MTAiPm1hdHVyaW5nPC90ZXh0Pjx0ZXh0IHg9Ijg0NSIgeT0iMTQwIiB0cmFuc2Zvcm09InNjYWxlKC4xKSIgZmlsbD0iI2ZmZiIgdGV4dExlbmd0aD0iNTEwIj5tYXR1cmluZzwvdGV4dD48L2c+PC9zdmc+" alt="Lifecycle: maturing" /></a></p>
<!-- badges: end -->
<h2 id="installation">Installation</h2>
<p>You can install the GitHub version of gpmodels with:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1"></a>remotes<span class="op">::</span><span class="kw">install_github</span>(<span class="st">'ML4LHS/gpmodels'</span>)</span></code></pre></div>
<h2 id="how-to-set-up-a-time_frame">How to set up a time_frame()</h2>
<p>Start by loading and package and defining your <code>time_frame()</code>. A <code>time_frame</code> is simply a list with the class <code>time_frame</code> and contains all the key information needed to describe both your fixed dataset (such as demographics, one row per patient) and your temporal dataset (one row per observation linked to a timestamp).</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a><span class="kw">library</span>(gpmodels)</span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a><span class="kw">library</span>(magrittr)</span>
<span id="cb3-2"><a href="#cb3-2"></a><span class="kw">library</span>(lubridate)</span>
<span id="cb3-3"><a href="#cb3-3"></a></span>
<span id="cb3-4"><a href="#cb3-4"></a>future<span class="op">::</span><span class="kw">plan</span>(<span class="st">'multisession'</span>)</span>
<span id="cb3-5"><a href="#cb3-5"></a></span>
<span id="cb3-6"><a href="#cb3-6"></a><span class="kw">unlink</span>(<span class="kw">file.path</span>(<span class="kw">tempdir</span>(), <span class="st">'gpmodels_dir'</span>, <span class="st">'*.*'</span>))</span>
<span id="cb3-7"><a href="#cb3-7"></a></span>
<span id="cb3-8"><a href="#cb3-8"></a>tf =<span class="st"> </span><span class="kw">time_frame</span>(<span class="dt">fixed_data =</span> sample_fixed_data,</span>
<span id="cb3-9"><a href="#cb3-9"></a> <span class="dt">temporal_data =</span> sample_temporal_data <span class="op">%>%</span><span class="st"> </span>dplyr<span class="op">::</span><span class="kw">filter</span>(id <span class="op">%in%</span><span class="st"> </span><span class="dv">1</span><span class="op">:</span><span class="dv">100</span>),</span>
<span id="cb3-10"><a href="#cb3-10"></a> <span class="dt">fixed_id =</span> <span class="st">'id'</span>,</span>
<span id="cb3-11"><a href="#cb3-11"></a> <span class="dt">fixed_start =</span> <span class="st">'admit_time'</span>,</span>
<span id="cb3-12"><a href="#cb3-12"></a> <span class="dt">fixed_end =</span> <span class="st">'dc_time'</span>,</span>
<span id="cb3-13"><a href="#cb3-13"></a> <span class="dt">temporal_id =</span> <span class="st">'id'</span>,</span>
<span id="cb3-14"><a href="#cb3-14"></a> <span class="dt">temporal_time =</span> <span class="st">'time'</span>,</span>
<span id="cb3-15"><a href="#cb3-15"></a> <span class="dt">temporal_variable =</span> <span class="st">'variable'</span>,</span>
<span id="cb3-16"><a href="#cb3-16"></a> <span class="dt">temporal_category =</span> <span class="st">'category'</span>,</span>
<span id="cb3-17"><a href="#cb3-17"></a> <span class="dt">temporal_value =</span> <span class="st">'value'</span>,</span>
<span id="cb3-18"><a href="#cb3-18"></a> <span class="dt">step =</span> <span class="kw">hours</span>(<span class="dv">6</span>),</span>
<span id="cb3-19"><a href="#cb3-19"></a> <span class="dt">max_length =</span> <span class="kw">days</span>(<span class="dv">7</span>), <span class="co"># optional parameter to limit to first 7 days of hospitalization</span></span>
<span id="cb3-20"><a href="#cb3-20"></a> <span class="dt">output_folder =</span> <span class="kw">file.path</span>(<span class="kw">tempdir</span>(), <span class="st">'gpmodels_dir'</span>),</span>
<span id="cb3-21"><a href="#cb3-21"></a> <span class="dt">create_folder =</span> <span class="ot">TRUE</span>)</span></code></pre></div>
<h2 id="lets-look-at-the-automatically-generated-data-dictionaries">Let’s look at the automatically generated data dictionaries</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1"></a><span class="kw">names</span>(tf)</span>
<span id="cb4-2"><a href="#cb4-2"></a><span class="co">#> [1] "fixed_data" "temporal_data" "fixed_id" "fixed_start" "fixed_end" "temporal_id" </span></span>
<span id="cb4-3"><a href="#cb4-3"></a><span class="co">#> [7] "temporal_time" "temporal_variable" "temporal_value" "temporal_category" "step" "max_length" </span></span>
<span id="cb4-4"><a href="#cb4-4"></a><span class="co">#> [13] "step_units" "output_folder" "fixed_data_dict" "temporal_data_dict" "chunk_size"</span></span>
<span id="cb4-5"><a href="#cb4-5"></a></span>
<span id="cb4-6"><a href="#cb4-6"></a>tf<span class="op">$</span>step</span>
<span id="cb4-7"><a href="#cb4-7"></a><span class="co">#> [1] 6</span></span>
<span id="cb4-8"><a href="#cb4-8"></a></span>
<span id="cb4-9"><a href="#cb4-9"></a>tf<span class="op">$</span>step_units</span>
<span id="cb4-10"><a href="#cb4-10"></a><span class="co">#> [1] "hour"</span></span>
<span id="cb4-11"><a href="#cb4-11"></a></span>
<span id="cb4-12"><a href="#cb4-12"></a>tf<span class="op">$</span>fixed_data_dict</span>
<span id="cb4-13"><a href="#cb4-13"></a><span class="co">#> variable class</span></span>
<span id="cb4-14"><a href="#cb4-14"></a><span class="co">#> 1 id integer</span></span>
<span id="cb4-15"><a href="#cb4-15"></a><span class="co">#> 2 sex character</span></span>
<span id="cb4-16"><a href="#cb4-16"></a><span class="co">#> 3 age numeric</span></span>
<span id="cb4-17"><a href="#cb4-17"></a><span class="co">#> 4 race character</span></span>
<span id="cb4-18"><a href="#cb4-18"></a><span class="co">#> 5 baseline_cr numeric</span></span>
<span id="cb4-19"><a href="#cb4-19"></a><span class="co">#> 6 admit_time POSIXct</span></span>
<span id="cb4-20"><a href="#cb4-20"></a><span class="co">#> 7 dc_time POSIXct</span></span>
<span id="cb4-21"><a href="#cb4-21"></a></span>
<span id="cb4-22"><a href="#cb4-22"></a>tf<span class="op">$</span>temporal_data_dict</span>
<span id="cb4-23"><a href="#cb4-23"></a><span class="co">#> variable class</span></span>
<span id="cb4-24"><a href="#cb4-24"></a><span class="co">#> 1 cr numeric</span></span>
<span id="cb4-25"><a href="#cb4-25"></a><span class="co">#> 2 cr_abnl character</span></span>
<span id="cb4-26"><a href="#cb4-26"></a><span class="co">#> 3 cr_high character</span></span>
<span id="cb4-27"><a href="#cb4-27"></a><span class="co">#> 4 med character</span></span></code></pre></div>
<h2 id="lets-dummy-code-the-temporal-categorical-variables">Let’s dummy code the temporal categorical variables</h2>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1"></a>tf =<span class="st"> </span>tf <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb5-2"><a href="#cb5-2"></a><span class="st"> </span><span class="kw">pre_dummy_code</span>()</span></code></pre></div>
<p>This affects only the temporal data and not the fixed data.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1"></a>tf<span class="op">$</span>fixed_data_dict</span>
<span id="cb6-2"><a href="#cb6-2"></a><span class="co">#> variable class</span></span>
<span id="cb6-3"><a href="#cb6-3"></a><span class="co">#> 1 id integer</span></span>
<span id="cb6-4"><a href="#cb6-4"></a><span class="co">#> 2 sex character</span></span>
<span id="cb6-5"><a href="#cb6-5"></a><span class="co">#> 3 age numeric</span></span>
<span id="cb6-6"><a href="#cb6-6"></a><span class="co">#> 4 race character</span></span>
<span id="cb6-7"><a href="#cb6-7"></a><span class="co">#> 5 baseline_cr numeric</span></span>
<span id="cb6-8"><a href="#cb6-8"></a><span class="co">#> 6 admit_time POSIXct</span></span>
<span id="cb6-9"><a href="#cb6-9"></a><span class="co">#> 7 dc_time POSIXct</span></span>
<span id="cb6-10"><a href="#cb6-10"></a></span>
<span id="cb6-11"><a href="#cb6-11"></a>tf<span class="op">$</span>temporal_data_dict</span>
<span id="cb6-12"><a href="#cb6-12"></a><span class="co">#> variable class</span></span>
<span id="cb6-13"><a href="#cb6-13"></a><span class="co">#> 1 cr numeric</span></span>
<span id="cb6-14"><a href="#cb6-14"></a><span class="co">#> 2 cr_abnl_high numeric</span></span>
<span id="cb6-15"><a href="#cb6-15"></a><span class="co">#> 3 cr_abnl_low numeric</span></span>
<span id="cb6-16"><a href="#cb6-16"></a><span class="co">#> 4 cr_abnl_normal numeric</span></span>
<span id="cb6-17"><a href="#cb6-17"></a><span class="co">#> 5 cr_high_no numeric</span></span>
<span id="cb6-18"><a href="#cb6-18"></a><span class="co">#> 6 cr_high_yes numeric</span></span>
<span id="cb6-19"><a href="#cb6-19"></a><span class="co">#> 7 med_acetaminophen numeric</span></span>
<span id="cb6-20"><a href="#cb6-20"></a><span class="co">#> 8 med_aspirin numeric</span></span>
<span id="cb6-21"><a href="#cb6-21"></a><span class="co">#> 9 med_diphenhydramine numeric</span></span></code></pre></div>
<h2 id="lets-add-some-predictors-and-outcomes">Let’s add some predictors and outcomes</h2>
<p>The default method writes output to the folder defined in your <code>time_frame</code>. When you write your output to file, you are allowed to chain together <code>add_predictors()</code> and <code>add_outcomes()</code> functions. This is possble because these functions invisibly return a <code>time_frame</code>.</p>
<p>If, however, you set <code>output_file</code> to <code>FALSE</code>, then your actual output is returned (rather than the <code>time_frame</code>) so you cannot chain functions.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1"></a>tf <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb7-2"><a href="#cb7-2"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">variables =</span> <span class="st">'cr'</span>, <span class="co"># Note: You can supply a vector of variables</span></span>
<span id="cb7-3"><a href="#cb7-3"></a> <span class="dt">lookback =</span> <span class="kw">hours</span>(<span class="dv">12</span>), </span>
<span id="cb7-4"><a href="#cb7-4"></a> <span class="dt">window =</span> <span class="kw">hours</span>(<span class="dv">6</span>), </span>
<span id="cb7-5"><a href="#cb7-5"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">mean =</span> mean,</span>
<span id="cb7-6"><a href="#cb7-6"></a> <span class="dt">min =</span> min,</span>
<span id="cb7-7"><a href="#cb7-7"></a> <span class="dt">max =</span> max,</span>
<span id="cb7-8"><a href="#cb7-8"></a> <span class="dt">median =</span> median,</span>
<span id="cb7-9"><a href="#cb7-9"></a> <span class="dt">length =</span> length)) <span class="op">%>%</span></span>
<span id="cb7-10"><a href="#cb7-10"></a><span class="st"> </span><span class="kw">add_baseline_predictors</span>(<span class="dt">variables =</span> <span class="st">'cr'</span>, <span class="co"># add baseline creatinine</span></span>
<span id="cb7-11"><a href="#cb7-11"></a> <span class="dt">lookback =</span> <span class="kw">days</span>(<span class="dv">90</span>),</span>
<span id="cb7-12"><a href="#cb7-12"></a> <span class="dt">offset =</span> <span class="kw">hours</span>(<span class="dv">10</span>),</span>
<span id="cb7-13"><a href="#cb7-13"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">min =</span> min)) <span class="op">%>%</span></span>
<span id="cb7-14"><a href="#cb7-14"></a><span class="st"> </span><span class="kw">add_growing_predictors</span>(<span class="dt">variables =</span> <span class="st">'cr'</span>, <span class="co"># cumulative max creatinine since admission</span></span>
<span id="cb7-15"><a href="#cb7-15"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">max =</span> max)) <span class="op">%>%</span></span>
<span id="cb7-16"><a href="#cb7-16"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">category =</span> <span class="st">'med'</span>, <span class="co"># Note: category is always a regular expression </span></span>
<span id="cb7-17"><a href="#cb7-17"></a> <span class="dt">lookback =</span> <span class="kw">days</span>(<span class="dv">7</span>),</span>
<span id="cb7-18"><a href="#cb7-18"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">sum =</span> sum)) <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb7-19"><a href="#cb7-19"></a><span class="st"> </span><span class="kw">add_rolling_outcomes</span>(<span class="dt">variables =</span> <span class="st">'cr'</span>,</span>
<span id="cb7-20"><a href="#cb7-20"></a> <span class="dt">lookahead =</span> <span class="kw">hours</span>(<span class="dv">24</span>), </span>
<span id="cb7-21"><a href="#cb7-21"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">max =</span> max))</span>
<span id="cb7-22"><a href="#cb7-22"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb7-23"><a href="#cb7-23"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb7-24"><a href="#cb7-24"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb7-25"><a href="#cb7-25"></a><span class="co">#> Number of rows in final output: 1540</span></span>
<span id="cb7-26"><a href="#cb7-26"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb7-27"><a href="#cb7-27"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb7-28"><a href="#cb7-28"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb7-29"><a href="#cb7-29"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb7-30"><a href="#cb7-30"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/rolling_predictors_variables_cr_2021_07_12_01_33_50.csv</span></span>
<span id="cb7-31"><a href="#cb7-31"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb7-32"><a href="#cb7-32"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb7-33"><a href="#cb7-33"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb7-34"><a href="#cb7-34"></a><span class="co">#> Number of rows in final output: 100</span></span>
<span id="cb7-35"><a href="#cb7-35"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb7-36"><a href="#cb7-36"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb7-37"><a href="#cb7-37"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb7-38"><a href="#cb7-38"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb7-39"><a href="#cb7-39"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/baseline_predictors_variables_cr_2021_07_12_01_33_52.csv</span></span>
<span id="cb7-40"><a href="#cb7-40"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb7-41"><a href="#cb7-41"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb7-42"><a href="#cb7-42"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb7-43"><a href="#cb7-43"></a><span class="co">#> Number of rows in final output: 1540</span></span>
<span id="cb7-44"><a href="#cb7-44"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb7-45"><a href="#cb7-45"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb7-46"><a href="#cb7-46"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb7-47"><a href="#cb7-47"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb7-48"><a href="#cb7-48"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/growing_predictors_variables_cr_2021_07_12_01_34_17.csv</span></span>
<span id="cb7-49"><a href="#cb7-49"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb7-50"><a href="#cb7-50"></a><span class="co">#> Processing category: med...</span></span>
<span id="cb7-51"><a href="#cb7-51"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb7-52"><a href="#cb7-52"></a><span class="co">#> Number of rows in final output: 1540</span></span>
<span id="cb7-53"><a href="#cb7-53"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb7-54"><a href="#cb7-54"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb7-55"><a href="#cb7-55"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb7-56"><a href="#cb7-56"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb7-57"><a href="#cb7-57"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/rolling_predictors_category_med_2021_07_12_01_34_48.csv</span></span>
<span id="cb7-58"><a href="#cb7-58"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb7-59"><a href="#cb7-59"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb7-60"><a href="#cb7-60"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb7-61"><a href="#cb7-61"></a><span class="co">#> Number of rows in final output: 1540</span></span>
<span id="cb7-62"><a href="#cb7-62"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb7-63"><a href="#cb7-63"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb7-64"><a href="#cb7-64"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb7-65"><a href="#cb7-65"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb7-66"><a href="#cb7-66"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/rolling_outcomes_variables_cr_2021_07_12_01_35_19.csv</span></span></code></pre></div>
<h2 id="lets-combine-our-output-into-a-single-data-frame">Let’s combine our output into a single data frame</h2>
<p>You can provide <code>combine_output()</code> with a set of data frames separated by commas. Or, you can provide a vector of file names using the <code>files</code> argument. If you leave <code>files</code> blank, it will automatically find all the <code>.csv</code> files from the <code>output_folder</code> of your <code>time_frame</code>.</p>
<p>This resulting frame is essentially ready for modeling (using <code>tidymodels</code>, for example). Make sure to keep individual patients in the same fold if you divide this dataset into multiple folds.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1"></a>model_data =<span class="st"> </span><span class="kw">combine_output</span>(tf)</span>
<span id="cb8-2"><a href="#cb8-2"></a><span class="co">#> Reading file: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/baseline_predictors_variables_cr_2021_07_12_01_33_52.csv...</span></span>
<span id="cb8-3"><a href="#cb8-3"></a><span class="co">#> Reading file: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/growing_predictors_variables_cr_2021_07_12_01_34_17.csv...</span></span>
<span id="cb8-4"><a href="#cb8-4"></a><span class="co">#> Reading file: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/rolling_outcomes_variables_cr_2021_07_12_01_35_19.csv...</span></span>
<span id="cb8-5"><a href="#cb8-5"></a><span class="co">#> Reading file: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/rolling_predictors_category_med_2021_07_12_01_34_48.csv...</span></span>
<span id="cb8-6"><a href="#cb8-6"></a><span class="co">#> Reading file: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/rolling_predictors_variables_cr_2021_07_12_01_33_50.csv...</span></span>
<span id="cb8-7"><a href="#cb8-7"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb8-8"><a href="#cb8-8"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb8-9"><a href="#cb8-9"></a><span class="co">#> Joining, by = c("id", "time")</span></span>
<span id="cb8-10"><a href="#cb8-10"></a><span class="co">#> Joining, by = c("id", "time")</span></span>
<span id="cb8-11"><a href="#cb8-11"></a><span class="co">#> Joining, by = c("id", "time")</span></span>
<span id="cb8-12"><a href="#cb8-12"></a></span>
<span id="cb8-13"><a href="#cb8-13"></a><span class="kw">head</span>(model_data)</span>
<span id="cb8-14"><a href="#cb8-14"></a><span class="co">#> id sex age race baseline_cr admit_time dc_time baseline_cr_min_2160 time growing_cr_max</span></span>
<span id="cb8-15"><a href="#cb8-15"></a><span class="co">#> 1 1 male 66.15955 asian 1.001175 2019-06-02 00:49:23 2019-06-08 10:38:23 NA 0 NA</span></span>
<span id="cb8-16"><a href="#cb8-16"></a><span class="co">#> 2 1 male 66.15955 asian 1.001175 2019-06-02 00:49:23 2019-06-08 10:38:23 NA 6 NA</span></span>
<span id="cb8-17"><a href="#cb8-17"></a><span class="co">#> 3 1 male 66.15955 asian 1.001175 2019-06-02 00:49:23 2019-06-08 10:38:23 NA 12 1.039322</span></span>
<span id="cb8-18"><a href="#cb8-18"></a><span class="co">#> 4 1 male 66.15955 asian 1.001175 2019-06-02 00:49:23 2019-06-08 10:38:23 NA 18 1.217020</span></span>
<span id="cb8-19"><a href="#cb8-19"></a><span class="co">#> 5 1 male 66.15955 asian 1.001175 2019-06-02 00:49:23 2019-06-08 10:38:23 NA 24 1.217020</span></span>
<span id="cb8-20"><a href="#cb8-20"></a><span class="co">#> 6 1 male 66.15955 asian 1.001175 2019-06-02 00:49:23 2019-06-08 10:38:23 NA 30 1.217020</span></span>
<span id="cb8-21"><a href="#cb8-21"></a><span class="co">#> outcome_cr_max_24 med_acetaminophen_sum_168 med_aspirin_sum_168 med_diphenhydramine_sum_168 cr_length_06 cr_length_12 cr_max_06</span></span>
<span id="cb8-22"><a href="#cb8-22"></a><span class="co">#> 1 1.217020 0 0 0 1 1 1.003659</span></span>
<span id="cb8-23"><a href="#cb8-23"></a><span class="co">#> 2 1.217020 0 0 0 0 1 1.003659</span></span>
<span id="cb8-24"><a href="#cb8-24"></a><span class="co">#> 3 1.217020 1 0 0 1 0 1.039322</span></span>
<span id="cb8-25"><a href="#cb8-25"></a><span class="co">#> 4 1.179722 1 0 0 2 1 1.217020</span></span>
<span id="cb8-26"><a href="#cb8-26"></a><span class="co">#> 5 1.274939 1 0 0 1 2 1.179722</span></span>
<span id="cb8-27"><a href="#cb8-27"></a><span class="co">#> 6 1.274939 1 0 0 3 1 1.165989</span></span>
<span id="cb8-28"><a href="#cb8-28"></a><span class="co">#> cr_max_12 cr_mean_06 cr_mean_12 cr_median_06 cr_median_12 cr_min_06 cr_min_12</span></span>
<span id="cb8-29"><a href="#cb8-29"></a><span class="co">#> 1 1.030098 1.003659 1.030098 1.003659 1.030098 1.0036587 1.030098</span></span>
<span id="cb8-30"><a href="#cb8-30"></a><span class="co">#> 2 1.003659 1.003659 1.003659 1.003659 1.003659 1.0036587 1.003659</span></span>
<span id="cb8-31"><a href="#cb8-31"></a><span class="co">#> 3 NA 1.039322 NA 1.039322 NA 1.0393216 NA</span></span>
<span id="cb8-32"><a href="#cb8-32"></a><span class="co">#> 4 1.039322 1.109985 1.039322 1.109985 1.039322 1.0029506 1.039322</span></span>
<span id="cb8-33"><a href="#cb8-33"></a><span class="co">#> 5 1.217020 1.179722 1.109985 1.179722 1.109985 1.1797219 1.002951</span></span>
<span id="cb8-34"><a href="#cb8-34"></a><span class="co">#> 6 1.179722 1.069630 1.179722 1.096827 1.179722 0.9460735 1.179722</span></span></code></pre></div>
<h2 id="testing-time_frame-without-writing-output-to-files">Testing time_frame without writing output to files</h2>
<p>If you want to simply test <code>time_frame</code>, you may prefer not to write your output to file. You can accomplish this by setting <code>output_file</code> to <code>FALSE</code>.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1"></a>tf <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb9-2"><a href="#cb9-2"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">variables =</span> <span class="st">'cr'</span>,</span>
<span id="cb9-3"><a href="#cb9-3"></a> <span class="dt">lookback =</span> <span class="kw">hours</span>(<span class="dv">12</span>), </span>
<span id="cb9-4"><a href="#cb9-4"></a> <span class="dt">window =</span> <span class="kw">hours</span>(<span class="dv">6</span>), </span>
<span id="cb9-5"><a href="#cb9-5"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">mean =</span> mean,</span>
<span id="cb9-6"><a href="#cb9-6"></a> <span class="dt">min =</span> min,</span>
<span id="cb9-7"><a href="#cb9-7"></a> <span class="dt">max =</span> max,</span>
<span id="cb9-8"><a href="#cb9-8"></a> <span class="dt">median =</span> median,</span>
<span id="cb9-9"><a href="#cb9-9"></a> <span class="dt">length =</span> length),</span>
<span id="cb9-10"><a href="#cb9-10"></a> <span class="dt">output_file =</span> <span class="ot">FALSE</span>) <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb9-11"><a href="#cb9-11"></a><span class="st"> </span><span class="kw">head</span>()</span>
<span id="cb9-12"><a href="#cb9-12"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb9-13"><a href="#cb9-13"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb9-14"><a href="#cb9-14"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb9-15"><a href="#cb9-15"></a><span class="co">#> Number of rows in final output: 1540</span></span>
<span id="cb9-16"><a href="#cb9-16"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb9-17"><a href="#cb9-17"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb9-18"><a href="#cb9-18"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb9-19"><a href="#cb9-19"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb9-20"><a href="#cb9-20"></a><span class="co">#> id time cr_length_06 cr_length_12 cr_max_06 cr_max_12 cr_mean_06 cr_mean_12 cr_median_06 cr_median_12 cr_min_06 cr_min_12</span></span>
<span id="cb9-21"><a href="#cb9-21"></a><span class="co">#> 1 1 0 1 1 1.003659 1.030098 1.003659 1.030098 1.003659 1.030098 1.0036587 1.030098</span></span>
<span id="cb9-22"><a href="#cb9-22"></a><span class="co">#> 2 1 6 0 1 1.003659 1.003659 1.003659 1.003659 1.003659 1.003659 1.0036587 1.003659</span></span>
<span id="cb9-23"><a href="#cb9-23"></a><span class="co">#> 3 1 12 1 0 1.039322 NA 1.039322 NA 1.039322 NA 1.0393216 NA</span></span>
<span id="cb9-24"><a href="#cb9-24"></a><span class="co">#> 4 1 18 2 1 1.217020 1.039322 1.109985 1.039322 1.109985 1.039322 1.0029506 1.039322</span></span>
<span id="cb9-25"><a href="#cb9-25"></a><span class="co">#> 5 1 24 1 2 1.179722 1.217020 1.179722 1.109985 1.179722 1.109985 1.1797219 1.002951</span></span>
<span id="cb9-26"><a href="#cb9-26"></a><span class="co">#> 6 1 30 3 1 1.165989 1.179722 1.069630 1.179722 1.096827 1.179722 0.9460735 1.179722</span></span></code></pre></div>
<h2 id="you-can-also-supply-a-vector-of-variables">You can also supply a vector of variables</h2>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1"></a>tf <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb10-2"><a href="#cb10-2"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">variables =</span> <span class="kw">c</span>(<span class="st">'cr'</span>, <span class="st">'med_aspirin'</span>),</span>
<span id="cb10-3"><a href="#cb10-3"></a> <span class="dt">lookback =</span> <span class="kw">weeks</span>(<span class="dv">1</span>), </span>
<span id="cb10-4"><a href="#cb10-4"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">length =</span> length),</span>
<span id="cb10-5"><a href="#cb10-5"></a> <span class="dt">output_file =</span> <span class="ot">FALSE</span>) <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb10-6"><a href="#cb10-6"></a><span class="st"> </span><span class="kw">head</span>()</span>
<span id="cb10-7"><a href="#cb10-7"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb10-8"><a href="#cb10-8"></a><span class="co">#> Processing variables: cr, med_aspirin...</span></span>
<span id="cb10-9"><a href="#cb10-9"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb10-10"><a href="#cb10-10"></a><span class="co">#> Number of rows in final output: 1540</span></span>
<span id="cb10-11"><a href="#cb10-11"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb10-12"><a href="#cb10-12"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb10-13"><a href="#cb10-13"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb10-14"><a href="#cb10-14"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb10-15"><a href="#cb10-15"></a><span class="co">#> id time cr_length_168 med_aspirin_length_168</span></span>
<span id="cb10-16"><a href="#cb10-16"></a><span class="co">#> 1 1 0 2 0</span></span>
<span id="cb10-17"><a href="#cb10-17"></a><span class="co">#> 2 1 6 2 0</span></span>
<span id="cb10-18"><a href="#cb10-18"></a><span class="co">#> 3 1 12 3 0</span></span>
<span id="cb10-19"><a href="#cb10-19"></a><span class="co">#> 4 1 18 5 0</span></span>
<span id="cb10-20"><a href="#cb10-20"></a><span class="co">#> 5 1 24 6 0</span></span>
<span id="cb10-21"><a href="#cb10-21"></a><span class="co">#> 6 1 30 9 0</span></span></code></pre></div>
<h2 id="category-accepts-regular-expressions">Category accepts regular expressions</h2>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1"></a>tf <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb11-2"><a href="#cb11-2"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">category =</span> <span class="st">'lab|med'</span>,</span>
<span id="cb11-3"><a href="#cb11-3"></a> <span class="dt">lookback =</span> <span class="kw">hours</span>(<span class="dv">12</span>), </span>
<span id="cb11-4"><a href="#cb11-4"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">length =</span> length),</span>
<span id="cb11-5"><a href="#cb11-5"></a> <span class="dt">output_file =</span> <span class="ot">FALSE</span>) <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb11-6"><a href="#cb11-6"></a><span class="st"> </span><span class="kw">head</span>()</span>
<span id="cb11-7"><a href="#cb11-7"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb11-8"><a href="#cb11-8"></a><span class="co">#> Processing category: lab|med...</span></span>
<span id="cb11-9"><a href="#cb11-9"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb11-10"><a href="#cb11-10"></a><span class="co">#> Number of rows in final output: 1540</span></span>
<span id="cb11-11"><a href="#cb11-11"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb11-12"><a href="#cb11-12"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb11-13"><a href="#cb11-13"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb11-14"><a href="#cb11-14"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb11-15"><a href="#cb11-15"></a><span class="co">#> id time cr_length_12 med_acetaminophen_length_12 med_aspirin_length_12 med_diphenhydramine_length_12</span></span>
<span id="cb11-16"><a href="#cb11-16"></a><span class="co">#> 1 1 0 2 0 0 0</span></span>
<span id="cb11-17"><a href="#cb11-17"></a><span class="co">#> 2 1 6 1 0 0 0</span></span>
<span id="cb11-18"><a href="#cb11-18"></a><span class="co">#> 3 1 12 1 1 0 0</span></span>
<span id="cb11-19"><a href="#cb11-19"></a><span class="co">#> 4 1 18 3 1 0 0</span></span>
<span id="cb11-20"><a href="#cb11-20"></a><span class="co">#> 5 1 24 3 0 0 0</span></span>
<span id="cb11-21"><a href="#cb11-21"></a><span class="co">#> 6 1 30 4 0 0 0</span></span></code></pre></div>
<h2 id="lets-benchmark-the-performance-on-our-package">Let’s benchmark the performance on our package</h2>
<h3 id="running-in-parallel">Running in parallel</h3>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1"></a>benchmark_results =<span class="st"> </span><span class="kw">list</span>()</span>
<span id="cb12-2"><a href="#cb12-2"></a></span>
<span id="cb12-3"><a href="#cb12-3"></a><span class="co"># future::plan('multisession')</span></span>
<span id="cb12-4"><a href="#cb12-4"></a></span>
<span id="cb12-5"><a href="#cb12-5"></a>benchmark_results[[<span class="st">'multisession'</span>]] =<span class="st"> </span></span>
<span id="cb12-6"><a href="#cb12-6"></a><span class="st"> </span>microbenchmark<span class="op">::</span><span class="kw">microbenchmark</span>(</span>
<span id="cb12-7"><a href="#cb12-7"></a> tf <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb12-8"><a href="#cb12-8"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">variable =</span> <span class="st">'cr'</span>,</span>
<span id="cb12-9"><a href="#cb12-9"></a> <span class="dt">lookback =</span> <span class="kw">hours</span>(<span class="dv">48</span>), </span>
<span id="cb12-10"><a href="#cb12-10"></a> <span class="dt">window =</span> <span class="kw">hours</span>(<span class="dv">6</span>), </span>
<span id="cb12-11"><a href="#cb12-11"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">mean =</span> mean,</span>
<span id="cb12-12"><a href="#cb12-12"></a> <span class="dt">min =</span> min,</span>
<span id="cb12-13"><a href="#cb12-13"></a> <span class="dt">max =</span> max,</span>
<span id="cb12-14"><a href="#cb12-14"></a> <span class="dt">median =</span> median,</span>
<span id="cb12-15"><a href="#cb12-15"></a> <span class="dt">length =</span> length)),</span>
<span id="cb12-16"><a href="#cb12-16"></a> <span class="dt">times =</span> <span class="dv">1</span></span>
<span id="cb12-17"><a href="#cb12-17"></a> )</span></code></pre></div>
<h3 id="running-in-parallel-with-a-chunk_size-of-20">Running in parallel with a chunk_size of 20</h3>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1"></a></span>
<span id="cb13-2"><a href="#cb13-2"></a>tf_with_chunks =<span class="st"> </span>tf</span>
<span id="cb13-3"><a href="#cb13-3"></a>tf_with_chunks<span class="op">$</span>chunk_size =<span class="st"> </span><span class="dv">20</span></span>
<span id="cb13-4"><a href="#cb13-4"></a></span>
<span id="cb13-5"><a href="#cb13-5"></a>benchmark_results[[<span class="st">'multisession with chunk_size 20'</span>]] =<span class="st"> </span></span>
<span id="cb13-6"><a href="#cb13-6"></a><span class="st"> </span>microbenchmark<span class="op">::</span><span class="kw">microbenchmark</span>(</span>
<span id="cb13-7"><a href="#cb13-7"></a> tf_with_chunks <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb13-8"><a href="#cb13-8"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">variable =</span> <span class="st">'cr'</span>,</span>
<span id="cb13-9"><a href="#cb13-9"></a> <span class="dt">lookback =</span> <span class="kw">hours</span>(<span class="dv">48</span>), </span>
<span id="cb13-10"><a href="#cb13-10"></a> <span class="dt">window =</span> <span class="kw">hours</span>(<span class="dv">6</span>), </span>
<span id="cb13-11"><a href="#cb13-11"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">mean =</span> mean,</span>
<span id="cb13-12"><a href="#cb13-12"></a> <span class="dt">min =</span> min,</span>
<span id="cb13-13"><a href="#cb13-13"></a> <span class="dt">max =</span> max,</span>
<span id="cb13-14"><a href="#cb13-14"></a> <span class="dt">median =</span> median,</span>
<span id="cb13-15"><a href="#cb13-15"></a> <span class="dt">length =</span> length)),</span>
<span id="cb13-16"><a href="#cb13-16"></a> <span class="dt">times =</span> <span class="dv">1</span></span>
<span id="cb13-17"><a href="#cb13-17"></a> )</span>
<span id="cb13-18"><a href="#cb13-18"></a><span class="co">#> Processing chunk # 1 out of 5...</span></span>
<span id="cb13-19"><a href="#cb13-19"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb13-20"><a href="#cb13-20"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb13-21"><a href="#cb13-21"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb13-22"><a href="#cb13-22"></a><span class="co">#> Number of rows in final output: 270</span></span>
<span id="cb13-23"><a href="#cb13-23"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb13-24"><a href="#cb13-24"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb13-25"><a href="#cb13-25"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb13-26"><a href="#cb13-26"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb13-27"><a href="#cb13-27"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/chunk_1_rolling_predictors_variables_cr_2021_07_12_01_37_39.csv</span></span>
<span id="cb13-28"><a href="#cb13-28"></a><span class="co">#> Processing chunk # 2 out of 5...</span></span>
<span id="cb13-29"><a href="#cb13-29"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb13-30"><a href="#cb13-30"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb13-31"><a href="#cb13-31"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb13-32"><a href="#cb13-32"></a><span class="co">#> Number of rows in final output: 294</span></span>
<span id="cb13-33"><a href="#cb13-33"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb13-34"><a href="#cb13-34"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb13-35"><a href="#cb13-35"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb13-36"><a href="#cb13-36"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb13-37"><a href="#cb13-37"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/chunk_2_rolling_predictors_variables_cr_2021_07_12_01_37_46.csv</span></span>
<span id="cb13-38"><a href="#cb13-38"></a><span class="co">#> Processing chunk # 3 out of 5...</span></span>
<span id="cb13-39"><a href="#cb13-39"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb13-40"><a href="#cb13-40"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb13-41"><a href="#cb13-41"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb13-42"><a href="#cb13-42"></a><span class="co">#> Number of rows in final output: 309</span></span>
<span id="cb13-43"><a href="#cb13-43"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb13-44"><a href="#cb13-44"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb13-45"><a href="#cb13-45"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb13-46"><a href="#cb13-46"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb13-47"><a href="#cb13-47"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/chunk_3_rolling_predictors_variables_cr_2021_07_12_01_37_53.csv</span></span>
<span id="cb13-48"><a href="#cb13-48"></a><span class="co">#> Processing chunk # 4 out of 5...</span></span>
<span id="cb13-49"><a href="#cb13-49"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb13-50"><a href="#cb13-50"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb13-51"><a href="#cb13-51"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb13-52"><a href="#cb13-52"></a><span class="co">#> Number of rows in final output: 345</span></span>
<span id="cb13-53"><a href="#cb13-53"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb13-54"><a href="#cb13-54"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb13-55"><a href="#cb13-55"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb13-56"><a href="#cb13-56"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb13-57"><a href="#cb13-57"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/chunk_4_rolling_predictors_variables_cr_2021_07_12_01_38_00.csv</span></span>
<span id="cb13-58"><a href="#cb13-58"></a><span class="co">#> Processing chunk # 5 out of 5...</span></span>
<span id="cb13-59"><a href="#cb13-59"></a><span class="co">#> Joining, by = "id"</span></span>
<span id="cb13-60"><a href="#cb13-60"></a><span class="co">#> Processing variables: cr...</span></span>
<span id="cb13-61"><a href="#cb13-61"></a><span class="co">#> Allocating memory...</span></span>
<span id="cb13-62"><a href="#cb13-62"></a><span class="co">#> Number of rows in final output: 322</span></span>
<span id="cb13-63"><a href="#cb13-63"></a><span class="co">#> Parallel processing is ENABLED.</span></span>
<span id="cb13-64"><a href="#cb13-64"></a><span class="co">#> Determining missing values for each statistic...</span></span>
<span id="cb13-65"><a href="#cb13-65"></a><span class="co">#> Beginning calculation...</span></span>
<span id="cb13-66"><a href="#cb13-66"></a><span class="co">#> Completed calculation.</span></span>
<span id="cb13-67"><a href="#cb13-67"></a><span class="co">#> The output file was written to: C:\Users\KARAN_~1\AppData\Local\Temp\Rtmp6PiqU2/gpmodels_dir/chunk_5_rolling_predictors_variables_cr_2021_07_12_01_38_07.csv</span></span></code></pre></div>
<h3 id="running-in-serial">Running in serial</h3>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1"></a>future<span class="op">::</span><span class="kw">plan</span>(<span class="st">'sequential'</span>)</span>
<span id="cb14-2"><a href="#cb14-2"></a></span>
<span id="cb14-3"><a href="#cb14-3"></a>benchmark_results[[<span class="st">'sequential'</span>]] =<span class="st"> </span></span>
<span id="cb14-4"><a href="#cb14-4"></a><span class="st"> </span>microbenchmark<span class="op">::</span><span class="kw">microbenchmark</span>(</span>
<span id="cb14-5"><a href="#cb14-5"></a> tf <span class="op">%>%</span><span class="st"> </span></span>
<span id="cb14-6"><a href="#cb14-6"></a><span class="st"> </span><span class="kw">add_rolling_predictors</span>(<span class="dt">variable =</span> <span class="st">'cr'</span>,</span>
<span id="cb14-7"><a href="#cb14-7"></a> <span class="dt">lookback =</span> <span class="kw">hours</span>(<span class="dv">48</span>), </span>
<span id="cb14-8"><a href="#cb14-8"></a> <span class="dt">window =</span> <span class="kw">hours</span>(<span class="dv">6</span>), </span>
<span id="cb14-9"><a href="#cb14-9"></a> <span class="dt">stats =</span> <span class="kw">c</span>(<span class="dt">mean =</span> mean,</span>
<span id="cb14-10"><a href="#cb14-10"></a> <span class="dt">min =</span> min,</span>
<span id="cb14-11"><a href="#cb14-11"></a> <span class="dt">max =</span> max,</span>
<span id="cb14-12"><a href="#cb14-12"></a> <span class="dt">median =</span> median,</span>
<span id="cb14-13"><a href="#cb14-13"></a> <span class="dt">length =</span> length)),</span>
<span id="cb14-14"><a href="#cb14-14"></a> <span class="dt">times =</span> <span class="dv">1</span></span>
<span id="cb14-15"><a href="#cb14-15"></a> )</span></code></pre></div>
<h2 id="benchmark-results">Benchmark results</h2>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1"></a>benchmark_results</span>
<span id="cb15-2"><a href="#cb15-2"></a><span class="co">#> $multisession</span></span>
<span id="cb15-3"><a href="#cb15-3"></a><span class="co">#> Unit: seconds</span></span>
<span id="cb15-4"><a href="#cb15-4"></a><span class="co">#> expr</span></span>
<span id="cb15-5"><a href="#cb15-5"></a><span class="co">#> tf %>% add_rolling_predictors(variable = "cr", lookback = hours(48), window = hours(6), stats = c(mean = mean, min = min, max = max, median = median, length = length))</span></span>
<span id="cb15-6"><a href="#cb15-6"></a><span class="co">#> min lq mean median uq max neval</span></span>
<span id="cb15-7"><a href="#cb15-7"></a><span class="co">#> 32.66706 32.66706 32.66706 32.66706 32.66706 32.66706 1</span></span>
<span id="cb15-8"><a href="#cb15-8"></a><span class="co">#> </span></span>
<span id="cb15-9"><a href="#cb15-9"></a><span class="co">#> $`multisession with chunk_size 20`</span></span>
<span id="cb15-10"><a href="#cb15-10"></a><span class="co">#> Unit: seconds</span></span>
<span id="cb15-11"><a href="#cb15-11"></a><span class="co">#> expr</span></span>
<span id="cb15-12"><a href="#cb15-12"></a><span class="co">#> tf_with_chunks %>% add_rolling_predictors(variable = "cr", lookback = hours(48), window = hours(6), stats = c(mean = mean, min = min, max = max, median = median, length = length))</span></span>
<span id="cb15-13"><a href="#cb15-13"></a><span class="co">#> min lq mean median uq max neval</span></span>
<span id="cb15-14"><a href="#cb15-14"></a><span class="co">#> 33.79288 33.79288 33.79288 33.79288 33.79288 33.79288 1</span></span>
<span id="cb15-15"><a href="#cb15-15"></a><span class="co">#> </span></span>
<span id="cb15-16"><a href="#cb15-16"></a><span class="co">#> $sequential</span></span>
<span id="cb15-17"><a href="#cb15-17"></a><span class="co">#> Unit: seconds</span></span>
<span id="cb15-18"><a href="#cb15-18"></a><span class="co">#> expr</span></span>
<span id="cb15-19"><a href="#cb15-19"></a><span class="co">#> tf %>% add_rolling_predictors(variable = "cr", lookback = hours(48), window = hours(6), stats = c(mean = mean, min = min, max = max, median = median, length = length))</span></span>
<span id="cb15-20"><a href="#cb15-20"></a><span class="co">#> min lq mean median uq max neval</span></span>
<span id="cb15-21"><a href="#cb15-21"></a><span class="co">#> 127.0335 127.0335 127.0335 127.0335 127.0335 127.0335 1</span></span></code></pre></div>
</body>
</html>