"""Context arithmetic for the page: numbers of ours that come from published figures rather than from a test. Fact-Checked Science ("Our analysis"), 20 November 2026, for the check of Marschollek, M., AGU26 abstract GH11D-VR9816 (not peer reviewed). Added after the fresh review, so that every number of ours on the page has a hosted source. Arithmetic only: no test, no rules file. A. The national scale of the abstract's 6.4%: Chan et al. (2020, JACEP Open 1(4), 445-452, Background) give prior estimates of 341,397-353,246 adult out-of-hospital cardiac arrests a year in the U.S.; over 14 days, 6.4% of that, as a share of the 25,397 U.S. heart-disease deaths of 15-28 March 2015 (NCHS, read from weekly_deaths_results.json, the national check's output), beside the same share at NEMSIS's own count (205,212 cases in 2015, from the abstract). B. The smallest drop the national check could flag under its own p-value rule, (1 + windows at or below) / (1 + n) <= 0.05, from the 282 placebo windows in placebo_deltas.csv (heart disease, not near a G4 storm). C. El Sibai et al. (2021, Medicine 100(18), e25643, Table 1): adult out-of-hospital cardiac arrests reaching U.S. emergency departments in 2014, by month, as a daily average. D. NOAA NCEI, Climate at a Glance, contiguous U.S. average temperature for February and for March, 1895-2026: the 2015 values and their departures from the 1991-2020 average. The two JSON files are fetched by URL (identifying as "factchecked-research/1.0") and checked against the SHA-256 of our copies of 20 November 2026; NCEI revises and extends its series, so a fresh copy may differ, and the script says so. E. Added after the narrow check: the age gap (65 or older against under 65) if the abstract's p-values were two-sided, which CausalImpact's are not (RULES_abstract_arithmetic.txt reads them as one-sided tail areas), with the two estimates' errors independent or correlated at 0.5, and the 65+ error at its bound or at the Poisson floor of a 14-day count; the same normal approximation as abstract_arithmetic.py. Run: python3 -I context_arithmetic.py add --cag-feb --cag-mar to read saved copies of the NCEI files instead of fetching them. Standard library only (Python 3.9+). Writes LF line endings. """ import argparse import csv import hashlib import json import math import os import urllib.request from statistics import NormalDist UA = "factchecked-research/1.0" CAG = { "feb": ("https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/national/time-series/110/tavg/1/2/1895-2026/data.json", "e272460d4e262099c3f149f259160d12fec7c05c31e83ccc6e55b87e6b357604"), "mar": ("https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/national/time-series/110/tavg/1/3/1895-2026/data.json", "a4a1801de9433d17f71218e4067a81dca6e796954d00106afdb05e618887c030"), } CHAN_RANGE = (341397, 353246) # Chan et al. 2020, Background NEMSIS_2015 = 205212 # the abstract, paragraph 3 PREVIOUS = 0.064 # the abstract, paragraph 1 EL_SIBAI_2014 = [("January", 12272, 31), ("February", 10054, 28), ("March", 10241, 31), ("April", 10179, 30)] AGE_65_PLUS = 102336 # the abstract, paragraph 3: cases aged 65 or older in 2015 OLD, YOUNG = (9.1, 0.001), (4.4, 0.077) # the abstract, paragraph 4: drop in % and p, 65+ (p<0.001) and under 65 def get(url): req = urllib.request.Request(url, headers={"User-Agent": UA}) with urllib.request.urlopen(req, timeout=60) as r: return r.read() def main(): ap = argparse.ArgumentParser() ap.add_argument("folder") ap.add_argument("out") ap.add_argument("--cag-feb") ap.add_argument("--cag-mar") a = ap.parse_args() out = [] res = json.load(open(os.path.join(a.folder, "weekly_deaths_results.json"), encoding="utf-8")) deaths = res["outcomes"]["O1_heart"]["storms"]["S1"]["W2s"]["observed"] # 15-28 March 2015 out.append("A. The abstract's 6.4%% at two scales (heart-disease deaths of 15-28 March 2015: %d)" % deaths) n14 = NEMSIS_2015 * 14 / 365 out.append(" NEMSIS's count: %d a year -> %.1f in 14 days; 6.4%% = %.1f people = %.2f%% of those deaths" % ( NEMSIS_2015, n14, PREVIOUS * n14, 100 * PREVIOUS * n14 / deaths)) for n in CHAN_RANGE: c = n * 14 / 365 out.append(" published national estimate %d a year -> %.1f in 14 days; 6.4%% = %.1f people = %.2f%% of those deaths" % ( n, c, PREVIOUS * c, 100 * PREVIOUS * c / deaths)) rows = [r for r in csv.DictReader(open(os.path.join(a.folder, "placebo_deltas.csv"), encoding="utf-8")) if r["outcome"] == "O1_heart" and r["near_G4_storm"] == "False"] d = sorted(float(r["delta_pct"]) for r in rows) n = len(d) k = max(j for j in range(1, n + 1) if (1 + j) / (1 + n) <= 0.05) # windows at or below that still give p <= 0.05 out.append("") out.append("B. The national check's flag line (placebo windows: %d)" % n) out.append(" a change is flagged if (1 + windows at or below it) / (1 + %d) <= 0.05, i.e. at most %d windows at or below" % (n, k)) out.append(" the %dth lowest window is %.2f%%: a change at or below it is flagged (p = %d/%d = %.3f); the next, %.2f%%, gives p = %.3f" % ( k, d[k - 1], 1 + k, 1 + n, (1 + k) / (1 + n), d[k], (2 + k) / (1 + n))) out.append("") out.append("C. El Sibai et al. 2021, Table 1: adult cases reaching U.S. emergency departments in 2014, a day") for m, c, days in EL_SIBAI_2014: out.append(" %s: %d / %d days = %.1f a day" % (m, c, days, c / days)) out.append("") out.append("D. NCEI Climate at a Glance, contiguous U.S. average temperature (degrees F)") for key, label, local in (("feb", "February", a.cag_feb), ("mar", "March", a.cag_mar)): url, sha = CAG[key] b = open(local, "rb").read() if local else get(url) h = hashlib.sha256(b).hexdigest() data = json.loads(b.decode("utf-8"))["data"] vals = {int(k_[:4]): v["value"] for k_, v in data.items()} base = sum(vals[y] for y in range(1991, 2021)) / 30 out.append(" %s: %s our copy; 2015 %.2f, 1991-2020 mean %.2f, departure %+.2f" % ( label, "same as" if h == sha else "DIFFERENT bytes from", vals[2015], base, vals[2015] - base)) nd = NormalDist() z2 = lambda p: nd.inv_cdf(1 - p / 2) # z for a two-sided p old14 = AGE_65_PLUS * 14 / 365 # the 65+ count expected in 14 days floor = 100 / math.sqrt(old14) # Poisson-only SE of its change, in points se_old = OLD[0] / z2(OLD[1]) # p<0.001 is a bound, so this SE is an upper bound se_young = YOUNG[0] / z2(YOUNG[1]) gap = OLD[0] - YOUNG[0] out.append("") out.append("E. The age gap if the abstract's p-values were two-sided (a sensitivity reading added after the narrow check;") out.append(" CausalImpact's p-values are one-sided, as RULES_abstract_arithmetic.txt reads them)") out.append(" 65+: effect -%.1f%%, p<%.3f read as two-sided: z >= %.3f, SE <= %.2f pp; Poisson floor for %.1f cases in 14 days: %.2f pp" % ( OLD[0], OLD[1], z2(OLD[1]), se_old, old14, floor)) out.append(" <65: effect -%.1f%%, p %.3f read as two-sided: z %.3f, SE %.2f pp" % (YOUNG[0], YOUNG[1], z2(YOUNG[1]), se_young)) for rho in (0.0, 0.5): for where, s_old in (("at the 65+ SE bound", se_old), ("at the 65+ Poisson floor", floor)): sd = math.sqrt(s_old ** 2 + se_young ** 2 - 2 * rho * s_old * se_young) z = gap / sd out.append(" gap %.1f pp, rho=%.1f, %s: SE_diff=%.2f, z=%.2f, two-sided p=%.3f" % ( gap, rho, where, sd, z, 2 * (1 - nd.cdf(z)))) with open(a.out, "w", encoding="utf-8", newline="\n") as f: f.write("\n".join(out) + "\n") if __name__ == "__main__": main()