SPB Git

Repository Public Research preview

12_make_tables_review.py 12.7 KB 128 lines python

1"""12_make_tables_review.py -- LaTeX fragments for the tables added by the editorial-board review2(2026-10-17): corpus composition, post-period inference, additional robustness, event-study inference."""3import json4R = json.load(open("results/tables/results_review.json")); CC = json.load(open("results/tables/corpus_composition.json"))5def w(n, b): open(f"paper/tables/{n}.tex", "w").write(b)6def ts(t): return "" if t is None else f" \\tstat{{{t:.2f}}}"7def pct(x): return f"{x*100:+.1f}"89# ---------------- corpus composition ----------------10dl = CC["filings_downloaded_by_form"]; sc = CC["filings_scored_by_form"]; cpf = CC["chunks_per_filing_by_form"]11chq = R["H_coverage"]["chunks_per_firm_year_quantiles"]12w("tab_corpus", r"""\begin{table}[H]\centering13\caption{Composition of the Scored Filing Corpus}\label{tab:corpus}14\small15\begin{tabular}{lrrr}\toprule16& Form 8-K & Form 10-Q & Form 10-K \\\midrule17Filings downloaded, 2010--2026 & %s & %s & %s \\18Filings parsed and scored & %s & %s & 0 \\19Share of downloaded filings scored & %.0f\%% & %.0f\%% & 0\%% \\20Chunks per scored filing (median) & %.0f & %.0f & --- \\21Tickers with at least one scored filing & 500 & 84 & 0 \\22Mean AI-adoption score per filing (\texttt{wmean}) & %.3f & %.3f & --- \\23\midrule24\multicolumn{4}{l}{\textit{Firm-year aggregates (7{,}869 firm-years)}}\\25Firm-years containing a scored 10-Q & \multicolumn{3}{r}{%.1f\%%} \\26Chunks per firm-year: p5 / p25 / median / p75 / p95 & \multicolumn{3}{r}{%.0f / %.0f / %.0f / %.0f / %.0f} \\27\bottomrule28\end{tabular}29\tablelegend{This table describes the filings that enter the semantic panel of the EDGAR Research Database at the time of the June 2026 draft. Filings were downloaded for the 500 current S\&P~500 constituents for the three form types, but the section parser and the scoring engine had processed only the Form 8-K current reports and a subset of the Form 10-Q quarterly reports (84 tickers, listed in Appendix~\ref{app:corpus}); no Form 10-K was parsed. The firm-year score is the unweighted average of filing-level scores over all filings dated in the calendar year, so that a 10-Q with roughly 60 chunks and an 8-K with two chunks carry the same weight. Mean AI-adoption scores differ markedly by form type, which is why Section~\ref{subsec:corpus} re-estimates the main results on an 8-K-only signal. Sources: \texttt{results/tables/corpus\_composition.json} and \texttt{results\_review.json}.}30\end{table}""" % (f"{dl['8-K']:,}", f"{dl['10-Q']:,}", f"{dl['10-K']:,}", f"{sc['8-K']:,}", f"{sc['10-Q']:,}",31                  100*sc['8-K']/dl['8-K'], 100*sc['10-Q']/dl['10-Q'], cpf['8-K']['50%'], cpf['10-Q']['50%'],32                  CC["ai_adoption_wmean_by_form"]["8-K"]["mean"], CC["ai_adoption_wmean_by_form"]["10-Q"]["mean"],33                  100*R["F_filing_type"]["share_firm_years_with_scored_10Q"], chq["0.05"], chq["0.25"], chq["0.5"], chq["0.75"], chq["0.95"]))3435# ---------------- post-period inference ----------------36B = R["B_cohorts_and_pooled"]; A = R["A_monthly_longshort"]37cs = B["cohort_spreads_pct"]; loo = B["post_leave_one_out_pct"]38rows = ""39for y in ["2022", "2023", "2024"]:40    rows += f"Cohort {y} (holding July {int(y)+1}--June {int(y)+2}) & {cs[y]:+.1f} & {loo[y]:+.1f} \\\\\n"41pp = B["pooled_post_Q5_vs_Q1"]; px = B["pooled_post_Q5_vs_Q1_excl_2024"]; pr = B["pooled_pre_Q5_vs_Q1"]; pd_ = B["pooled_diff_in_spread"]42def arow(lab, k):43    a = A["AI_COMPOS"][k]44    return (f"{lab} & {a['n_months']} & {a['mean_ann_pct']:+.1f} & {a['sharpe_ann']:.2f} & {a['hac_t_mean']:.2f} & "45            f"{a['ff6_alpha_ann_pct']:+.1f} \\tstat{{{a['ff6_alpha_t']:.2f}}} & {a['ff6_tech_alpha_ann_pct']:+.1f} \\tstat{{{a['ff6_tech_alpha_t']:.2f}}} & {a['tech_beta']:.2f} \\tstat{{{a['tech_beta_t']:.2f}}} \\\\\n")46w("tab_postinference", r"""\begin{table}[H]\centering47\caption{How Much Evidence Is There in the Post-ChatGPT Period?}\label{tab:postinf}48\small49\begin{tabular}{lcc}\toprule50\multicolumn{3}{l}{\textit{Panel A. Post-period cohorts (AI composite, EW Q5$-$Q1, \%%)}}\\51& Spread & Post mean excluding this cohort \\\midrule52%s\midrule53Post-period mean (three cohorts) & %+.1f & \\54Pre-period mean (twelve cohorts; share positive %.0f\%%) & %+.1f & \\55\midrule56\multicolumn{3}{l}{\textit{Panel B. Pooled firm-level tests (Q5 vs.\ Q1 firm-years, year dummies, SE clustered by firm)}}\\57& Spread (\%%) & \textit{t} \\\midrule58Post cohorts 2022--2024 (raw returns), $n=%s$ & %+.1f & %.2f \\59Post cohorts 2022--2024 (winsorized returns) & %+.1f & %.2f \\60Post cohorts 2022--2023 only, $n=%s$ & %+.1f & %.2f \\61Pre cohorts 2010--2021, $n=%s$ & %+.1f & %.2f \\62Post minus pre (interaction) & %+.1f & %.2f \\63\bottomrule64\end{tabular}6566\vspace{0.6em}67{\footnotesize\begin{tabular}{lrrrrrrr}\toprule68\multicolumn{8}{l}{\textit{Panel C. Monthly long--short series (AI composite, EW, annually rebalanced)}}\\69Period & Months & Mean (\%%/yr) & Sharpe & HAC \textit{t} & FF6 $\alpha$ (\%%/yr) & FF6+TECH $\alpha$ & $\beta_{\text{TECH}}$ \\\midrule70%s\bottomrule71\end{tabular}}72\tablelegend{Panel~A reports the equal-weighted Q5$-$Q1 forward-return spread on the AI composite for each post-ChatGPT formation cohort and the post-period mean obtained when that cohort is dropped. Panel~B pools the firm-years in the top and bottom quintiles and regresses the forward return on a top-quintile indicator and formation-year dummies, with standard errors clustered by firm; the last row interacts the indicator with a post-2022 dummy in the pooled pre- and post-period sample. Panel~C describes the monthly return of the self-financing high-minus-low portfolio in each sub-period (the post-period starts in July 2023, the first holding month of the 2022 cohort); the HAC $t$-statistic tests the mean with Newey--West (three-lag) errors; FF6 is the Fama--French five-factor model plus momentum; TECH is the equal-weighted return of the Information Technology constituents in the panel minus the equal-weighted return of all constituents, and $\beta_{\text{TECH}}$ its loading. Factor regressions use the 34 (post) and 144 (pre) months for which the French factors are available. Source: \texttt{scripts/11\_review\_reanalysis.py}.}73\end{table}""" % (rows, B["post_mean_pct"], 100*B["pre_cohorts_positive_share"], B["pre_mean_pct"],74                  f"{pp['n']:,}".replace(",","{,}"), pp["coef_pct"], pp["t_firm_cluster"], pp["winsorized_coef_pct"], pp["winsorized_t"],75                  f"{px['n']:,}".replace(",","{,}"), px["coef_pct"], px["t_firm_cluster"], f"{pr['n']:,}".replace(",","{,}"), pr["coef_pct"], pr["t_firm_cluster"], pd_["coef_pct"], pd_["t_firm_cluster"],76                  arow("Full sample", "full") + arow("Pre-ChatGPT", "pre") + arow("Post-ChatGPT", "post")))7778# ---------------- additional robustness ----------------79F = R["F_filing_type"]; Dd = R["D_entrants"]; CB = R["C_break_definitions"]; E = R["E_sector_controls"]80def prepost(lab, pre, post):81    return f"{lab} & {pct(pre['mean'])}{ts(pre['nw_t'])} & {pct(post['mean'])}{ts(post['nw_t'])} & {pct(post['by_cohort']['2022'])} / {pct(post['by_cohort']['2023'])} / {pct(post['by_cohort']['2024'])} \\\\\n"82body = r"\multicolumn{4}{l}{\textit{Panel A. Composition of the text signal}}\\" + "\n"83body += prepost("Baseline composite (all scored filings)", F["baseline"]["pre"], F["baseline"]["post"])84body += prepost("8-K-only composite", F["8k_only"]["pre"], F["8k_only"]["post"])85body += prepost("Baseline, 84 firms with scored 10-Qs excluded", F["excl_10Q_tickers"]["pre"], F["excl_10Q_tickers"]["post"])86body += r"\midrule\multicolumn{4}{l}{\textit{Panel B. Entrants and survivorship}}\\" + "\n"87body += prepost(f"Seasoned firms (prices since July 2009; {Dd['n_firms_seasoned']} firms)", Dd["seasoned"]["pre"], Dd["seasoned"]["post"])88body += prepost("Firms listed at least 36 months at formation", Dd["listed_36m"]["pre"], Dd["listed_36m"]["post"])89body += r"\midrule\multicolumn{4}{l}{\textit{Panel C. Definition of the break}}\\" + "\n"90cb = CB["excl_2021_pre_2010_2020"]; p21 = CB["post_from_2021"]91body += f"Pre-period ends in 2020 (2021 cohort dropped) & {pct(cb['mean'])}{ts(cb['nw_t'])} & --- & --- \\\\\n"92body += f"Post-period starts in 2021 (cohorts 21 / 22 / 23 / 24) & --- & {pct(p21['mean'])}{ts(p21['nw_t'])} & {pct(p21['by_cohort']['2021'])} / {pct(p21['by_cohort']['2022'])} / {pct(p21['by_cohort']['2023'])} / {pct(p21['by_cohort']['2024'])} \\\\\n"93body += r"\midrule\multicolumn{4}{l}{\textit{Panel D. Sector controls (slope per cross-sectional SD of the composite, \%)}}\\" + "\n"94fp, fo = E["fm_pre"], E["fm_post"]; yb = E["fm_by_year_sector_fe_pct"]95body += f"Fama--MacBeth, size, momentum, volatility controls & {fp['slope_no_sector_pct']:+.2f}{ts(fp['t_no_sector'])} & {fo['slope_no_sector_pct']:+.2f}{ts(fo['t_no_sector'])} & --- \\\\\n"96body += f"Fama--MacBeth, adding GICS-sector dummies & {fp['slope_sector_fe_pct']:+.2f}{ts(fp['t_sector_fe'])} & {fo['slope_sector_fe_pct']:+.2f}{ts(fo['t_sector_fe'])} & {yb['2022']:+.1f} / {yb['2023']:+.1f} / {yb['2024']:+.1f} \\\\\n"97pp_, po_ = E["pooled_pre"], E["pooled_post"]98body += f"Pooled OLS, year FE, firm-clustered SE & {pp_['year_fe_slope_pct']:+.2f}{ts(pp_['year_fe_t'])} & {po_['year_fe_slope_pct']:+.2f}{ts(po_['year_fe_t'])} & --- \\\\\n"99body += f"Pooled OLS, sector~$\\times$~year FE, firm-clustered SE & {pp_['sector_year_fe_slope_pct']:+.2f}{ts(pp_['sector_year_fe_t'])} & {po_['sector_year_fe_slope_pct']:+.2f}{ts(po_['sector_year_fe_t'])} & --- \\\\\n"100w("tab_review_robust", r"""\begin{table}[H]\centering101\caption{Additional Robustness: Signal Composition, Entrants, Break Definition, and Sector Controls}\label{tab:reviewrobust}102\footnotesize103\begin{tabular}{@{}p{7.1cm}ccc@{}}\toprule104& Pre (2010--21) & Post (2022--24) & Cohorts 2022 / 23 / 24 \\\midrule105%s\bottomrule106\end{tabular}107\tablelegend{Panels~A--C report the equal-weighted Q5$-$Q1 forward-return spread on the AI composite (percent per year, Newey--West three-lag $t$-statistics on the annual spreads in parentheses) with the cohort-by-cohort post-period values in the last column. Panel~A rebuilds the composite from Form 8-K filings only (\texttt{data/processed/filing\_type\_scores.parquet}) and, alternatively, drops the 84 tickers whose 10-Q filings were scored (Table~\ref{tab:corpus}). Panel~B restricts the universe to firms with Yahoo Finance prices since July 2009, which removes later listings such as Uber, Palantir or Airbnb, and to firm-years with at least 36 months of price history at formation. Panel~C moves the 2021 cohort, whose July 2022--June 2023 holding period straddles the ChatGPT launch, out of the pre-period or into the post-period. Panel~D reports the average annual cross-sectional slope on the composite (Fama--MacBeth) with and without GICS-sector dummies, and pooled regressions of the winsorized forward return on the composite and controls with year or sector-by-year fixed effects and firm-clustered standard errors. Source: \texttt{scripts/11\_review\_reanalysis.py}.}108\end{table}""" % body)109110# ---------------- event-study inference ----------------111G = R["G_event_inference"]; EV = json.load(open("results/tables/results_event.json"))112hz = {"car_60d": "+60 trading days", "car_6m": "+6 months", "car_1y": "+1 year", "car_18m": "+18 months"}113rows = ""114for rec in G["cda"]:115    e = EV[rec["horizon"]]116    rows += f"{hz[rec['horizon']]} & {rec['HL_CAR_pct']:+.2f} & {e['t']:.2f} & {rec['t_cda']:.2f} & {rec['t_event_window_sd']:.2f} \\\\\n"117w("tab_event_cda", r"""\begin{table}[H]\centering118\caption{Event-Study Inference under Cross-Sectional Dependence}\label{tab:eventcda}119\small120\begin{tabular}{lrrrr}\toprule121& High$-$Low CAR & Welch \textit{t} & Portfolio \textit{t} & Portfolio \textit{t} \\122Horizon & (\%%) & (independence) & (estimation-window SD) & (event-window SD) \\\midrule123%s\bottomrule124\end{tabular}125\tablelegend{All firms share the same event date, so firm-level abnormal returns are cross-sectionally correlated and the Welch $t$-test of Table~\ref{tab:event}, which treats the %d High and %d Low firms as independent draws, overstates precision: the average pairwise correlation of market-model residuals over the January--October 2022 estimation window is $\bar\rho=%.3f$, and the deflation factor of Kolari and Pynn\"onen (2010) for a one-sample test, $\sqrt{(1-\bar\rho)/(1+(n-1)\bar\rho)}$, equals %.2f. The portfolio tests sidestep the problem by treating the daily High-minus-Low abnormal return as a single time series: its cumulative value over $T$ event days is divided by $\hat\sigma\sqrt{T}$, where $\hat\sigma$ is the daily standard deviation of the same portfolio series either in the estimation window (crude dependence adjustment of Brown and Warner, 1985; $\hat\sigma=%.3f\%%$) or in the event window itself (%.3f\%%). Source: \texttt{scripts/11\_review\_reanalysis.py}.}126\end{table}""" % (rows, G["n_high"], G["n_low"], G["cda"][0]["rho_bar"], G["cda"][0]["kp_adjustment_factor"], G["hl_portfolio_daily_sd_est_pct"], G["hl_portfolio_daily_sd_event_pct"]))127print("review tables written")128
Files main
Menu

Theme