SPB Git

Repository Public Research preview

r3k_07_tables.py 33.7 KB 213 lines python

1"""r3k_07_tables.py — LaTeX tables + number macros for the WP 0002 manuscript (paper/tables/)."""2import json, numpy as np, pandas as pd3D = "data/processed_r3k"; T = "results/r3k"; P = "paper/tables"4R = json.load(open(f"{T}/results.json")); R2 = json.load(open(f"{T}/results2.json")); RE = json.load(open(f"{T}/results_event.json")); META = json.load(open(f"{D}/panel_meta.json"))5df = pd.read_parquet(f"{D}/analysis_panel.parquet")6def n(x, d=0): return f"{float(x):,.{d}f}".replace(",", "{,}")7def w(name, body): open(f"{P}/{name}", "w").write(body); print("table", name)8def pp(x, d=1): return f"{x * 100:+.{d}f}"9def tv(t): return "--" if t is None or (isinstance(t, float) and np.isnan(t)) else f"{t:.2f}"10# summary11s = pd.read_csv(f"{T}/t1_summary_stats.csv", index_col=0); lab = {"ai_adoption_wmean": "AI adoption (wmean)", "ai_infrastructure_wmean": "AI infrastructure (wmean)", "ai_disruption_risk_wmean": "AI disruption risk (wmean)", "spid_mentions_tech": "SPID technology-project mentions", "spid_ai_any": "Any AI-initiative mention (0/1)", "fwd_ret": "Forward 12-m return", "fwd_ret_mktadj": "Forward return, SPY-adjusted", "mom_12m": "Momentum (12 m)", "vol_12m": "Volatility (12 m, ann.)", "log_mktcap": "log market cap", "total_chunks": "Chunks per firm-year"}12body = "\\begin{tabular}{lrrrrrrr}\n\\toprule\nVariable & N & Mean & SD & P5 & Median & P95 \\\\\n\\midrule\n"13for k, l in lab.items():14    r = s.loc[k]; body += f"{l} & {n(r['count'])} & {r['mean']:.4f} & {r['std']:.4f} & {r['5%']:.4f} & {r['50%']:.4f} & {r['95%']:.4f} \\\\\n"15w("tab_summary.tex", body + "\\bottomrule\n\\end{tabular}")16# sorts17S = R["sorts"]; body = "\\begin{tabular}{llrrrrrrrr}\n\\toprule\nSignal & Weighting & Q1 & Q2 & Q3 & Q4 & Q5 & Q5$-$Q1 & $t$ & Years \\\\\n\\midrule\n"18for k, l in [("AI_ADOPT", "AI adoption"), ("AI_INFRA", "AI infrastructure"), ("AI_RISK", "AI disruption risk"), ("AI_COMPOS", "AI composite"), ("SPID_TECH", "SPID tech projects")]:19    for sfx, wl in [("EW", "EW"), ("VW", "VW"), ("EW_madj", "EW, mkt-adj.")]:20        r = S[f"{k}_{sfx}"]; body += f"{l if sfx == 'EW' else ''} & {wl} & " + " & ".join(pp(r[f'Q{q}']) for q in range(1, 6)) + f" & {pp(r['Q5_minus_Q1'])} & {tv(r['t_stat'])} & {int(r['n_years'])} \\\\\n"21    body += "\\addlinespace\n"22w("tab_sorts.tex", body + "\\bottomrule\n\\end{tabular}")23# LS alphas24L = R["ls_alpha"]; body = "\\begin{tabular}{llrrrrrrr}\n\\toprule\nSignal & Period & Months & Mean (\\%/yr) & HAC $t$ & Sharpe & CAPM $\\alpha$ (\\%/yr) & FF6 $\\alpha$ (\\%/yr) & FF6 $t$ \\\\\n\\midrule\n"25for k, l in [("AI_COMPOS", "AI composite"), ("AI_ADOPT", "AI adoption"), ("AI_INFRA", "AI infrastructure"), ("AI_RISK", "AI disruption risk"), ("SPID_TECH", "SPID tech projects")]:26    for per in ["full", "pre", "post"]:27        r = L[k][per]; body += f"{l if per == 'full' else ''} & {per} & {r['n_months']} & {r['mean_ls_ann_pct']:+.2f} & {tv(r['hac_t'])} & {r['sharpe']:.2f} & {r['capm_alpha_ann_pct']:+.2f} & {r['ff6_alpha_ann_pct']:+.2f} & {tv(r['ff6_alpha_t'])} \\\\\n"28    body += "\\addlinespace\n"29w("tab_alpha.tex", body + "\\bottomrule\n\\end{tabular}")30# FE panel31PF = R["panel_fe"]; vars_ = ["z_AI_ADOPT", "z_AI_INFRA", "z_AI_RISK", "z_AI_COMPOS", "z_SPID_TECH", "z_size", "z_mom", "z_vol"]; vl = {"z_AI_ADOPT": "AI adoption ($z$)", "z_AI_INFRA": "AI infrastructure ($z$)", "z_AI_RISK": "AI disruption risk ($z$)", "z_AI_COMPOS": "AI composite ($z$)", "z_SPID_TECH": "SPID tech projects ($z$)", "z_size": "Size ($z$)", "z_mom": "Momentum ($z$)", "z_vol": "Volatility ($z$)"}32specs = list(PF); body = "\\begin{tabular}{l" + "r" * len(specs) + "}\n\\toprule\n & " + " & ".join(f"({i + 1})" for i in range(len(specs))) + " \\\\\n\\midrule\n"33for v in vars_:34    if not any(v in PF[s]["coefs"] for s in specs): continue35    body += vl[v] + " & " + " & ".join(f"{PF[s]['coefs'][v]['coef'] * 100:+.2f}" if v in PF[s]["coefs"] else "" for s in specs) + " \\\\\n"36    body += " & " + " & ".join(f"({PF[s]['coefs'][v]['t']:.2f})" if v in PF[s]["coefs"] else "" for s in specs) + " \\\\\n"37body += "\\midrule\nObservations & " + " & ".join(n(PF[s]["n"]) for s in specs) + " \\\\\nWithin $R^2$ & " + " & ".join(f"{PF[s]['r2_within']:.4f}" for s in specs) + " \\\\\n\\bottomrule\n\\end{tabular}"38w("tab_panel.tex", body)39# FM40FM = R["fama_macbeth"]; body = "\\begin{tabular}{lrrrrrr}\n\\toprule\n & (1) & (2) & (3) & (4) & (5) & (6) \\\\\n\\midrule\n"; cols = ["adopt", "infra", "all", "compos", "spid", "compos_spid"]41for v in ["z_AI_ADOPT", "z_AI_INFRA", "z_AI_RISK", "z_AI_COMPOS", "z_SPID_TECH", "z_size", "z_mom", "z_vol"]:42    body += vl[v] + " & " + " & ".join(f"{FM[c][v]['mean_coef'] * 100:+.2f}" if v in FM[c] else "" for c in cols) + " \\\\\n & " + " & ".join(f"({FM[c][v]['t']:.2f})" if v in FM[c] else "" for c in cols) + " \\\\\n"43body += "\\midrule\nYears & " + " & ".join(str(FM[c]["n_years"]) for c in cols) + " \\\\\n\\bottomrule\n\\end{tabular}"; w("tab_fm.tex", body)44# break + subperiod45B = R["structural_break"]; SP = R["subperiod_spread"]; body = "\\begin{tabular}{lrrrrrrrr}\n\\toprule\nSignal & Pre slope & Post extra & $t$ (year cl.) & $t$ (firm cl.) & Pre Q5$-$Q1 & ($t$) & Post Q5$-$Q1 & ($t$) \\\\\n\\midrule\n"46for k, l in [("AI_ADOPT", "AI adoption"), ("AI_INFRA", "AI infrastructure"), ("AI_COMPOS", "AI composite"), ("SPID_TECH", "SPID tech projects")]:47    b = B[k]; p_ = SP[k]; body += f"{l} & {b['pre_slope'] * 100:+.2f} & {b['interaction'] * 100:+.2f} & {tv(b['interaction_t_year'])} & {tv(b['interaction_t_firm'])} & {pp(p_['pre']['mean'])} & ({tv(p_['pre']['t'])}) & {pp(p_['post']['mean'])} & ({tv(p_['post']['t'])}) \\\\\n"48w("tab_break.tex", body + "\\bottomrule\n\\end{tabular}")49# groups50G = R["groups"]; body = "\\begin{tabular}{lrrrrrrrrr}\n\\toprule\nSample & Firm-years & Firms & Full Q5$-$Q1 & ($t$) & Pre & Post & ($t$) & FF6 $\\alpha$ post (\\%/yr) & ($t$) \\\\\n\\midrule\n"51for g, l in [("large_top1000", "Largest 1,000 by market cap"), ("small_rest", "Remaining firms"), ("sp500", "S\\&P 500 members"), ("non_sp500", "Non-members")]:52    r = G[g]; body += f"{l} & {n(r['n'])} & {n(r['firms'])} & {pp(r['sort_EW']['Q5_minus_Q1'])} & ({tv(r['sort_EW']['t_stat'])}) & {pp(r['pre']['mean'])} & {pp(r['post']['mean'])} & ({tv(r['post']['t'])}) & {r['ls']['post']['ff6_alpha_ann_pct']:+.2f} & ({tv(r['ls']['post']['ff6_alpha_t'])}) \\\\\n"53sn = R["size_neutral"]; body += f"Size-neutral quintiles (all) & {n(R['n_obs'])} & {n(R['n_firms'])} & {pp(sn['full']['Q5_minus_Q1'])} & ({tv(sn['full']['t_stat'])}) & {pp(sn['pre']['mean'])} & {pp(sn['post']['mean'])} & ({tv(sn['post']['t'])}) & & \\\\\n"54w("tab_groups.tex", body + "\\bottomrule\n\\end{tabular}")55# placebo56PL = R2["placebo"]; body = "\\begin{tabular}{lrrrrrr}\n\\toprule\nSemantic factor & Full Q5$-$Q1 & Pre & Post & ($t$) & Interaction & ($t$) \\\\\n\\midrule\n"57for k, v in PL.items(): body += f"{k} & {pp(v['full']['mean'])} & {pp(v['pre']['mean'])} & {pp(v['post']['mean'])} & ({tv(v['post']['t'])}) & {v['interaction'] * 100:+.2f} & ({tv(v['interaction_t'])}) \\\\\n"58w("tab_placebo.tex", body + "\\bottomrule\n\\end{tabular}")59# cohorts + pooled60C = R2["cohorts"]; body = "\\begin{tabular}{lr@{\\hspace{2em}}lr}\n\\toprule\nCohort & Q5$-$Q1 (pp) & Pooled test & Estimate \\\\\n\\midrule\n"61cs = list(C["cohort_spreads_pct"].items()); pooled = [("Post cohorts, Q5 vs Q1 (firm-clustered $t$)", f"{C['pooled_post']['coef_pct']:+.1f} ({C['pooled_post']['t']:.2f}), $N$={n(C['pooled_post']['n'])}"), ("Post, winsorized", f"{C['pooled_post_wins']['coef_pct']:+.1f} ({C['pooled_post_wins']['t']:.2f})"), ("Post 2022--2023 only", f"{C['pooled_post_excl_2024']['coef_pct']:+.1f} ({C['pooled_post_excl_2024']['t']:.2f})"), ("Pre cohorts", f"{C['pooled_pre']['coef_pct']:+.1f} ({C['pooled_pre']['t']:.2f})"), ("Difference post $-$ pre", f"{C['pooled_diff']['coef_pct']:+.1f} ({C['pooled_diff']['t']:.2f})"), ("Post mean / leave-one-out", f"{C['post_mean_pct']:+.1f} / " + ", ".join(f"{v:+.1f}" for v in C["post_loo_pct"].values()))]62for i in range(max(len(cs), len(pooled))):63    a = f"{cs[i][0]} & {cs[i][1]:+.1f}" if i < len(cs) else "&"; b = f"{pooled[i][0]} & {pooled[i][1]}" if i < len(pooled) else "&"; body += f"{a} & {b} \\\\\n"64w("tab_cohorts.tex", body + "\\bottomrule\n\\end{tabular}")65# robustness (sector, mag7, alt, breaks, entrants, horizon, benchmark, pca, fwd vol)66rows = []67def add(l, pre, post): rows.append((l, pp(pre["mean"]), tv(pre["t"]), pp(post["mean"]), tv(post["t"])))68add("Baseline (EW quintiles)", SP["AI_COMPOS"]["pre"], SP["AI_COMPOS"]["post"]); add("Sector-neutral composite", R2["sector_neutral"]["pre"], R2["sector_neutral"]["post"])69add("Excluding Magnificent-7", R2["mag7"]["ex_mag7_pre"], R2["mag7"]["ex_mag7_post"]); add("Excluding 500 largest", SP["AI_COMPOS"]["pre"], R2["mag7"]["ex_top500_post"])70for s_, l in [("mean", "Signal: unweighted mean"), ("top5pct", "Signal: top-5\\% chunks")]: add(l, R2["alt_signal"][s_]["pre"], R2["alt_signal"][s_]["post"])71add("Outcome: IWV-adjusted return", R2["alt_benchmark"]["iwv_adj"]["pre"], R2["alt_benchmark"]["iwv_adj"]["post"]); add("Horizon 6 months", R2["alt_horizon"]["6m"]["pre"], R2["alt_horizon"]["6m"]["post"]); add("Horizon 24 months", R2["alt_horizon"]["24m"]["pre"], R2["alt_horizon"]["24m"]["post"])72add("PCA first component", R2["pca"]["pre"], R2["pca"]["post"]); add("Seasoned firms (listed before July 2009)", R2["entrants"]["seasoned"]["pre"], R2["entrants"]["seasoned"]["post"]); add("Listed $\\geq$ 36 months", R2["entrants"]["listed36"]["pre"], R2["entrants"]["listed36"]["post"])73body = "\\begin{tabular}{lrrrr}\n\\toprule\nSpecification & Pre Q5$-$Q1 & ($t$) & Post Q5$-$Q1 & ($t$) \\\\\n\\midrule\n" + "".join(f"{a} & {b} & ({c}) & {d} & ({e}) \\\\\n" for a, b, c, d, e in rows)74w("tab_robust.tex", body + "\\bottomrule\n\\end{tabular}")75# sector controls + TECH76Lc = R2["sector_controls"]; M = R2["monthly_ls"]["AI_COMPOS"]; body = "\\begin{tabular}{lrrrr}\n\\toprule\n & Pre & Post & Full & \\\\\n\\midrule\n"77body += f"FM slope, no sector dummies (pp/SD) & {Lc['fm_pre']['slope_pct']:+.2f} ({tv(Lc['fm_pre']['t'])}) & {Lc['fm_post']['slope_pct']:+.2f} ({tv(Lc['fm_post']['t'])}) & {Lc['fm_full']['slope_pct']:+.2f} ({tv(Lc['fm_full']['t'])}) & \\\\\n"78body += f"FM slope, sector dummies & {Lc['fm_pre']['slope_sector_pct']:+.2f} ({tv(Lc['fm_pre']['t_sector'])}) & {Lc['fm_post']['slope_sector_pct']:+.2f} ({tv(Lc['fm_post']['t_sector'])}) & {Lc['fm_full']['slope_sector_pct']:+.2f} ({tv(Lc['fm_full']['t_sector'])}) & \\\\\n"79body += f"Pooled, year FE (firm-cl.) & {Lc['pooled_pre']['year_fe_pct']:+.2f} ({Lc['pooled_pre']['year_fe_t']:.2f}) & {Lc['pooled_post']['year_fe_pct']:+.2f} ({Lc['pooled_post']['year_fe_t']:.2f}) & {Lc['pooled_full']['year_fe_pct']:+.2f} ({Lc['pooled_full']['year_fe_t']:.2f}) & \\\\\n"80body += f"Pooled, sector$\\times$year FE & {Lc['pooled_pre']['sector_year_fe_pct']:+.2f} ({Lc['pooled_pre']['sector_year_fe_t']:.2f}) & {Lc['pooled_post']['sector_year_fe_pct']:+.2f} ({Lc['pooled_post']['sector_year_fe_t']:.2f}) & {Lc['pooled_full']['sector_year_fe_pct']:+.2f} ({Lc['pooled_full']['sector_year_fe_t']:.2f}) & \\\\\n\\midrule\n"81for lab, key in [("Monthly LS mean (\\%/yr)", "mean_ann_pct"), ("Sharpe", "sharpe"), ("FF6 $\\alpha$ (\\%/yr)", "ff6_alpha_pct"), ("FF6 $t$", "ff6_t"), ("FF6+TECH $\\alpha$ (\\%/yr)", "ff6_tech_alpha_pct"), ("FF6+TECH $t$", "ff6_tech_t"), ("$\\beta_{TECH}$", "tech_beta")]:82    body += f"{lab} & " + " & ".join(f"{M[p].get(key, float('nan')):.2f}" for p in ["pre", "post", "full"]) + " & \\\\\n"83w("tab_sector_tech.tex", body + "\\bottomrule\n\\end{tabular}")84# filing type85N = R2["filing_type"]; body = "\\begin{tabular}{lrrrrrrr}\n\\toprule\nSignal built from & Firm-years covered & Corr. w/ baseline & Full Q5$-$Q1 & Pre & Post & ($t$) & FM slope (pp/SD) \\\\\n\\midrule\n"86for t, l in [("10k", "Form 10-K only"), ("10q", "Form 10-Q only"), ("8k", "Form 8-K only")]:87    v = N[t]; body += f"{l} & {v['share_firm_years'] * 100:.1f}\\% & {v['corr_with_baseline']:.2f} & {pp(v['full']['mean'])} & {pp(v['pre']['mean'])} & {pp(v['post']['mean'])} & ({tv(v['post']['t'])}) & {v['fm_full']['slope_pct']:+.2f} ({tv(v['fm_full']['t'])}) \\\\\n"88hr = N["horse_race_fm"]; body += "\\midrule\nHorse race (FM, all three): & & & & & & & " + "; ".join(f"{l}: {hr[f'z_AI_{t}']['slope_pct']:+.2f} ({hr[f'z_AI_{t}']['t']:.2f})" for t, l in [("10k", "10-K"), ("10q", "10-Q"), ("8k", "8-K")]) + " \\\\\n"89w("tab_filing_type.tex", body + "\\bottomrule\n\\end{tabular}")90# event91body = "\\begin{tabular}{lrrrrrr}\n\\toprule\nHorizon & High & Mid & Low & High$-$Low & Welch $t$ & CDA $t$ \\\\\n\\midrule\n"; cda = {c["horizon"]: c for c in RE["cda"]}92for hz, l in [("car_60d", "60 trading days"), ("car_6m", "6 months"), ("car_1y", "1 year"), ("car_18m", "18 months")]:93    r = RE[hz]; body += f"{l} & {r['High']:+.2f} & {r['Mid']:+.2f} & {r['Low']:+.2f} & {r['H_minus_L']:+.2f} & {r['t_welch']:.2f} & {cda[hz]['t_cda']:.2f} \\\\\n"94body += "\\midrule\n" + " & ".join(["Sub-samples (1-year H$-$L)"] + [f"{l}: {RE['by_size'][g]['H_minus_L_1y']:+.1f} ({RE['by_size'][g]['t_welch']:.2f})" for g, l in [("large", "largest 1,000"), ("small", "remaining"), ("sp500", "S\\&P 500"), ("non_sp500", "non-S\\&P")] if g in RE["by_size"]][:3]) + " \\\\\n"95w("tab_event.tex", body + "\\bottomrule\n\\end{tabular}")96# DiD + SPID97Dd = R2["did"]; Pp = R2["spid"]; body = "\\begin{tabular}{lrr}\n\\toprule\nSpecification & Coefficient (pp) & $t$ \\\\\n\\midrule\n"98body += f"DiD: treated (above-median 2019--21 exposure) $\\times$ post & {Dd['binary']['coef'] * 100:+.2f} & {Dd['binary']['t']:.2f} \\\\\nDiD: continuous exposure $\\times$ post & {Dd['continuous']['coef'] * 100:+.2f} & {Dd['continuous']['t']:.2f} \\\\\n\\midrule\n"99for k, l in [("z_SPID_TECH", "SPID technology projects ($z$)"), ("spid_ai_any", "Any AI-initiative project (0/1)")]:100    for v, vl_ in [(k, l), (f"{k}:post", l + " $\\times$ post"), ("z_AI_COMPOS", "AI composite ($z$)"), ("z_AI_COMPOS:post", "AI composite $\\times$ post")]:101        if v in Pp[k]: body += f"{vl_} & {Pp[k][v]['coef_pct']:+.2f} & {Pp[k][v]['t']:.2f} \\\\\n"102    body += "\\addlinespace\n"103w("tab_did_spid.tex", body + "\\bottomrule\n\\end{tabular}")104# coverage by cohort105cv = R2["coverage"]; body = "\\begin{tabular}{lrrrr}\n\\toprule\nCohort & Firms & of which top-1,000 & Median filings & Median chunks \\\\\n\\midrule\n"106for y in cv["firms_per_cohort"]: body += f"{y} & {n(cv['firms_per_cohort'][y])} & {n(cv['n_large'][y])} & {cv['median_filings'][y]:.0f} & {cv['median_chunks'][y]:.0f} \\\\\n"107w("tab_coverage.tex", body + "\\bottomrule\n\\end{tabular}")108# macros109sp = SP["AI_COMPOS"]; la = L["AI_COMPOS"]; E1 = RE["car_1y"]110mac = {"nObs": n(R["n_obs"]), "nFirms": n(R["n_firms"]), "nFirmYearsPanel": n(META["n_firm_years"]), "yrs": R["yrs"], "nLarge": n(R["n_large"]), "nSPfy": n(R["n_sp500_firm_years"]),111       "spreadFull": pp(S["AI_COMPOS_EW"]["Q5_minus_Q1"]), "spreadFullT": tv(S["AI_COMPOS_EW"]["t_stat"]), "spreadFullVW": pp(S["AI_COMPOS_VW"]["Q5_minus_Q1"]), "spreadFullVWT": tv(S["AI_COMPOS_VW"]["t_stat"]),112       "spreadPre": pp(sp["pre"]["mean"]), "spreadPreT": tv(sp["pre"]["t"]), "spreadPost": pp(sp["post"]["mean"]), "spreadPostT": tv(sp["post"]["t"]),113       "ffsixFull": f"{la['full']['ff6_alpha_ann_pct']:+.1f}", "ffsixFullT": tv(la["full"]["ff6_alpha_t"]), "ffsixPost": f"{la['post']['ff6_alpha_pct' if 'ff6_alpha_pct' in la['post'] else 'ff6_alpha_ann_pct']:+.1f}", "ffsixPostT": tv(la["post"]["ff6_alpha_t"]),114       "sharpePre": f"{la['pre']['sharpe']:.2f}", "sharpePost": f"{la['post']['sharpe']:.2f}", "meanLSPre": f"{la['pre']['mean_ls_ann_pct']:+.1f}", "meanLSPost": f"{la['post']['mean_ls_ann_pct']:+.1f}",115       "cohortsPost": ", ".join(f"{y}: {v:+.1f}" for y, v in C["cohort_spreads_pct"].items() if int(y) >= 2022), "postLOO": ", ".join(f"{v:+.1f}" for v in C["post_loo_pct"].values()), "preMean": f"{C['pre_mean_pct']:+.1f}", "postMean": f"{C['post_mean_pct']:+.1f}",116       "pooledPost": f"{C['pooled_post']['coef_pct']:+.1f}", "pooledPostT": f"{C['pooled_post']['t']:.2f}", "pooledPostW": f"{C['pooled_post_wins']['coef_pct']:+.1f}", "pooledPostWT": f"{C['pooled_post_wins']['t']:.2f}", "pooledDiff": f"{C['pooled_diff']['coef_pct']:+.1f}", "pooledDiffT": f"{C['pooled_diff']['t']:.2f}",117       "eventHL": f"{E1['H_minus_L']:+.1f}", "eventT": f"{E1['t_welch']:.2f}", "eventCDA": f"{cda['car_1y']['t_cda']:.2f}", "eventN": n(RE["n_firms"]), "eventHLsixty": f"{RE['car_60d']['H_minus_L']:+.1f}",118       "largePre": pp(G["large_top1000"]["pre"]["mean"]), "largePost": pp(G["large_top1000"]["post"]["mean"]), "largePostT": tv(G["large_top1000"]["post"]["t"]), "smallPre": pp(G["small_rest"]["pre"]["mean"]), "smallPost": pp(G["small_rest"]["post"]["mean"]), "smallPostT": tv(G["small_rest"]["post"]["t"]),119       "spPre": pp(G["sp500"]["pre"]["mean"]), "spPost": pp(G["sp500"]["post"]["mean"]), "nonspPre": pp(G["non_sp500"]["pre"]["mean"]), "nonspPost": pp(G["non_sp500"]["post"]["mean"]), "nonspPostT": tv(G["non_sp500"]["post"]["t"]),120       "sectNeuPost": pp(R2["sector_neutral"]["post"]["mean"]), "sectNeuPostT": tv(R2["sector_neutral"]["post"]["t"]), "techBetaPost": f"{M['post'].get('tech_beta', float('nan')):.2f}", "ffsixTechPost": f"{M['post'].get('ff6_tech_alpha_pct', float('nan')):+.1f}", "ffsixTechPostT": f"{M['post'].get('ff6_tech_t', float('nan')):.2f}",121       "fmPostSector": f"{Lc['fm_post']['slope_sector_pct']:+.2f}", "fmPostSectorT": tv(Lc["fm_post"]["t_sector"]), "fmPost": f"{Lc['fm_post']['slope_pct']:+.2f}", "fmPostT": tv(Lc["fm_post"]["t"]), "syPost": f"{Lc['pooled_post']['sector_year_fe_pct']:+.2f}", "syPostT": f"{Lc['pooled_post']['sector_year_fe_t']:.2f}",122       "placeboRank": str(R2["placebo_breaks"]["rank_of_2022"]), "placeboN": str(R2["placebo_breaks"]["n_candidates"]), "didCont": f"{Dd['continuous']['coef'] * 100:+.2f}", "didContT": f"{Dd['continuous']['t']:.2f}",123       "tenkPost": pp(N["10k"]["post"]["mean"]), "tenkPostT": tv(N["10k"]["post"]["t"]), "tenkPre": pp(N["10k"]["pre"]["mean"]), "tenqPost": pp(N["10q"]["post"]["mean"]), "eightkPost": pp(N["8k"]["post"]["mean"]), "corrTenK": f"{N['10k']['corr_with_baseline']:.2f}",124       "spidPre": pp(SP["SPID_TECH"]["pre"]["mean"]), "spidPost": pp(SP["SPID_TECH"]["post"]["mean"]), "spidPostT": tv(SP["SPID_TECH"]["post"]["t"]), "spidAnyShare": f"{Pp['share_firm_years_any_ai_project'] * 100:.1f}", "spidAnyPostShare": f"{Pp['share_post_any_ai_project'] * 100:.1f}",125       "esgPost": pp(PL["ESG commitment"]["post"]["mean"]), "climPost": pp(PL["Climate risk"]["post"]["mean"]), "cyberPost": pp(PL["Cybersecurity"]["post"]["mean"]), "autoPost": pp(PL["Automation/labor"]["post"]["mean"]),126       "nEntrantFirms": n(R2["entrants"]["n_firms"] - R2["entrants"]["n_seasoned"]), "nSeasoned": n(R2["entrants"]["n_seasoned"]), "rankAuto": f"{R2['coverage']['rank_autocorr_lag1']:.2f}", "rankAutoFive": f"{R2['coverage']['rank_autocorr_lag5']:.2f}"}127128# ---- side-by-side tables: Panel A Russell 3000, Panel B S&P 500 members ----129SM = R["samples"]; SIGL = [("AI_ADOPT", "AI adoption"), ("AI_INFRA", "AI infrastructure"), ("AI_RISK", "AI disruption risk"), ("AI_COMPOS", "AI composite"), ("SPID_TECH", "SPID tech projects")]130body = "\\begin{tabular}{llrrrrrrrr}\n\\toprule\nSignal & Weighting & Q1 & Q2 & Q3 & Q4 & Q5 & Q5$-$Q1 & $t$ & Years \\\\\n"131for sname, lab in [("r3k", "Panel A: Russell 3000 universe"), ("sp500", "Panel B: S\\&P 500 members only")]:132    body += f"\\midrule\n\\multicolumn{{10}}{{l}}{{\\textit{{{lab}}} ($N$ = {n(SM[sname]['n'])} firm-years, {n(SM[sname]['firms'])} firms)}} \\\\\n\\midrule\n"133    for k, l in SIGL:134        for sfx, wl in [("EW", "EW"), ("VW", "VW")]:135            r = SM[sname]["sorts"][f"{k}_{sfx}"]; body += f"{l if sfx == 'EW' else ''} & {wl} & " + " & ".join(pp(r[f'Q{q}']) for q in range(1, 6)) + f" & {pp(r['Q5_minus_Q1'])} & {tv(r['t_stat'])} & {int(r['n_years'])} \\\\\n"136w("tab_sorts_both.tex", body + "\\bottomrule\n\\end{tabular}")137body = "\\begin{tabular}{llrrrrrrrr}\n\\toprule\nSignal & Sample & Pre Q5$-$Q1 & ($t$) & Post Q5$-$Q1 & ($t$) & Post cohorts 2022 / 2023 / 2024 & Pooled post (firm-cl. $t$) & Winsorized & Post Sharpe \\\\\n\\midrule\n"138for k, l in SIGL:139    for sname, sl in [("r3k", "Russell 3000"), ("sp500", "S\\&P 500")]:140        b = SM[sname]; su = b["sub"][k]; ls_ = b["ls"][k]["post"]141        coh = " / ".join(f"{v * 100:+.1f}" for y, v in su["post"]["by_cohort"].items())142        pooled = f"{b['pooled_post']['coef_pct']:+.1f} ({b['pooled_post']['t']:.2f})" if k == "AI_COMPOS" else ""; wins_ = f"{b['pooled_post']['wins_pct']:+.1f} ({b['pooled_post']['wins_t']:.2f})" if k == "AI_COMPOS" else ""143        body += f"{l if sname == 'r3k' else ''} & {sl} & {pp(su['pre']['mean'])} & ({tv(su['pre']['t'])}) & {pp(su['post']['mean'])} & ({tv(su['post']['t'])}) & {coh} & {pooled} & {wins_} & {ls_['sharpe']:.2f} \\\\\n"144    body += "\\addlinespace\n"145w("tab_prepost_both.tex", body + "\\bottomrule\n\\end{tabular}")146body = "\\begin{tabular}{llrrrrrr}\n\\toprule\nSignal & Sample & Months & Mean (\\%/yr) & Sharpe & FF6 $\\alpha$ full (\\%/yr) & ($t$) & FF6 $\\alpha$ post (\\%/yr) ($t$) \\\\\n\\midrule\n"147for k, l in SIGL:148    for sname, sl in [("r3k", "Russell 3000"), ("sp500", "S\\&P 500")]:149        f_ = SM[sname]["ls"][k]["full"]; p_ = SM[sname]["ls"][k]["post"]150        body += f"{l if sname == 'r3k' else ''} & {sl} & {f_['n_months']} & {f_['mean_ls_ann_pct']:+.2f} & {f_['sharpe']:.2f} & {f_['ff6_alpha_ann_pct']:+.2f} & ({tv(f_['ff6_alpha_t'])}) & {p_['ff6_alpha_ann_pct']:+.2f} ({tv(p_['ff6_alpha_t'])}) \\\\\n"151w("tab_alpha_both.tex", body + "\\bottomrule\n\\end{tabular}")152body = "\\begin{tabular}{lrrrr}\n\\toprule\nFama--MacBeth slope (pp per SD, controls: size, momentum, volatility) & Russell 3000 & ($t$) & S\\&P 500 & ($t$) \\\\\n\\midrule\n"153for spec, v, l in [("compos", "zz_AI_COMPOS", "AI composite"), ("all", "zz_AI_ADOPT", "AI adoption (joint)"), ("all", "zz_AI_INFRA", "AI infrastructure (joint)"), ("all", "zz_AI_RISK", "AI disruption risk (joint)"), ("spid", "zz_SPID_TECH", "SPID tech projects"), ("compos", "zz_size", "Size"), ("compos", "zz_mom", "Momentum"), ("compos", "zz_vol", "Volatility")]:154    a = SM["r3k"]["fm"][spec][v]; b = SM["sp500"]["fm"][spec][v]; body += f"{l} & {a['mean_coef'] * 100:+.2f} & ({tv(a['t'])}) & {b['mean_coef'] * 100:+.2f} & ({tv(b['t'])}) \\\\\n"155w("tab_fm_both.tex", body + "\\bottomrule\n\\end{tabular}")156sp = SM["sp500"]; mac.update({"spN": n(sp["n"]), "spFirms": n(sp["firms"]), "spSpreadFull": pp(sp["sorts"]["AI_COMPOS_EW"]["Q5_minus_Q1"]), "spSpreadFullT": tv(sp["sorts"]["AI_COMPOS_EW"]["t_stat"]),157            "spSpreadPre": pp(sp["sub"]["AI_COMPOS"]["pre"]["mean"]), "spSpreadPost": pp(sp["sub"]["AI_COMPOS"]["post"]["mean"]), "spSpreadPostT": tv(sp["sub"]["AI_COMPOS"]["post"]["t"]),158            "spCohorts": ", ".join(f"{y}: {v:+.1f}" for y, v in sp["cohorts_pct"].items() if int(y) >= 2022), "spSharpePost": f"{sp['ls']['AI_COMPOS']['post']['sharpe']:.2f}", "spSharpePre": f"{sp['ls']['AI_COMPOS']['pre']['sharpe']:.2f}",159            "spFFsixPost": f"{sp['ls']['AI_COMPOS']['post']['ff6_alpha_ann_pct']:+.1f}", "spFFsixPostT": tv(sp["ls"]["AI_COMPOS"]["post"]["ff6_alpha_t"]), "spPooledPost": f"{sp['pooled_post']['coef_pct']:+.1f}", "spPooledPostT": f"{sp['pooled_post']['t']:.2f}", "spPooledPostW": f"{sp['pooled_post']['wins_pct']:+.1f}",160            "spFMcompos": f"{sp['fm']['compos']['zz_AI_COMPOS']['mean_coef'] * 100:+.2f}", "spFMcomposT": tv(sp["fm"]["compos"]["zz_AI_COMPOS"]["t"]), "rkFMcompos": f"{SM['r3k']['fm']['compos']['zz_AI_COMPOS']['mean_coef'] * 100:+.2f}", "rkFMcomposT": tv(SM["r3k"]["fm"]["compos"]["zz_AI_COMPOS"]["t"])})161162163# ---- correlations ----164c = pd.read_csv(f"{T}/t1b_correlations.csv", index_col=0); lab2 = {"z_AI_ADOPT": "AI adoption", "z_AI_INFRA": "AI infrastructure", "z_AI_RISK": "AI disruption risk", "z_SPID_TECH": "SPID tech projects", "z_size": "Size", "z_mom": "Momentum", "fwd_ret": "Forward return"}165cols_ = list(c.columns); body = "\\begin{tabular}{l" + "r" * len(cols_) + "}\n\\toprule\n & " + " & ".join(lab2[x] for x in cols_) + " \\\\\n\\midrule\n"166for i_, rname in enumerate(c.index): body += lab2[rname] + " & " + " & ".join(f"{c.loc[rname, cc]:.2f}" if j_ <= i_ else "" for j_, cc in enumerate(cols_)) + " \\\\\n"167w("tab_corr.tex", body + "\\bottomrule\n\\end{tabular}")168# ---- double sort 3x3 pre/post ----169body = "\\begin{tabular}{llrrrr}\n\\toprule\nPeriod & Size tercile & Low AI & Mid & High AI & High$-$Low \\\\\n"170for per, key in [("Pre-ChatGPT (2010--2021)", "double_sort_pre"), ("Post-ChatGPT (2022--2024)", "double_sort_post")]:171    dsx = pd.DataFrame(R2[key]); body += "\\midrule\n"172    for sz in ["Small", "Mid", "Large"]:173        if sz in dsx.index: body += f"{per if sz == 'Small' else ''} & {sz} & {dsx.loc[sz, 'Lo']:.1f} & {dsx.loc[sz, 'Mid']:.1f} & {dsx.loc[sz, 'Hi']:.1f} & {dsx.loc[sz, 'Hi-Lo']:+.1f} \\\\\n"174w("tab_doublesort.tex", body + "\\bottomrule\n\\end{tabular}")175# ---- top firms by average composite ----176tf = df.groupby(["ticker", "company_name", "sector"]).agg(z=("z_AI_COMPOS", "mean"), yrs=("fiscal_year", "count")).reset_index(); tf = tf[tf.yrs >= 5].nlargest(12, "z")177body = "\\begin{tabular}{lllrr}\n\\toprule\nTicker & Company & Sector & Mean composite ($z$) & Years \\\\\n\\midrule\n"178for r_ in tf.itertuples(): body += f"{r_.ticker} & {str(r_.company_name).title().replace('&', '\\&')[:34]} & {r_.sector} & {r_.z:.2f} & {r_.yrs} \\\\\n"179w("tab_topfirms.tex", body + "\\bottomrule\n\\end{tabular}")180# ---- event inference (CDA / KP) ----181cd = pd.read_csv(f"{T}/t_event_cda.csv"); body = "\\begin{tabular}{lrrrrr}\n\\toprule\nHorizon & Days & High$-$Low CAR (\\%) & $t$ (estimation-window SD) & $t$ (event-window SD) & $\\bar\\rho$ \\\\\n\\midrule\n"182for r_ in cd.itertuples(): body += f"{r_.horizon.replace('car_', '').replace('d', ' days').replace('m', ' months').replace('y', ' year')} & {r_.days} & {r_.HL_CAR_pct:+.2f} & {r_.t_cda:.2f} & {r_.t_event_sd:.2f} & {r_.rho_bar:.4f} \\\\\n"183body += f"\\midrule\n\\multicolumn{{6}}{{l}}{{High tercile: {RE['n_high']} firms; Low tercile: {RE['n_low']} firms; Kolari--Pynnonen deflation factor of the independence $t$: {cd.kp_factor.iloc[0]:.3f}}} \\\\\n"184w("tab_event_cda.tex", body + "\\bottomrule\n\\end{tabular}")185# ---- corpus composition by form ----186fl = pd.read_parquet("data/raw_russell3000/filings"); fl["yr"] = pd.to_datetime(fl["filing_date"]).dt.year187body = "\\begin{tabular}{lrrrr}\n\\toprule\nForm & Filings 2010--2026 & Issuers & Parsed & Firm-years with a scored filing (estimation sample) \\\\\n\\midrule\n"188for fm_ in ["10-K", "10-Q", "8-K"]:189    sub = fl[fl.form_type == fm_]; tag = {"10-K": "n_10k", "10-Q": "n_10q", "8-K": "n_8k"}[fm_]190    body += f"{fm_} & {n(len(sub))} & {n(sub.cik.nunique())} & {n((sub.parse_status == 'complete').sum())} & {df[tag].notna().mean() * 100:.1f}\\% \\\\\n"191body += f"\\midrule\nTotal & {n(len(fl))} & {n(fl.cik.nunique())} & {n((fl.parse_status == 'complete').sum())} & \\\\\n"192w("tab_corpus.tex", body + "\\bottomrule\n\\end{tabular}")193mac.update({"nFilingsCorpus": n(len(fl)), "nIssuersCorpus": n(fl.cik.nunique()), "corrAdoptInfra": f"{c.loc['z_AI_ADOPT', 'z_AI_INFRA']:.2f}", "corrAdoptRisk": f"{c.loc['z_AI_ADOPT', 'z_AI_RISK']:.2f}", "corrSpid": f"{c.loc['z_AI_ADOPT', 'z_SPID_TECH']:.2f}",194            "dsSmallPost": f"{pd.DataFrame(R2['double_sort_post']).loc['Small', 'Hi-Lo']:+.1f}", "dsLargePost": f"{pd.DataFrame(R2['double_sort_post']).loc['Large', 'Hi-Lo']:+.1f}", "dsSmallPre": f"{pd.DataFrame(R2['double_sort_pre']).loc['Small', 'Hi-Lo']:+.1f}", "dsLargePre": f"{pd.DataFrame(R2['double_sort_pre']).loc['Large', 'Hi-Lo']:+.1f}",195            "evLarge": f"{RE['by_size']['large']['H_minus_L_1y']:+.1f}", "evLargeT": f"{RE['by_size']['large']['t_welch']:.2f}", "evSmall": f"{RE['by_size']['small']['H_minus_L_1y']:+.1f}", "evSmallT": f"{RE['by_size']['small']['t_welch']:.2f}", "evSP": f"{RE['by_size']['sp500']['H_minus_L_1y']:+.1f}", "evSPT": f"{RE['by_size']['sp500']['t_welch']:.2f}", "evNonSP": f"{RE['by_size']['non_sp500']['H_minus_L_1y']:+.1f}", "evNonSPT": f"{RE['by_size']['non_sp500']['t_welch']:.2f}",196            "evXsec": f"{RE['xsec_1y']['ai_pre_pct']:+.1f}", "evXsecT": f"{RE['xsec_1y']['t']:.2f}", "evXsecSect": f"{RE['xsec_1y_sector']['ai_pre_pct']:+.1f}", "evXsecSectT": f"{RE['xsec_1y_sector']['t']:.2f}", "evRho": f"{cd.rho_bar.iloc[0]:.3f}", "evCDAsixty": f"{cd.t_cda.iloc[0]:.2f}", "evHLeighteen": f"{RE['car_18m']['H_minus_L']:+.1f}", "evCDAeighteen": f"{cd.t_cda.iloc[3]:.2f}",197            "fmPre": f"{Lc['fm_pre']['slope_pct']:+.2f}", "fmPreT": tv(Lc["fm_pre"]["t"]), "fmFull": f"{Lc['fm_full']['slope_pct']:+.2f}", "fmFullT": tv(Lc["fm_full"]["t"]), "fmFullSector": f"{Lc['fm_full']['slope_sector_pct']:+.2f}", "fmFullSectorT": tv(Lc["fm_full"]["t_sector"]), "syFull": f"{Lc['pooled_full']['sector_year_fe_pct']:+.2f}", "syFullT": f"{Lc['pooled_full']['sector_year_fe_t']:.2f}",198            "techBetaFull": f"{M['full'].get('tech_beta', float('nan')):.2f}", "ffsixTechFull": f"{M['full'].get('ff6_tech_alpha_pct', float('nan')):+.1f}", "ffsixTechFullT": f"{M['full'].get('ff6_tech_t', float('nan')):.2f}", "sharpeFull": f"{M['full']['sharpe']:.2f}", "meanLSFull": f"{M['full']['mean_ann_pct']:+.1f}", "hacFull": f"{M['full']['hac_t']:.2f}",199            "placeboBest": max(R2["placebo_breaks"]["diff_post_minus_pre_pct_by_break_year"], key=R2["placebo_breaks"]["diff_post_minus_pre_pct_by_break_year"].get), "placeboDiffTwentyTwo": f"{R2['placebo_breaks']['diff_post_minus_pre_pct_by_break_year']['2022']:+.1f}",200            "evtEighteen": f"{[e for e in R2['did_eventtime'] if e['year'] == 2018][0]['coef'] * 100:+.1f}", "evtTwentyFour": f"{[e for e in R2['did_eventtime'] if e['year'] == 2024][0]['coef'] * 100:+.1f}", "evtTwentyTwo": f"{[e for e in R2['did_eventtime'] if e['year'] == 2022][0]['coef'] * 100:+.1f}",201            "riskPost": pp(PL["AI disruption risk"]["post"]["mean"]), "riskPostT": tv(PL["AI disruption risk"]["post"]["t"]), "riskPre": pp(PL["AI disruption risk"]["pre"]["mean"]), "adoptPost": pp(PL["AI adoption"]["post"]["mean"]), "infraPost": pp(PL["AI infrastructure"]["post"]["mean"]), "macroPost": pp(PL["Macro risk"]["post"]["mean"]),202            "tenqPre": pp(N["10q"]["pre"]["mean"]), "eightkPre": pp(N["8k"]["pre"]["mean"]), "corrEightK": f"{N['8k']['corr_with_baseline']:.2f}", "hrTenK": f"{N['horse_race_fm']['z_AI_10k']['slope_pct']:+.2f}", "hrTenKT": f"{N['horse_race_fm']['z_AI_10k']['t']:.2f}", "hrEightK": f"{N['horse_race_fm']['z_AI_8k']['slope_pct']:+.2f}", "hrEightKT": f"{N['horse_race_fm']['z_AI_8k']['t']:.2f}", "hrTenQ": f"{N['horse_race_fm']['z_AI_10q']['slope_pct']:+.2f}", "hrTenQT": f"{N['horse_race_fm']['z_AI_10q']['t']:.2f}",203            "spidAnyPre": f"{Pp['spread_ai_any_post']['pre']['mean_pct']:+.1f}", "spidAnyPost": f"{Pp['spread_ai_any_post']['post']['mean_pct']:+.1f}", "spidAnyPostT": tv(Pp["spread_ai_any_post"]["post"]["t"]),204            "magSevenPost": pp(R2["mag7"]["ex_mag7_post"]["mean"]), "listedPre": pp(R2["entrants"]["listed36"]["pre"]["mean"]), "listedPost": pp(R2["entrants"]["listed36"]["post"]["mean"]), "exTopFiveHundredPost": pp(R2["mag7"]["ex_top500_post"]["mean"]), "seasonedPost": pp(R2["entrants"]["seasoned"]["post"]["mean"]), "seasonedPre": pp(R2["entrants"]["seasoned"]["pre"]["mean"]), "entrantPrem": f"{R2['entrants']['entrant_minus_seasoned_fwd_pct']:+.1f}",205            "sixmPost": pp(R2["alt_horizon"]["6m"]["post"]["mean"]), "iwvPost": pp(R2["alt_benchmark"]["iwv_adj"]["post"]["mean"]), "iwvPre": pp(R2["alt_benchmark"]["iwv_adj"]["pre"]["mean"]), "pcaPost": pp(R2["pca"]["post"]["mean"]), "pcaEVR": f"{R2['pca']['evr'][0] * 100:.1f}", "fvolPost": f"{R2['fwd_vol']['post']['mean'] * 100:+.1f}", "fvolPostT": tv(R2["fwd_vol"]["post"]["t"]), "fvolPre": f"{R2['fwd_vol']['pre']['mean'] * 100:+.1f}",206            "breakInfraT": tv(B["AI_INFRA"]["interaction_t_firm"]), "breakComposT": tv(B["AI_COMPOS"]["interaction_t_firm"]), "breakCompos": f"{B['AI_COMPOS']['interaction'] * 100:+.2f}", "didBin": f"{Dd['binary']['coef'] * 100:+.2f}", "didBinT": f"{Dd['binary']['t']:.2f}", "vwQone": pp(S["AI_COMPOS_VW"]["Q1"]), "vwQfive": pp(S["AI_COMPOS_VW"]["Q5"]), "ewQone": pp(S["AI_COMPOS_EW"]["Q1"]), "ewQfive": pp(S["AI_COMPOS_EW"]["Q5"]),207            "feCompos": f"{PF['M7_all_spid']['coefs']['z_AI_COMPOS']['coef'] * 100:+.2f}", "feComposT": f"{PF['M7_all_spid']['coefs']['z_AI_COMPOS']['t']:.2f}", "feAdopt": f"{PF['M2_adopt_ctrl']['coefs']['z_AI_ADOPT']['coef'] * 100:+.2f}", "feAdoptT": f"{PF['M2_adopt_ctrl']['coefs']['z_AI_ADOPT']['t']:.2f}", "feInfra": f"{PF['M3_infra_ctrl']['coefs']['z_AI_INFRA']['coef'] * 100:+.2f}", "feInfraT": f"{PF['M3_infra_ctrl']['coefs']['z_AI_INFRA']['t']:.2f}", "feSize": f"{PF['M2_adopt_ctrl']['coefs']['z_size']['coef'] * 100:+.2f}", "feSizeT": f"{PF['M2_adopt_ctrl']['coefs']['z_size']['t']:.2f}",208            "nLargeFirms": n(G["large_top1000"]["firms"]), "nSmallFirms": n(G["small_rest"]["firms"]), "nSmall": n(G["small_rest"]["n"]), "largeFFsixPost": f"{G['large_top1000']['ls']['post']['ff6_alpha_ann_pct']:+.1f}", "largeFFsixPostT": tv(G["large_top1000"]["ls"]["post"]["ff6_alpha_t"]), "largeSharpePost": f"{G['large_top1000']['ls']['post']['sharpe']:.2f}", "smallSharpePost": f"{G['small_rest']['ls']['post']['sharpe']:.2f}", "smallSharpePre": f"{G['small_rest']['ls']['pre']['sharpe']:.2f}", "largeSharpePre": f"{G['large_top1000']['ls']['pre']['sharpe']:.2f}", "smallFull": pp(G["small_rest"]["sort_EW"]["Q5_minus_Q1"]), "smallFullT": tv(G["small_rest"]["sort_EW"]["t_stat"]), "largeFull": pp(G["large_top1000"]["sort_EW"]["Q5_minus_Q1"]), "largeFullT": tv(G["large_top1000"]["sort_EW"]["t_stat"]),209            "sizeNeuFull": pp(sn["full"]["Q5_minus_Q1"]), "sizeNeuFullT": tv(sn["full"]["t_stat"]), "sizeNeuPost": pp(sn["post"]["mean"]), "sizeNeuPre": pp(sn["pre"]["mean"]), "largeCohorts": ", ".join(f"{y}: {v * 100:+.1f}" for y, v in G["large_top1000"]["post"]["by_cohort"].items()), "smallCohorts": ", ".join(f"{y}: {v * 100:+.1f}" for y, v in G["small_rest"]["post"]["by_cohort"].items()),210            "fmPostSectorFull": f"{Lc['fm_full']['slope_sector_pct']:+.2f}", "preCohortsAbove": str(sum(1 for y, v in C["cohort_spreads_pct"].items() if int(y) < 2022 and v > C["cohort_spreads_pct"]["2022"])), "preCohortsPositive": f"{C['pre_cohorts_positive_share'] * 100:.0f}", "nonSPfirms": n(G["non_sp500"]["firms"])})211212open(f"{P}/macros.tex", "w").write("".join(f"\\newcommand{{\\m{k}}}{{{v}}}\n" for k, v in mac.items())); print("macros", len(mac))213
Files main
Menu

Theme