-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpresentation.html
More file actions
926 lines (866 loc) · 62.5 KB
/
Copy pathpresentation.html
File metadata and controls
926 lines (866 loc) · 62.5 KB
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
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Financial Fragility Clock · Presentation</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%237132f5'/%3E%3Ccircle cx='16' cy='16' r='11' stroke='white' stroke-width='2' fill='none'/%3E%3Cline x1='16' y1='6' x2='16' y2='16' stroke='white' stroke-width='2.5' stroke-linecap='round'/%3E%3Cline x1='16' y1='16' x2='22' y2='12' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Serif:ital,wght@0,300;0,400;0,600;1,300;1,400&display=swap" rel="stylesheet">
<style>
/* LIGHT MODE (default) */
:root{--bg:#f9f8f6;--s:#ffffff;--b:rgba(0,0,0,.07);--bm:rgba(0,0,0,.13);--t:#1a1714;--t2:#5a5450;--t3:#a09894;--pu:#7132f5;--hedge:#149e61;--spec:#d97706;--ponzi:#dc2626;--cf:#ffffff;--cn:rgba(0,0,0,.22);--ct:rgba(0,0,0,.1);--nb:rgba(249,248,246,.92);--track:rgba(0,0,0,.06);--fn:'IBM Plex Sans',system-ui,sans-serif;--fs:'IBM Plex Serif',Georgia,serif;--fm:'IBM Plex Mono',monospace}
/* DARK MODE */
[data-theme=dark]{--bg:#0c0c10;--s:#131318;--b:rgba(255,255,255,.07);--bm:rgba(255,255,255,.14);--t:#e8eaf0;--t2:#8b92a8;--t3:#3d4357;--cf:#0e0e14;--cn:rgba(255,255,255,.2);--ct:rgba(255,255,255,.09);--nb:rgba(19,19,24,.9);--track:rgba(255,255,255,.08)}
*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}
html,body{width:100%;height:100%;overflow:hidden;font-family:var(--fn);background:var(--bg);color:var(--t);-webkit-font-smoothing:antialiased;transition:background .3s,color .3s}
/* STAGE */
.stage{width:100vw;height:100vh;position:relative;overflow:hidden}
.slide{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:72px 80px;opacity:0;pointer-events:none;transition:opacity .5s cubic-bezier(.25,.46,.45,.94),transform .5s cubic-bezier(.25,.46,.45,.94);transform:translateX(60px)}
.slide.active{opacity:1;pointer-events:all;transform:translateX(0)}
.slide.prev{transform:translateX(-60px)}
/* NAV */
.nav-bar{position:fixed;bottom:32px;left:50%;transform:translateX(-50%);z-index:100;display:flex;align-items:center;gap:12px;background:var(--nb);backdrop-filter:blur(14px);border:1px solid var(--bm);border-radius:9999px;padding:10px 20px}
.nav-btn{width:34px;height:34px;border-radius:50%;border:1px solid var(--bm);background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--t2);transition:all .15s;font-size:14px}
.nav-btn:hover{color:var(--t);border-color:var(--pu);background:rgba(113,50,245,.12)}
.slide-counter{font-family:var(--fm);font-size:11px;color:var(--t3);letter-spacing:.08em;min-width:42px;text-align:center}
.nav-dots{display:flex;gap:6px}
.nav-dot{width:6px;height:6px;border-radius:50%;background:var(--bm);cursor:pointer;transition:all .2s}
.nav-dot.active{background:var(--pu);transform:scale(1.3)}
.nav-home{font-family:var(--fm);font-size:11px;color:var(--t3);text-decoration:none;padding:4px 10px;border-radius:9999px;border:1px solid var(--bm);transition:all .15s}
.nav-home:hover{color:var(--pu);border-color:var(--pu)}
/* COMMON SLIDE ELEMENTS */
.eyebrow{font-family:var(--fm);font-size:10px;letter-spacing:.2em;text-transform:uppercase;color:var(--pu);margin-bottom:12px}
.slide-h{font-family:var(--fs);font-size:clamp(30px,3.8vw,52px);font-weight:400;letter-spacing:-.03em;line-height:1.08;margin-bottom:16px}
.slide-h em{font-style:italic;color:var(--t2)}
.slide-sub{font-size:16px;color:var(--t2);line-height:1.65;max-width:560px}
/* SLIDE LAYOUTS */
.s-split{display:grid;grid-template-columns:1fr 1fr;gap:72px;align-items:center;width:100%;max-width:1200px}
.s-center{text-align:center;max-width:800px}
.s-wide{width:100%;max-width:1200px}
.s-3col{display:grid;grid-template-columns:repeat(3,1fr);gap:32px;width:100%;max-width:1200px}
/* CLOCK */
.clock-wrap{display:flex;flex-direction:column;align-items:center;position:relative}
.clock-glow{position:absolute;inset:-40px;border-radius:50%;pointer-events:none;transition:background .8s}
/* COMPARISON BARS */
.cmp-row{display:grid;grid-template-columns:160px 1fr 1fr;gap:20px;align-items:center;margin-bottom:16px}
.cmp-name{font-size:14px;font-weight:500;text-align:right;color:var(--t2)}
.cmp-date{font-family:var(--fm);font-size:11px;color:var(--t3);display:block;margin-top:2px}
.cmp-bar-wrap{position:relative}
.cmp-track{height:32px;background:var(--track);border-radius:6px;overflow:visible;position:relative;border:1px solid var(--b)}
.cmp-fill{height:100%;border-radius:6px;display:flex;align-items:center;justify-content:flex-end;padding-right:10px;transition:width .8s}
.cmp-val{font-family:var(--fm);font-size:13px;font-weight:500;color:#fff;white-space:nowrap}
.cmp-thresh{position:absolute;top:-3px;bottom:-3px;width:2px;border-radius:1px;background:var(--ponzi);opacity:.5}
.cmp-tag{font-family:var(--fm);font-size:11px;padding:2px 8px;border-radius:9999px;margin-left:8px}
.cmp-tag.miss{background:rgba(220,38,38,.15);color:var(--ponzi)}
.cmp-tag.catch{background:rgba(20,158,97,.15);color:var(--hedge)}
.cmp-tag.part{background:rgba(217,119,6,.15);color:var(--spec)}
/* SHAP BARS */
.shap-row{display:flex;align-items:center;gap:12px;margin-bottom:12px}
.shap-lbl{font-family:var(--fm);font-size:12px;color:var(--t2);width:120px;text-align:right;flex-shrink:0}
.shap-track{flex:1;height:8px;background:var(--track);border-radius:4px;overflow:hidden}
.shap-fill{height:100%;border-radius:4px;background:var(--pu);transition:width .7s}
.shap-num{font-family:var(--fm);font-size:11px;color:var(--t3);width:52px;text-align:right}
/* METRIC CARDS */
.metric-card{background:var(--s);border:1px solid var(--b);border-radius:16px;padding:28px;text-align:center}
.metric-val{font-family:var(--fm);font-size:36px;font-weight:500;line-height:1;margin-bottom:6px}
.metric-lbl{font-family:var(--fm);font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3)}
.metric-note{font-size:13px;color:var(--t2);margin-top:8px;line-height:1.5}
/* CALLOUT BOX */
.callout{background:rgba(113,50,245,.08);border:1px solid rgba(113,50,245,.22);border-radius:14px;padding:20px 24px;margin-top:20px}
.callout-title{font-family:var(--fm);font-size:9px;letter-spacing:.14em;text-transform:uppercase;color:var(--pu);margin-bottom:8px}
.callout-text{font-size:14px;line-height:1.65;color:var(--t2)}
/* LOADING */
.loading-state{font-family:var(--fm);font-size:12px;color:var(--t3);letter-spacing:.1em;animation:pulse 1.5s infinite}
@keyframes pulse{0%,100%{opacity:.3}50%{opacity:1}}
</style>
</head>
<body>
<div class="stage" id="stage">
<!-- SLIDE 1: TITLE & CLOCK -->
<div class="slide active" id="slide-0" data-screen-label="01 The Problem">
<div class="s-split">
<div>
<p class="eyebrow">Group 5 · MSc FinTech · Birmingham</p>
<h1 class="slide-h">Financial<br>Fragility<br><em>Clock</em></h1>
<p class="slide-sub">Predicting the next stock market crash of the Istanbul Stock Exchange using Minsky's Financial Instability Hypothesis and machine learning.</p>
<div class="callout">
<div class="callout-title">Core Question</div>
<div class="callout-text">What changes when a global-only model is asked to read a domestic Turkish stress cycle? Model B is not perfect — but it stays materially more sensitive when the crisis mechanism turns local.</div>
</div>
</div>
<div class="clock-wrap">
<div class="clock-glow" id="p-glow"></div>
<svg width="340" height="360" viewBox="0 0 380 400" id="p-clock">
<defs><radialGradient id="pGrad" cx="50%" cy="50%" r="50%"><stop offset="0%" id="p-grad-stop" stop-color="#dc2626" stop-opacity="0.15"/><stop offset="100%" stop-color="#dc2626" stop-opacity="0"/></radialGradient></defs>
<g id="p-arcs"></g>
<circle cx="190" cy="195" r="172" fill="none" stroke="var(--b)" stroke-width="1"/>
<circle cx="190" cy="195" r="155" fill="url(#pGrad)"/>
<g id="p-ticks"></g>
<text x="190" y="14" text-anchor="middle" font-size="9" font-family="IBM Plex Mono,monospace" fill="rgba(220,38,38,0.55)" letter-spacing="0.22em">CRASH</text>
<text x="190" y="382" text-anchor="middle" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--ct)" letter-spacing="0.22em">SAFE</text>
<circle cx="190" cy="195" r="135" fill="var(--cf)"/>
<circle cx="190" cy="195" r="135" fill="none" stroke="var(--ct)" stroke-width="1"/>
<text x="190" y="52" text-anchor="middle" dominant-baseline="middle" font-size="12" font-family="IBM Plex Mono,monospace" fill="var(--cn)">12</text>
<text x="333" y="197" text-anchor="middle" dominant-baseline="middle" font-size="12" font-family="IBM Plex Mono,monospace" fill="var(--cn)">3</text>
<text x="190" y="342" text-anchor="middle" dominant-baseline="middle" font-size="12" font-family="IBM Plex Mono,monospace" fill="var(--cn)">6</text>
<text x="47" y="197" text-anchor="middle" dominant-baseline="middle" font-size="12" font-family="IBM Plex Mono,monospace" fill="var(--cn)">9</text>
<text id="p-face-date" x="190" y="165" text-anchor="middle" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--cn)" letter-spacing="0.09em">APR 2026</text>
<text id="p-face-score" x="190" y="232" text-anchor="middle" font-size="13" font-family="IBM Plex Mono,monospace" font-weight="500" fill="#dc2626" letter-spacing="0.04em">— / 100</text>
<line id="p-second" x1="190" y1="211" x2="190" y2="100" stroke="rgba(220,38,38,0.35)" stroke-width="1" stroke-linecap="round"/>
<line id="p-minute" x1="190" y1="211" x2="190" y2="95" stroke="#dc2626" stroke-width="2.5" stroke-linecap="round"/>
<line id="p-hour" x1="190" y1="209" x2="190" y2="128" stroke="#dc2626" stroke-width="4.5" stroke-linecap="round"/>
<circle cx="190" cy="195" r="6.5" fill="var(--cf)" stroke="var(--ct)" stroke-width="1.5"/>
<circle cx="190" cy="195" r="3.5" fill="#dc2626" id="p-pivot"/>
</svg>
<div style="margin-top:12px;text-align:center">
<div id="p-time" style="font-family:var(--fs);font-size:26px;font-weight:300;color:var(--t)">Loading…</div>
<div id="p-regime" style="font-family:var(--fm);font-size:11px;letter-spacing:.15em;text-transform:uppercase;margin-top:6px;color:var(--spec)">— REGIME</div>
<div id="p-trajectory" style="font-family:var(--fm);font-size:12px;color:var(--t3);margin-top:10px;letter-spacing:.03em">—</div>
<div style="font-family:var(--fm);font-size:9px;color:var(--t3);margin-top:3px;opacity:.6;letter-spacing:.05em">3-MONTH TREND · NOT A FORECAST</div>
</div>
</div>
</div>
</div>
<!-- SLIDE 2: METHODOLOGY -->
<div class="slide" id="slide-1" data-screen-label="02 Methodology">
<div class="s-wide">
<p class="eyebrow">Pipeline Overview</p>
<h2 class="slide-h" style="margin-bottom:20px">How we built it.<br><em>What we tested.</em></h2>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px;margin-bottom:20px">
<div style="background:var(--s);border:1px solid var(--b);border-radius:14px;padding:22px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.16em;text-transform:uppercase;color:var(--t3);margin-bottom:10px">Step 1 · Data</div>
<div style="font-size:16px;font-family:var(--fs);font-weight:400;margin-bottom:10px">Two sources</div>
<div style="font-size:13px;color:var(--t2);line-height:1.65">
<strong style="color:var(--spec)">Model A:</strong> <code>group5_clean_data.csv</code><br>536 daily returns · Jan 2009–Aug 2011<br>ISE + 7 global market indices<br><br>
<strong style="color:var(--pu)">Model B:</strong> yfinance 2003–2026<br>260+ monthly obs · 30+ features<br>TRY velocity, VIX lags, DXY, CBRT dummy
</div>
</div>
<div style="background:var(--s);border:1px solid var(--b);border-radius:14px;padding:22px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.16em;text-transform:uppercase;color:var(--t3);margin-bottom:10px">Step 2 · Six Models</div>
<div style="font-size:16px;font-family:var(--fs);font-weight:400;margin-bottom:10px">Trained & compared</div>
<div style="font-size:13px;color:var(--t2);line-height:1.7">
OLS · Ridge · LASSO<br>Elastic Net · Random Forest · ANN/MLP<br><br>
<span style="font-family:var(--fm);font-size:11px;color:var(--t3)">Ridge → degenerate to OLS (α→0, no regularisation benefit).<br>ANN → excluded: CV RMSE 6× test RMSE on 536 rows (Zhang, 2003).</span>
</div>
</div>
<div style="background:var(--s);border:1px solid rgba(113,50,245,.25);border-radius:14px;padding:22px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.16em;text-transform:uppercase;color:var(--pu);margin-bottom:10px">Step 3 · Validation</div>
<div style="font-size:16px;font-family:var(--fs);font-weight:400;margin-bottom:10px">Walk-forward</div>
<div style="font-size:13px;color:var(--t2);line-height:1.65">
4 out-of-sample crisis windows:<br>GFC 2008 · TRY 2018 · COVID 2020 · Turkey 2021–24<br><br>
Train on pre-crisis data → test on crisis period → compare R² across models and windows
</div>
</div>
</div>
<div style="background:var(--s);border:1px solid var(--b);border-radius:14px;padding:18px 24px;display:grid;grid-template-columns:180px 1fr;gap:24px;align-items:center">
<div>
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3);margin-bottom:6px">Step 4 · Output</div>
<div style="font-family:var(--fs);font-size:20px;font-weight:400;line-height:1.25">Fragility Score<br><span style="font-family:var(--fm);font-size:28px;color:var(--spec)">0 – 100</span></div>
</div>
<div style="font-size:13px;color:var(--t2);line-height:1.7">
A composite signal — prediction errors, rolling volatility, feature correlations — normalised to 0–100 and mapped to Minsky's three regimes:
<span style="font-family:var(--fm);color:var(--hedge)"> 0–39 Hedge</span> ·
<span style="font-family:var(--fm);color:var(--spec)"> 40–69 Speculative</span> ·
<span style="font-family:var(--fm);color:var(--ponzi)"> 70–100 Ponzi</span>.<br>
<span style="font-family:var(--fm);font-size:11px;color:var(--t3)">In-sample R² of 4–14% is the EMH baseline — daily returns are near-random by construction. Walk-forward R² on crisis windows (38–74%) is the operative performance measure.</span>
</div>
</div>
</div>
</div>
<!-- SLIDE 3: THE DATA -->
<div class="slide" id="slide-2" data-screen-label="03 The Data">
<div class="s-wide">
<p class="eyebrow">The Dataset</p>
<h2 class="slide-h" style="margin-bottom:20px">Two models. Two stories.<br><em>One city.</em></h2>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:32px;margin-bottom:24px">
<div style="background:var(--s);border:1px solid var(--b);border-radius:14px;padding:24px">
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3);margin-bottom:14px">Model A · 2009–2011 Original</div>
<div style="font-family:var(--fm);font-size:44px;font-weight:500;color:var(--spec);line-height:1" id="p-a-card-value">—</div>
<div style="font-family:var(--fm);font-size:11px;color:var(--t3);margin-top:4px;margin-bottom:14px" id="p-a-card-note">Selected late-crisis score</div>
<div style="font-size:14px;color:var(--t2);line-height:1.65">Global baseline. Strong for shared contagion episodes, but consistently lower once Turkey-specific stress begins to dominate.</div>
<div style="margin-top:12px;font-family:var(--fm);font-size:11px;padding:5px 10px;background:var(--b);border-radius:5px;color:var(--t2);display:inline-block">Best read as benchmark, not final answer</div>
</div>
<div style="background:var(--s);border:1px solid rgba(113,50,245,.28);border-radius:14px;padding:24px">
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--pu);margin-bottom:14px">Model B · 2003–2026 Extended ↑</div>
<div style="font-family:var(--fm);font-size:44px;font-weight:500;color:var(--pu);line-height:1" id="p-b-card-value">—</div>
<div style="font-family:var(--fm);font-size:11px;color:var(--t3);margin-top:4px;margin-bottom:14px" id="p-b-card-note">Selected late-crisis score</div>
<div style="font-size:14px;color:var(--t2);line-height:1.65">Extended context. VIX and USDTRY-related features keep the system more elevated through Turkey-specific stress episodes.</div>
<div style="margin-top:12px;font-family:var(--fm);font-size:11px;padding:5px 10px;background:rgba(113,50,245,.1);border-radius:5px;color:var(--pu);display:inline-block">Cleanest separation appears in late 2021</div>
</div>
</div>
<div style="background:var(--s);border:1px solid var(--b);border-radius:14px;overflow:hidden">
<svg id="p-timeline" width="100%" height="150" viewBox="0 0 1120 150" preserveAspectRatio="none" style="display:block;" class="loading-state"></svg>
</div>
<p style="font-family:var(--fm);font-size:11px;color:var(--t3);margin-top:8px">Fragility scores 2003–2026 · Both models · Regime-coloured areas · Dashes = 40/70 thresholds</p>
</div>
</div>
<!-- SLIDE 4: THE CRISIS TEST -->
<div class="slide" id="slide-3" data-screen-label="04 Crisis Test">
<div class="s-wide">
<p class="eyebrow">The Decisive Test</p>
<h2 class="slide-h" style="margin-bottom:6px">Model A underreads Turkey.<br><em>Model B stays higher.</em></h2>
<p style="font-size:14px;color:var(--t2);margin-bottom:24px;max-width:720px">Four crisis episodes. Real fragility scores. The gap between the two models across different crisis mechanisms is the evidence.</p>
<div class="cmp-row" style="margin-bottom:8px;padding-bottom:10px;border-bottom:1px solid var(--b)">
<div></div>
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--t3)">Model A · 2009–2011</div>
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--pu)">Model B · 2003–2026</div>
</div>
<div id="p-crises"></div>
<div class="callout">
<div class="callout-title">What The Evidence Actually Supports</div>
<div class="callout-text">2020 is the strongest threshold-crossing case: Model B reaches 71.1 while Model A stays below 70. <strong style="color:var(--t)">November 2021</strong> is the cleanest divergence case: Model B is 19.4 points higher than Model A during Turkey-specific stress. 2018 shows an early warning difference rather than a total binary miss.</div>
</div>
</div>
</div>
<!-- SLIDE 5: SHAP + FEATURES -->
<div class="slide" id="slide-4" data-screen-label="05 What Drives It">
<div class="s-wide">
<p class="eyebrow">Explainability</p>
<h2 class="slide-h" style="margin-bottom:20px">What drives<br><em>each model?</em></h2>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:40px">
<div>
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3);margin-bottom:14px">Model A · SHAP Feature Importance</div>
<div id="p-shap-a"></div>
<div style="margin-top:14px;padding:14px 16px;background:var(--b);border-radius:10px;font-size:13px;color:var(--t2);line-height:1.6">Model A is dominated by broad market structure. Its strongest global driver is EM, useful for contagion but not enough for Turkey-specific stress.</div>
</div>
<div>
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--pu);margin-bottom:14px">Model B · SHAP Feature Importance</div>
<div id="p-shap-b"></div>
<div style="margin-top:14px;padding:14px 16px;background:rgba(113,50,245,.07);border:1px solid rgba(113,50,245,.18);border-radius:10px;font-size:13px;color:var(--t2);line-height:1.6">Model B still uses global context, but adds VIX and USDTRY-related volatility into the top ranks — making the extension more credible than a "more of the same" model.</div>
</div>
</div>
</div>
</div>
<!-- SLIDE 6: SCORE DISTRIBUTION & REGIME DWELL -->
<div class="slide" id="slide-5" data-screen-label="06 Score Distribution">
<div class="s-wide">
<p class="eyebrow">Score Distribution</p>
<h2 class="slide-h" style="margin-bottom:20px">Where each model<br><em>spends its time</em></h2>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:40px">
<div>
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3);margin-bottom:10px">Score Histogram · Both Models · 2003–2026</div>
<div style="background:var(--s);border:1px solid var(--b);border-radius:14px;overflow:hidden">
<svg id="p-dist" width="100%" height="190" viewBox="0 0 540 190" preserveAspectRatio="none" style="display:block;"></svg>
</div>
<p style="font-family:var(--fm);font-size:11px;color:var(--t3);margin-top:8px">Grey = Model A · Purple = Model B · Dashes at 40 & 70</p>
</div>
<div>
<div style="font-family:var(--fm);font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3);margin-bottom:10px">Months in Each Regime · Full Coverage Period</div>
<div id="p-dwell"></div>
<div class="callout">
<div class="callout-title">What This Tells Us</div>
<div class="callout-text">Model B spends more months in the Speculative and Ponzi bands because it captures Turkey-specific stress. The distribution shift is evidence that the extended features add persistent fragility signal — not noise.</div>
</div>
</div>
</div>
</div>
</div>
<!-- SLIDE 7: MODEL GAP TIMELINE -->
<div class="slide" id="slide-6" data-screen-label="07 Divergence Gap">
<div class="s-wide">
<p class="eyebrow">Divergence Analysis</p>
<h2 class="slide-h" style="margin-bottom:16px">Model B − Model A<br><em>over two decades</em></h2>
<div style="background:var(--s);border:1px solid var(--b);border-radius:14px;overflow:hidden;margin-bottom:12px">
<svg id="p-gap" width="100%" height="180" viewBox="0 0 1120 180" preserveAspectRatio="none" style="display:block;"></svg>
</div>
<div style="display:flex;gap:16px;font-family:var(--fm);font-size:10px;color:var(--t3);margin-bottom:20px">
<span style="display:flex;align-items:center;gap:6px"><span style="display:inline-block;width:12px;height:2px;background:#7132f5;border-radius:1px;vertical-align:middle"></span>B above A (purple area)</span>
<span style="display:flex;align-items:center;gap:6px"><span style="display:inline-block;width:12px;height:2px;background:#dc2626;border-radius:1px;vertical-align:middle"></span>B below A</span>
<span>Dashed verticals = crisis events</span>
</div>
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:16px">
<div style="background:var(--s);border:1px solid var(--b);border-radius:12px;padding:18px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.12em;text-transform:uppercase;color:var(--t3);margin-bottom:6px">Aug 2018 · TRY Crisis</div>
<div style="font-family:var(--fm);font-size:26px;font-weight:500;color:var(--spec)" id="p-gap-2018">—</div>
<div style="font-size:12px;color:var(--t2);margin-top:4px">B − A points gap</div>
</div>
<div style="background:var(--s);border:1px solid rgba(113,50,245,.25);border-radius:12px;padding:18px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.12em;text-transform:uppercase;color:var(--pu);margin-bottom:6px">Nov 2021 · Turkey Stress</div>
<div style="font-family:var(--fm);font-size:26px;font-weight:500;color:var(--pu)" id="p-gap-2021">—</div>
<div style="font-size:12px;color:var(--t2);margin-top:4px">Peak divergence month</div>
</div>
<div style="background:var(--s);border:1px solid rgba(220,38,38,.2);border-radius:12px;padding:18px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.12em;text-transform:uppercase;color:var(--ponzi);margin-bottom:6px">Mar 2020 · COVID Shock</div>
<div style="font-family:var(--fm);font-size:26px;font-weight:500;color:var(--ponzi)" id="p-gap-2020">—</div>
<div style="font-size:12px;color:var(--t2);margin-top:4px">Threshold crossing gap</div>
</div>
</div>
</div>
</div>
<!-- SLIDE 8: ALGORITHM VALIDATION -->
<div class="slide" id="slide-7" data-screen-label="08 Algorithm Validation">
<div class="s-wide">
<p class="eyebrow">Technical Validation</p>
<h2 class="slide-h" style="margin-bottom:18px">Does the story hold<br><em>across all algorithms?</em></h2>
<div style="display:grid;grid-template-columns:5fr 8fr;gap:28px;align-items:start">
<div>
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3);margin-bottom:8px">In-Sample R² · All Algorithms · Both Training Windows</div>
<div style="background:var(--s);border:1px solid var(--b);border-radius:12px;overflow:hidden">
<table id="p-algo-tbl" style="width:100%;border-collapse:collapse">
<thead>
<tr style="border-bottom:1px solid var(--b)">
<th style="font-family:var(--fm);font-size:9px;letter-spacing:.08em;text-transform:uppercase;color:var(--t3);padding:9px 12px;text-align:left;font-weight:400">Model</th>
<th style="font-family:var(--fm);font-size:9px;letter-spacing:.08em;text-transform:uppercase;color:var(--t3);padding:9px 12px;text-align:left;font-weight:400">A R²</th>
<th style="font-family:var(--fm);font-size:9px;letter-spacing:.08em;text-transform:uppercase;color:var(--pu);padding:9px 12px;text-align:left;font-weight:400">B R²</th>
</tr>
</thead>
<tbody id="p-algo-body"></tbody>
</table>
</div>
<div style="margin-top:10px;font-size:12px;color:var(--t2);line-height:1.55">Model B improves on Model A across every algorithm. RF gains most — Model A's 32-month training window is too short for RF to generalise; Model B's 20-year window changes that.</div>
<div style="margin-top:8px;padding:10px 12px;background:var(--b);border-radius:8px;font-family:var(--fm);font-size:11px;color:var(--t3);line-height:1.5">4–14% is expected under EMH. These are test-set R² on 2018–2026 data — genuinely out-of-sample relative to both training windows.</div>
</div>
<div>
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.14em;text-transform:uppercase;color:var(--t3);margin-bottom:8px">Walk-Forward R² · All Algorithms · Both Models · By Crisis Window</div>
<div id="p-wf-body"></div>
<div style="margin-top:12px;display:grid;grid-template-columns:1fr 1fr;gap:10px">
<div style="padding:12px 14px;background:var(--s);border:1px solid var(--b);border-radius:10px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.1em;text-transform:uppercase;color:var(--hedge);margin-bottom:5px">Global shocks → models work</div>
<div style="font-size:12px;color:var(--t2);line-height:1.5">GFC and COVID show strong positive R² across both models. Co-movement is exactly what the training data captures.</div>
</div>
<div style="padding:12px 14px;background:var(--s);border:1px solid rgba(220,38,38,.2);border-radius:10px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.1em;text-transform:uppercase;color:var(--ponzi);margin-bottom:5px">Domestic stress → structural break</div>
<div style="font-size:12px;color:var(--t2);line-height:1.5">2021–24 breaks every algorithm in both models. Negative R² marks the breakdown of global co-movement as a predictor — that <em>is</em> the finding.</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- SLIDE 9: CONCLUSIONS -->
<div class="slide" id="slide-8" data-screen-label="09 Conclusions">
<div class="s-wide">
<p class="eyebrow">Conclusions & Implications</p>
<h2 class="slide-h" style="margin-bottom:28px">What we found.<br><em>What it means.</em></h2>
<div class="s-3col" style="margin-bottom:28px">
<div class="metric-card">
<div class="metric-val" style="color:var(--pu)" id="p-metric-1">—</div>
<div class="metric-lbl">Late-2021 Gap</div>
<div class="metric-note" id="p-metric-1-note">Selected divergence month</div>
</div>
<div class="metric-card">
<div class="metric-val" style="color:var(--spec)" id="p-metric-2">—</div>
<div class="metric-lbl">2020 Threshold Test</div>
<div class="metric-note" id="p-metric-2-note">Selected crisis threshold result</div>
</div>
<div class="metric-card">
<div class="metric-val" style="color:var(--hedge)" id="p-metric-3">—</div>
<div class="metric-lbl">Top Mean-SHAP Driver</div>
<div class="metric-note" id="p-metric-3-note">Global context variable shared by both models</div>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:20px">
<div class="callout">
<div class="callout-title">Academic Finding</div>
<div class="callout-text">A global-only training window teaches useful contagion structure, but it underreacts when the stress mechanism becomes country-specific. The contribution of Model B is not perfection — it is a more coherent and sustained fragility signal when Turkey decouples from the wider market narrative.</div>
</div>
<div style="background:rgba(20,158,97,.07);border:1px solid rgba(20,158,97,.2);border-radius:14px;padding:20px 24px">
<div style="font-family:var(--fm);font-size:9px;letter-spacing:.14em;text-transform:uppercase;color:var(--hedge);margin-bottom:8px">Practical Implication</div>
<div style="font-size:14px;line-height:1.65;color:var(--t2)">Adding extended market context and Turkey-relevant stress features does not make forecasting easy, but it makes the system more useful for interpretation: the fragility signal remains elevated where the global-only baseline would tell a calmer story.</div>
</div>
</div>
</div>
</div>
</div>
<!-- NAV -->
<div class="nav-bar">
<button class="nav-btn" id="prev-btn" onclick="goSlide(currentSlide-1)">←</button>
<div class="nav-dots" id="nav-dots"></div>
<span class="slide-counter" id="slide-counter">1 / 9</span>
<button class="nav-btn" id="next-btn" onclick="goSlide(currentSlide+1)">→</button>
<a href="dashboard.html#clock" class="nav-home" id="dash-link">↗ Dashboard</a>
<a href="reports.html" class="nav-home">⬇ Report</a>
<button class="nav-btn" id="theme-btn" onclick="toggleTheme()" title="Toggle dark/light mode" style="font-size:12px">◑</button>
</div>
<script>
const TOTAL = 9;
let currentSlide = 0;
let DATA = null;
const DASH_LINKS = [
'dashboard.html#clock', // 1 Title
'dashboard.html#models', // 2 Methodology
'dashboard.html#clock', // 3 The Data — scrubber demo
'dashboard.html#detection', // 4 Crisis Test
'dashboard.html#models', // 5 SHAP
'dashboard.html#models', // 6 Score Distribution
'dashboard.html#timeline', // 7 Divergence Gap
'dashboard.html#models', // 8 Algorithm Validation
'dashboard.html#clock', // 9 Conclusions
];
let secAngle = 0;
let darkMode = false;
// ── NAVIGATION ───────────────────────────────────────────────────────────────
function goSlide(n) {
if (n < 0 || n >= TOTAL) return;
const prev = document.getElementById(`slide-${currentSlide}`);
prev.classList.remove('active');
prev.classList.add('prev');
setTimeout(() => prev.classList.remove('prev'), 500);
currentSlide = n;
document.getElementById(`slide-${currentSlide}`).classList.add('active');
document.getElementById('slide-counter').textContent = `${n+1} / ${TOTAL}`;
document.querySelectorAll('.nav-dot').forEach((d,i) => d.classList.toggle('active', i===n));
document.getElementById('dash-link').href = DASH_LINKS[n] || 'dashboard.html';
window.postMessage({slideIndexChanged: n}, '*');
}
document.addEventListener('keydown', e => {
if (e.key === 'ArrowRight' || e.key === ' ') goSlide(currentSlide + 1);
if (e.key === 'ArrowLeft') goSlide(currentSlide - 1);
});
// Build dots
const dotsEl = document.getElementById('nav-dots');
for (let i = 0; i < TOTAL; i++) {
const d = document.createElement('div');
d.className = 'nav-dot' + (i===0?' active':'');
d.onclick = () => goSlide(i);
dotsEl.appendChild(d);
}
// ── THEME ────────────────────────────────────────────────────────────────────
function toggleTheme() {
darkMode = !darkMode;
document.documentElement.setAttribute('data-theme', darkMode ? 'dark' : 'light');
}
// ── HELPERS ──────────────────────────────────────────────────────────────────
const regCol = s => s>=70?'#dc2626':s>=40?'#d97706':'#149e61';
const regLabel = s => s>=70?'PONZI FINANCE':s>=40?'SPECULATIVE FINANCE':'HEDGE FINANCE';
const regClass = s => s>=70?'ponzi':s>=40?'spec':'hedge';
const regimeFromScore = s => s>=70?'PONZI':s>=40?'SPECULATIVE':'HEDGE';
function polar(cx,cy,r,deg){const rad=(deg-90)*Math.PI/180;return{x:cx+r*Math.cos(rad),y:cy+r*Math.sin(rad)}}
function scoreToTime(s){if(s>=70){const m=Math.round((s-70)/30*120);return{h:Math.floor(m/60),m:m%60,past:true}}const m2=Math.round((1-s/100)*120),tot=24*60-m2;return{h:Math.floor(tot/60)%12||12,m:tot%60,past:false}}
function timeToAngle(h,m,isH){return isH?((h%12)+m/60)*30:m*6}
function timeDisplay(s){if(s>=70){const m=Math.round((s-70)/30*120);return m===0?'PAST MIDNIGHT':`${m} MIN PAST MIDNIGHT`}const mins=Math.round((1-s/100)*120);if(mins>=60){const hh=Math.floor(mins/60),mm=mins%60;return`${hh}H ${mm}M TO MIDNIGHT`}return`${Math.max(1,mins)} MIN TO MIDNIGHT`}
function monthKey(d){return (d||'').slice(0,7)}
function monthNum(d){const [y,m]=monthKey(d).split('-').map(Number);if(!y||!m)return null;return y*12+(m-1)}
function fmtDateLong(d){const key=monthKey(d);if(!key)return'—';const [y,m]=key.split('-').map(Number);const dt=new Date(Date.UTC(y,(m||1)-1,1));return dt.toLocaleDateString('en-US',{year:'numeric',month:'short',timeZone:'UTC'});}
function prettyFeature(key){return({VIX_lag1m:'VIX lag 1m',VIX_lag3m:'VIX lag 3m',USDTRY_lag1m:'USDTRY lag 1m',USDTRY_lag3m:'USDTRY lag 3m',usdtry_vol:'USDTRY volatility',rolling_vol:'Rolling volatility',mean_corr:'Mean correlation',eigenvalue_ratio:'Eigenvalue ratio',pe:'Perm. entropy',rf_prediction_error:'RF pred. error',pe_inv:'Inverse entropy'}[key]||key)}
// ── CLOCK ────────────────────────────────────────────────────────────────────
function drawClockTicks() {
const g = document.getElementById('p-ticks');
for(let i=0;i<60;i++){
const deg=i*6,major=i%5===0,CX=190,CY=195,R=172;
const p1=polar(CX,CY,R-(major?13:5),deg),p2=polar(CX,CY,R,deg);
const ln=document.createElementNS('http://www.w3.org/2000/svg','line');
ln.setAttribute('x1',p1.x);ln.setAttribute('y1',p1.y);
ln.setAttribute('x2',p2.x);ln.setAttribute('y2',p2.y);
ln.setAttribute('stroke',major?'var(--cn)':'var(--ct)');
ln.setAttribute('stroke-width',major?'1.5':'0.8');
g.appendChild(ln);
}
// Regime arcs
const ga=document.getElementById('p-arcs');
[{s:220,e:340,c:'#149e61'},{s:340,e:358,c:'#d97706'},{s:0,e:60,c:'#dc2626'}].forEach(a=>{
const p=document.createElementNS('http://www.w3.org/2000/svg','path');
const st=polar(190,195,182,a.s),en=polar(190,195,182,a.e);
p.setAttribute('d',`M${st.x},${st.y} A182,182 0 0,1 ${en.x},${en.y}`);
p.setAttribute('fill','none');p.setAttribute('stroke',a.c);
p.setAttribute('stroke-width','3');p.setAttribute('opacity','0.45');p.setAttribute('stroke-linecap','round');
ga.appendChild(p);
});
}
function updatePClock(s){
const CX=190,CY=195,col=regCol(s);
const{h,m}=scoreToTime(s);
const hA=timeToAngle(h,m,true),mA=timeToAngle(h,m,false);
function hp(angle,rT,rB){return{tip:polar(CX,CY,rT,angle),base:polar(CX,CY,rB,angle+180)}}
const{tip:mT,base:mB}=hp(mA,120,18),{tip:hT,base:hB}=hp(hA,84,16),{tip:sT,base:sB}=hp(secAngle,108,18);
function sl(id,p1,p2){const el=document.getElementById(id);if(!el)return;el.setAttribute('x1',p1.x);el.setAttribute('y1',p1.y);el.setAttribute('x2',p2.x);el.setAttribute('y2',p2.y);}
sl('p-minute',mB,mT);sl('p-hour',hB,hT);sl('p-second',sB,sT);
['p-minute','p-hour'].forEach(id=>{const el=document.getElementById(id);if(el)el.setAttribute('stroke',col);});
document.getElementById('p-pivot')?.setAttribute('fill',col);
document.getElementById('p-face-score').textContent=`${s.toFixed(1)} / 100`;
document.getElementById('p-face-score').setAttribute('fill',col);
document.getElementById('p-grad-stop')?.setAttribute('stop-color',col);
document.getElementById('p-glow').style.background=`radial-gradient(circle,${col}20 0%,transparent 70%)`;
document.getElementById('p-time').textContent=timeDisplay(s);
document.getElementById('p-time').style.color=col;
document.getElementById('p-regime').textContent=regLabel(s);
document.getElementById('p-regime').style.color=col;
}
setInterval(()=>{secAngle=(secAngle+6)%360;if(DATA){const latest=DATA.models.model_2003.monthly_scores;updatePClock(latest[latest.length-1].fragility_score);}},1000);
// ── LOAD + RENDER ─────────────────────────────────────────────────────────────
async function loadData() {
try {
const res = await fetch('./data/fragility_output.json');
if (!res.ok) throw new Error();
DATA = await res.json();
} catch(e) {
DATA = getMock();
}
renderAll();
}
function getMock(){
const scores=[];
for(let i=0;i<277;i++){const yr=2003+Math.floor(i/12),mo=(i%12)+1;const d=`${yr}-${String(mo).padStart(2,'0')}-28`;const s=Math.min(85,Math.max(10,30+20*Math.sin(i/12)+10*Math.sin(i/4)));scores.push({date:d,fragility_score:s,regime:s>=70?'PONZI':s>=40?'SPECULATIVE':'HEDGE',components:{},correlations:{},features:{}});}
const sa=scores.map(s=>({...s,fragility_score:Math.min(59,s.fragility_score*.72+5)}));
const wfA=[
{split:1,description:'GFC 2008',ols:{r2:.39,rmse:.09},elastic_net:{r2:.41,rmse:.09},lasso:{r2:.40,rmse:.09},rf:{r2:.52,rmse:.08}},
{split:2,description:'2018 TRY',ols:{r2:.18,rmse:.10},elastic_net:{r2:.19,rmse:.10},lasso:{r2:.18,rmse:.10},rf:{r2:.12,rmse:.10}},
{split:3,description:'COVID 2020',ols:{r2:.74,rmse:.07},elastic_net:{r2:.75,rmse:.07},lasso:{r2:.74,rmse:.07},rf:{r2:.48,rmse:.08}},
{split:4,description:'2021–24 Turkey',ols:{r2:-.15,rmse:.12},elastic_net:{r2:-.14,rmse:.12},lasso:{r2:-.15,rmse:.12},rf:{r2:-.27,rmse:.13}},
];
const wfB=[
{split:1,description:'2018 TRY',ols:{r2:.21,rmse:.10},elastic_net:{r2:.22,rmse:.10},lasso:{r2:.21,rmse:.10},rf:{r2:.24,rmse:.10}},
{split:2,description:'COVID 2020',ols:{r2:.69,rmse:.08},elastic_net:{r2:.70,rmse:.07},lasso:{r2:.69,rmse:.07},rf:{r2:.42,rmse:.09}},
{split:3,description:'2021–24 Turkey',ols:{r2:-.31,rmse:.13},elastic_net:{r2:-.29,rmse:.13},lasso:{r2:-.31,rmse:.13},rf:{r2:-.09,rmse:.12}},
];
return{models:{
model_2009:{meta:{label:'Model A'},monthly_scores:sa,shap_values:{EM:0.027,SP500:0.019,FTSE:0.015,NIKKEI:0.011,EU:0.010,BOVESPA:0.009,DAX:0.001},walk_forward:wfA,performance:{ols:{r2:.041,rmse:.098,mae:.080},elastic_net:{r2:.079,rmse:.096,mae:.076},lasso:{r2:.065,rmse:.097,mae:.077},random_forest:{r2:.138,rmse:.093,mae:.074}}},
model_2003:{meta:{label:'Model B'},monthly_scores:scores,shap_values:{EM:0.018,BOVESPA:0.008,FTSE:0.004,VIX_lag1m:0.004,SP500:0.004,usdtry_vol:0.003,EU:0.003,DAX:0.003,rolling_vol:0.002,USDTRY_lag1m:0.001},walk_forward:wfB,performance:{ols:{r2:.094,rmse:.096,mae:.076},elastic_net:{r2:.090,rmse:.096,mae:.075},lasso:{r2:.095,rmse:.096,mae:.075},random_forest:{r2:.138,rmse:.093,mae:.074}}}
}};
}
function getScoreByDate(model, datePrefix) {
const s = DATA?.models[model]?.monthly_scores;
if (!s) return null;
const row = s.find(r => monthKey(r.date) === monthKey(datePrefix));
return row ? row.fragility_score : null;
}
function updateTrajectory() {
const scores = DATA.models.model_2003.monthly_scores;
const current = scores[scores.length - 1].fragility_score;
const el = document.getElementById('p-trajectory');
if (!el) return;
if (current >= 70) {
el.textContent = 'Currently in Ponzi regime — threshold already crossed';
el.style.color = 'var(--ponzi)';
return;
}
// Average monthly change over last 3 months
const window3 = scores.slice(-4).map(s => s.fragility_score);
const changes = window3.slice(1).map((v, i) => v - window3[i]);
const slope = changes.reduce((a, b) => a + b, 0) / changes.length;
if (slope <= 0) {
el.textContent = `Score ${slope < -0.2 ? 'declining' : 'stable'} — no threshold crossing projected`;
el.style.color = 'var(--hedge)';
return;
}
const months = Math.ceil((70 - current) / slope);
if (months > 120) {
el.textContent = 'No near-term threshold crossing at current rate';
el.style.color = 'var(--t3)';
return;
}
const urgency = months <= 6 ? 'var(--ponzi)' : months <= 18 ? 'var(--spec)' : 'var(--t3)';
el.textContent = `At current trend: Ponzi threshold in ~${months} month${months === 1 ? '' : 's'}`;
el.style.color = urgency;
}
function renderAll(){
const latestB = DATA.models.model_2003.monthly_scores.slice(-1)[0];
drawClockTicks();
updatePClock(latestB.fragility_score);
updateTrajectory();
document.getElementById('p-face-date').textContent = fmtDateLong(latestB.date).toUpperCase();
renderTimeline();
renderCrises();
renderShap('p-shap-a', DATA.models.model_2009.shap_values, 6);
renderShap('p-shap-b', DATA.models.model_2003.shap_values, 8);
renderDistribution();
renderDwell();
renderGapTimeline();
renderAlgoTable();
renderWFHeatmap();
const scoreA202111 = getScoreByDate('model_2009', '2021-11');
const scoreB202111 = getScoreByDate('model_2003', '2021-11');
const scoreA202003 = getScoreByDate('model_2009', '2020-03');
const scoreB202003 = getScoreByDate('model_2003', '2020-03');
const topB = Object.entries(DATA.models.model_2003.shap_values || {}).sort((a,b)=>b[1]-a[1])[0];
if(scoreA202111!=null && scoreB202111!=null){
document.getElementById('p-a-card-value').textContent=scoreA202111.toFixed(1);
document.getElementById('p-a-card-note').textContent='Model A score · Nov 2021';
document.getElementById('p-b-card-value').textContent=scoreB202111.toFixed(1);
document.getElementById('p-b-card-note').textContent=`Model B score · Nov 2021 · Δ +${(scoreB202111-scoreA202111).toFixed(1)}`;
document.getElementById('p-metric-1').textContent=`+${(scoreB202111-scoreA202111).toFixed(1)}`;
document.getElementById('p-metric-1-note').textContent=`Nov 2021: Model B ${scoreB202111.toFixed(1)} vs Model A ${scoreA202111.toFixed(1)}`;
}
if(scoreA202003!=null && scoreB202003!=null){
document.getElementById('p-metric-2').textContent=`${scoreB202003.toFixed(1)}`;
document.getElementById('p-metric-2-note').textContent=`Mar 2020: Model B crosses 70 while Model A remains at ${scoreA202003.toFixed(1)}`;
}
if(topB){
document.getElementById('p-metric-3').textContent=prettyFeature(topB[0]);
document.getElementById('p-metric-3-note').textContent='Top global context variable in the extended model';
}
}
// ── SLIDE 2: TIMELINE ────────────────────────────────────────────────────────
function renderTimeline(){
const svg = document.getElementById('p-timeline');
const scoresA = DATA.models.model_2009.monthly_scores;
const scoresB = DATA.models.model_2003.monthly_scores;
const W=1120,H=150,P={t:14,b:22,l:8,r:8};
const cW=W-P.l-P.r,cH=H-P.t-P.b;
const firstMonth=monthNum(scoresB[0].date);
const lastMonth=monthNum(scoresB[scoresB.length-1].date);
const span=Math.max(1,(lastMonth??0)-(firstMonth??0));
const xForDate=d=>P.l+(((monthNum(d)??firstMonth)-firstMonth)/span)*cW;
let html=`<defs><clipPath id="ptc"><rect x="${P.l}" y="${P.t}" width="${cW}" height="${cH}"/></clipPath></defs>`;
[40,70].forEach(v=>{
const y=P.t+cH-(v/100)*cH;
const col=v===70?'rgba(220,38,38,.4)':'rgba(217,119,6,.3)';
html+=`<line x1="${P.l}" y1="${y}" x2="${W-P.r}" y2="${y}" stroke="${col}" stroke-width="1" stroke-dasharray="4,3"/>`;
});
// Model B coloured area
let seg=[],lastR=regimeFromScore(scoresB[0].fragility_score),segs=[];
scoresB.forEach(s=>{
const band=regimeFromScore(s.fragility_score);
if(band!==lastR&&seg.length){segs.push({p:seg,r:lastR});seg=[];}
seg.push({x:xForDate(s.date),y:P.t+cH-(s.fragility_score/100)*cH});
lastR=band;
});
if(seg.length)segs.push({p:seg,r:lastR});
const cols={HEDGE:'#149e61',SPECULATIVE:'#d97706',PONZI:'#dc2626'};
segs.forEach(({p:sp,r})=>{
let d=`M${sp[0].x},${P.t+cH} L${sp[0].x},${sp[0].y}`;
sp.forEach((pt,i)=>{if(i)d+=` L${pt.x},${pt.y}`;});
d+=` L${sp[sp.length-1].x},${P.t+cH} Z`;
html+=`<path d="${d}" fill="${cols[r]}" fill-opacity=".28" clip-path="url(#ptc)"/>`;
});
// Model A line (dashed)
let lpA=`M${xForDate(scoresA[0].date)},${P.t+cH-(scoresA[0].fragility_score/100)*cH}`;
scoresA.forEach((s,i)=>{if(i)lpA+=` L${xForDate(s.date)},${P.t+cH-(s.fragility_score/100)*cH}`;});
html+=`<path d="${lpA}" fill="none" stroke="var(--t3)" stroke-width="1" stroke-dasharray="4,3" clip-path="url(#ptc)"/>`;
// Model B line (solid)
let lpB=`M${xForDate(scoresB[0].date)},${P.t+cH-(scoresB[0].fragility_score/100)*cH}`;
scoresB.forEach((s,i)=>{if(i)lpB+=` L${xForDate(s.date)},${P.t+cH-(s.fragility_score/100)*cH}`;});
html+=`<path d="${lpB}" fill="none" stroke="var(--t2)" stroke-width="1.5" clip-path="url(#ptc)"/>`;
[{date:'2018-08',label:'2018',col:'rgba(217,119,6,.6)'},{date:'2020-03',label:'2020',col:'rgba(220,38,38,.6)'},{date:'2021-11',label:'2021',col:'rgba(113,50,245,.65)'}].forEach(ev=>{
const x=xForDate(ev.date);
html+=`<line x1="${x}" y1="${P.t}" x2="${x}" y2="${P.t+cH}" stroke="${ev.col}" stroke-width="1" stroke-dasharray="3,3"/>`;
html+=`<text x="${x+4}" y="${P.t+11}" font-size="8" font-family="IBM Plex Mono,monospace" fill="${ev.col}">${ev.label}</text>`;
});
for(let yr=2004;yr<=2026;yr+=3){
const x=xForDate(`${yr}-01`);
html+=`<text x="${x}" y="${H-5}" text-anchor="middle" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--t3)">${yr}</text>`;
}
html+=`<text x="${P.l+8}" y="${P.t+12}" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--t3)">— Model A (dashed)</text>`;
html+=`<text x="${P.l+142}" y="${P.t+12}" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--t2)">— Model B (solid)</text>`;
svg.innerHTML=html;
svg.classList.remove('loading-state');
}
// ── SLIDE 3: CRISIS BARS ──────────────────────────────────────────────────────
function renderCrises(){
const crises=[
{name:'2010 Greek Crisis',date:'2010-05',lbl:'May 2010'},
{name:'2018 TRY Crash',date:'2018-08',lbl:'Aug 2018'},
{name:'2020 COVID Shock',date:'2020-03',lbl:'Mar 2020'},
{name:'Late-2021 Turkey Stress',date:'2021-11',lbl:'Nov 2021'},
];
const container=document.getElementById('p-crises');
container.innerHTML=crises.map(c=>{
const sa=getScoreByDate('model_2009',c.date)||0;
const sb=getScoreByDate('model_2003',c.date)||0;
const delta=sb-sa;
const colA=regCol(sa),colB=regCol(sb);
const tagA=sa>=70?'<span class="cmp-tag catch">threshold</span>':sa>=40?'<span class="cmp-tag part">elevated</span>':'<span class="cmp-tag miss">low</span>';
const tagB=sb>=70?'<span class="cmp-tag catch">threshold</span>':sb>=40?'<span class="cmp-tag part">elevated</span>':'<span class="cmp-tag miss">low</span>';
return `<div class="cmp-row">
<div class="cmp-name">${c.name}<span class="cmp-date">${c.lbl} · Δ B−A ${(delta>=0?'+':'')+delta.toFixed(1)}</span></div>
<div style="display:flex;align-items:center;gap:8px"><div class="cmp-track" style="flex:1"><div class="cmp-fill" style="width:${Math.min(sa,100)}%;background:${colA}"><span class="cmp-val">${sa.toFixed(1)}</span></div><div class="cmp-thresh" style="left:70%"></div></div>${tagA}</div>
<div style="display:flex;align-items:center;gap:8px"><div class="cmp-track" style="flex:1"><div class="cmp-fill" style="width:${Math.min(sb,100)}%;background:${colB}"><span class="cmp-val">${sb.toFixed(1)}</span></div><div class="cmp-thresh" style="left:70%"></div></div>${tagB}</div>
</div>`;
}).join('');
}
// ── SLIDE 4: SHAP ─────────────────────────────────────────────────────────────
function renderShap(containerId, shap, topN){
const entries=Object.entries(shap||{}).sort((a,b)=>b[1]-a[1]).slice(0,topN);
if(!entries.length){document.getElementById(containerId).innerHTML='<p style="font-size:12px;color:var(--t3)">No SHAP data</p>';return;}
const max=entries[0][1];
document.getElementById(containerId).innerHTML=entries.map(([k,v])=>`
<div class="shap-row">
<div class="shap-lbl" title="${k}">${prettyFeature(k)}</div>
<div class="shap-track"><div class="shap-fill" style="width:${max>0?(v/max*100).toFixed(0):0}%"></div></div>
<div class="shap-num">${v>1?v.toFixed(1):v.toFixed(4)}</div>
</div>`).join('');
}
// ── SLIDE 5: DISTRIBUTION ─────────────────────────────────────────────────────
function renderDistribution(){
const svg=document.getElementById('p-dist');if(!svg)return;
const W=540,H=190,P={t:18,b:26,l:10,r:10};
const cW=W-P.l-P.r,cH=H-P.t-P.b;
const scoresA=(DATA?.models?.model_2009?.monthly_scores||[]).map(s=>s.fragility_score);
const scoresB=(DATA?.models?.model_2003?.monthly_scores||[]).map(s=>s.fragility_score);
if(!scoresA.length&&!scoresB.length){svg.innerHTML='';return;}
const bins=20,bw=100/bins;
function makeHist(arr){const h=new Array(bins).fill(0);arr.forEach(v=>{const b=Math.min(bins-1,Math.floor(v/bw));if(b>=0)h[b]++;});return h;}
const hA=makeHist(scoresA),hB=makeHist(scoresB);
const maxCount=Math.max(...hA,...hB,1);
let html='';
[0,40,70,100].forEach(v=>{
const x=P.l+(v/100)*cW;
const isDash=v===40||v===70;
html+=`<line x1="${x}" y1="${P.t}" x2="${x}" y2="${P.t+cH}" stroke="${isDash?(v===70?'var(--ponzi)':'var(--spec)'):'var(--b)'}" stroke-width="${isDash?1:.7}" stroke-dasharray="${isDash?'3,3':''}"/>`;
html+=`<text x="${x}" y="${H-6}" text-anchor="middle" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--t3)">${v}</text>`;
});
const bwPx=cW/bins;
hA.forEach((count,i)=>{
const x=P.l+i*bwPx,h2=(count/maxCount)*cH;
html+=`<rect x="${x+1}" y="${P.t+cH-h2}" width="${bwPx-2}" height="${h2}" fill="#94a3b8" opacity=".75" rx="1"/>`;
});
hB.forEach((count,i)=>{
const x=P.l+i*bwPx,h2=(count/maxCount)*cH;
html+=`<rect x="${x+1}" y="${P.t+cH-h2}" width="${bwPx-2}" height="${h2*.9}" fill="#7132f5" opacity=".82" rx="1"/>`;
});
html+=`<text x="${P.l+8}" y="${P.t+13}" font-size="9" font-family="IBM Plex Mono,monospace" fill="#94a3b8">■ Model A</text>`;
html+=`<text x="${P.l+72}" y="${P.t+13}" font-size="9" font-family="IBM Plex Mono,monospace" fill="#7132f5">■ Model B</text>`;
svg.innerHTML=html;
}
// ── SLIDE 5: DWELL ────────────────────────────────────────────────────────────
function renderDwell(){
const body=document.getElementById('p-dwell');if(!body)return;
const models=[
{id:'model_2009',label:'Model A · Baseline 2009–2011'},
{id:'model_2003',label:'Model B · Extended 2003–2026'},
];
let html='';
models.forEach(m=>{
const sc=(DATA?.models[m.id]?.monthly_scores||[]).map(s=>regimeFromScore(s.fragility_score));
const total=sc.length||1;
const hPct=Math.round(sc.filter(r=>r==='HEDGE').length/total*100);
const sPct=Math.round(sc.filter(r=>r==='SPECULATIVE').length/total*100);
const pPct=100-hPct-sPct;
html+=`<div style="margin-bottom:22px">
<div style="font-family:var(--fm);font-size:10px;color:var(--t2);margin-bottom:8px;letter-spacing:.04em">${m.label} · ${total} months</div>
<div style="height:30px;border-radius:6px;overflow:hidden;display:flex;margin-bottom:6px">
<div style="width:${hPct}%;background:var(--hedge);display:flex;align-items:center;justify-content:center;font-family:var(--fm);font-size:10px;font-weight:500;color:#fff;white-space:nowrap;overflow:hidden">${hPct>10?hPct+'%':''}</div>
<div style="width:${sPct}%;background:var(--spec);display:flex;align-items:center;justify-content:center;font-family:var(--fm);font-size:10px;font-weight:500;color:#fff;white-space:nowrap;overflow:hidden">${sPct>10?sPct+'%':''}</div>
<div style="width:${pPct}%;background:var(--ponzi);display:flex;align-items:center;justify-content:center;font-family:var(--fm);font-size:10px;font-weight:500;color:#fff;white-space:nowrap;overflow:hidden">${pPct>10?pPct+'%':''}</div>
</div>
<div style="display:flex;gap:14px;font-family:var(--fm);font-size:10px">
<span style="color:var(--hedge)">Hedge: ${hPct}%</span>
<span style="color:var(--spec)">Spec: ${sPct}%</span>
<span style="color:var(--ponzi)">Ponzi: ${pPct}%</span>
</div>
</div>`;
});
body.innerHTML=html;
}
// ── SLIDE 6: GAP TIMELINE ────────────────────────────────────────────────────
function renderGapTimeline(){
const svg=document.getElementById('p-gap');if(!svg)return;
const W=1120,H=180,P={t:18,b:26,l:44,r:16};
const cW=W-P.l-P.r,cH=H-P.t-P.b;
const scoresA=DATA?.models?.model_2009?.monthly_scores||[];
const scoresB=DATA?.models?.model_2003?.monthly_scores||[];
const pairs=[];
scoresB.forEach(b=>{
const a=scoresA.find(a=>monthKey(a.date)===monthKey(b.date));
if(a)pairs.push({date:b.date,gap:b.fragility_score-a.fragility_score});
});
if(!pairs.length){svg.innerHTML='';return;}
const gaps=pairs.map(p=>p.gap);
const range=Math.max(Math.abs(Math.min(...gaps)),Math.abs(Math.max(...gaps)),1);
const toY=v=>P.t+cH/2-(v/(range*2))*cH;
const zeroY=toY(0);
let html='';
html+=`<line x1="${P.l}" y1="${zeroY}" x2="${W-P.r}" y2="${zeroY}" stroke="var(--bm)" stroke-width="1"/>`;
html+=`<text x="40" y="${zeroY+4}" text-anchor="end" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--t3)">0</text>`;
[{mo:'2018-08',lbl:'2018'},{mo:'2020-03',lbl:'2020'},{mo:'2021-11',lbl:'2021'}].forEach(ev=>{
const idx=pairs.findIndex(p=>monthKey(p.date)===ev.mo);if(idx<0)return;
const x=P.l+(idx/(pairs.length-1))*cW;
html+=`<line x1="${x}" y1="${P.t}" x2="${x}" y2="${P.t+cH}" stroke="var(--t3)" stroke-width="1" stroke-dasharray="3,3" opacity=".5"/>`;
html+=`<text x="${x+4}" y="${P.t+12}" font-size="8" font-family="IBM Plex Mono,monospace" fill="var(--t3)">${ev.lbl}</text>`;
});
const pts=pairs.map((p,i)=>({x:P.l+(i/(pairs.length-1))*cW,y:toY(p.gap),g:p.gap}));
let posPath='',negPath='';
pts.forEach((p,i)=>{
if(i===0){posPath=`M${p.x},${zeroY}`;negPath=`M${p.x},${zeroY}`;}
posPath+=` L${p.x},${p.g>=0?p.y:zeroY}`;
negPath+=` L${p.x},${p.g<0?p.y:zeroY}`;
});
posPath+=` L${pts[pts.length-1].x},${zeroY} Z`;
negPath+=` L${pts[pts.length-1].x},${zeroY} Z`;
html+=`<path d="${posPath}" fill="#7132f5" fill-opacity=".22"/>`;
html+=`<path d="${negPath}" fill="#dc2626" fill-opacity=".22"/>`;
let line=`M${pts[0].x},${pts[0].y}`;
pts.forEach((p,i)=>{if(i)line+=` L${p.x},${p.y}`;});
html+=`<path d="${line}" fill="none" stroke="#7132f5" stroke-width="1.5"/>`;
[Math.round(range),0,-Math.round(range)].forEach(v=>{
html+=`<text x="40" y="${toY(v)+4}" text-anchor="end" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--t3)">${v>0?'+':''}${v}</text>`;
});
const firstYear=parseInt(pairs[0].date,10);
const lastYear=parseInt(pairs[pairs.length-1].date,10);
for(let yr=firstYear;yr<=lastYear;yr+=4){
const idx=pairs.findIndex(p=>p.date.startsWith(`${yr}-`));if(idx<0)continue;
const x=P.l+(idx/(pairs.length-1))*cW;
html+=`<text x="${x}" y="${H-8}" text-anchor="middle" font-size="9" font-family="IBM Plex Mono,monospace" fill="var(--t3)">${yr}</text>`;
}
svg.innerHTML=html;
// Populate gap stat cards
[['2018-08','p-gap-2018'],['2021-11','p-gap-2021'],['2020-03','p-gap-2020']].forEach(([mo,elId])=>{
const sa=getScoreByDate('model_2009',mo);
const sb=getScoreByDate('model_2003',mo);
const el=document.getElementById(elId);
if(el&&sa!=null&&sb!=null){const g=sb-sa;el.textContent=(g>=0?'+':'')+g.toFixed(1);}
});
}
// ── SLIDE 7: ALGO TABLE ───────────────────────────────────────────────────────
function renderAlgoTable(){
const algos=[
{key:'ols',label:'OLS'},
{key:'elastic_net',label:'Elastic Net'},
{key:'lasso',label:'Lasso'},
{key:'random_forest',label:'Random Forest'},
];
const perfA=DATA?.models?.model_2009?.performance||{};
const perfB=DATA?.models?.model_2003?.performance||{};
const fmtR2=v=>v==null?'—':v.toFixed(3);
const colR2=v=>v==null?'color:var(--t3)':v>0.1?`color:var(--hedge)`:v>0?'color:var(--t2)':'color:var(--ponzi)';
let html='';
algos.forEach(a=>{
const r2A=perfA[a.key]?.r2;
const r2B=perfB[a.key]?.r2;
html+=`<tr style="border-bottom:1px solid var(--b)">
<td style="font-family:var(--fm);font-size:12px;padding:10px 14px;font-weight:500;color:var(--t)">${a.label}</td>
<td style="font-family:var(--fm);font-size:13px;padding:10px 14px;${colR2(r2A)}">${fmtR2(r2A)}</td>
<td style="font-family:var(--fm);font-size:13px;padding:10px 14px;${colR2(r2B)}">${fmtR2(r2B)}</td>
</tr>`;
});
const body=document.getElementById('p-algo-body');
if(body)body.innerHTML=html||'<tr><td colspan="3" style="padding:16px;color:var(--t3);font-size:12px">Performance data not available</td></tr>';
}
// ── SLIDE 7: WALK-FORWARD HEATMAP (both models) ───────────────────────────────
function renderWFHeatmap(){
const body=document.getElementById('p-wf-body');if(!body)return;
const wfA=DATA?.models?.model_2009?.walk_forward||[];
const wfB=DATA?.models?.model_2003?.walk_forward||[];
if(!wfA.length&&!wfB.length){body.innerHTML='<p style="font-size:12px;color:var(--t3);font-family:var(--fm)">Walk-forward data not available.</p>';return;}
const algos=['ols','elastic_net','lasso','rf'];
const algoLabels={ols:'OLS',elastic_net:'E.Net',lasso:'Lasso',rf:'RF'};
function r2Bg(v){
if(v==null)return'var(--b)';
if(v<0){const t=Math.min(1,-v/0.5);return`rgb(${Math.round(220-20*t)},${Math.round(80-30*t)},${Math.round(80-20*t)})`;}
const t=Math.min(1,v/0.75);return`rgb(${Math.round(220-180*t)},${Math.round(200-40*t)},${Math.round(80-40*t)})`;
}
function r2Fg(v){return v==null?'var(--t3)':Math.abs(v)>0.12?'#fff':'var(--t)';}
function buildSection(wf,label,col){
if(!wf.length)return'';
let h=`<div style="font-family:var(--fm);font-size:9px;letter-spacing:.12em;text-transform:uppercase;color:${col};margin-bottom:3px">${label}</div>`;
h+=`<div style="display:grid;grid-template-columns:auto repeat(${algos.length},1fr);gap:3px;margin-bottom:2px">`;
h+=`<div></div>`;
algos.forEach(a=>h+=`<div style="font-family:var(--fm);font-size:9px;color:var(--t3);text-align:center;padding:2px;letter-spacing:.04em">${algoLabels[a]}</div>`);
wf.forEach(sp=>{
const desc=(sp.description||sp.split||'').replace('Crisis','').replace('Turkey ','').trim();
h+=`<div style="font-family:var(--fm);font-size:9px;color:var(--t2);display:flex;align-items:center;padding-right:6px;white-space:nowrap">${desc}</div>`;
algos.forEach(a=>{
const r2=sp[a]?.r2;
const val=r2!=null?r2.toFixed(2):'—';
h+=`<div style="border-radius:3px;padding:6px 4px;display:flex;align-items:center;justify-content:center;font-family:var(--fm);font-size:11px;font-weight:500;background:${r2Bg(r2)};color:${r2Fg(r2)}">${val}</div>`;
});
});
h+=`</div>`;
return h;
}
let html=buildSection(wfA,'Model A · 2009–2011 baseline','var(--t3)');
html+=`<div style="border-top:1px solid var(--b);margin:6px 0"></div>`;
html+=buildSection(wfB,'Model B · 2003–2026 extended','var(--pu)');
html+=`<div style="display:flex;gap:12px;font-family:var(--fm);font-size:9px;color:var(--t3);margin-top:6px">
<span style="display:flex;align-items:center;gap:4px"><span style="width:10px;height:10px;border-radius:2px;background:rgb(200,60,60);display:inline-block"></span>R² < 0 · structural break</span>
<span style="display:flex;align-items:center;gap:4px"><span style="width:10px;height:10px;border-radius:2px;background:rgb(60,190,60);display:inline-block"></span>R² > 0.5 · strong fit</span>
</div>`;
body.innerHTML=html;
}
// ── INIT ──────────────────────────────────────────────────────────────────────
drawClockTicks();
loadData();
window.postMessage({slideIndexChanged: 0}, '*');
</script>
</body>
</html>