# F2-dev-01 — Two-way FE slope with firm-clustered uncertainty ## Question Estimate β in y_it = a_i + g_t + β x_it + u_it (firm and year fixed effects), with standard errors that allow arbitrary within-firm dependence over time. The data are simulated (synthetic). ## Data and exclusions `data/firm_panel.csv`: 1200 rows read. 100 firms (IDs 1001–1100) × 12 years (2008–2019), one row per firm–year. I checked for missing values, duplicated firm–year keys, imbalance, and firms with no within-firm variation in x. None of these problems turned up, so no rows were excluded (`data_issues` = []). All 1200 observations are used. ## Method - Baseline: pooled OLS of y on x with an intercept. - Two-way FE: OLS of y on x plus firm and year dummies (LSDV), which is numerically identical to the two-way within estimator in a balanced panel. Residual df = 1200 − 1 − 99 − 11 − 1 = 1088. - Conventional SE: the homoskedastic OLS SE from the LSDV fit (df = 1088). - Clustered SE: the CR1 sandwich estimator clustered by `firm_id` (100 clusters). It uses the statsmodels small-sample factor G/(G−1)·(N−1)/(N−K), where K counts all dummies (like Stata `areg`/`reg … i.firm, vce(cluster firm)`). - 95% CI: β̂ ± t_{0.975, G−1} · se_cluster, with G−1 = 99 df (t = 1.984). - No randomness is involved (`random_seed` = null). ## Results | quantity | value | |---|---| | pooled OLS slope | 1.2684 | | two-way FE β̂ | 0.6045 | | conventional SE | 0.0326 | | firm-clustered SE | 0.0471 | | 95% CI (clustered) | [0.5111, 0.6978] | The pooled slope is about twice the FE slope. This means x is correlated with the firm and/or year effects, so the naïve estimate is biased upward relative to the within-firm, within-year association. ## Uncertainty The clustered SE is about 1.44 times the conventional SE. This suggests positive within-firm dependence in the residuals and/or x over time, which the conventional SE ignores. The result changes little under other small-sample conventions (see `sensitivity` in results.json): - clustered SE with no finite-sample correction: 0.0446; - clustered SE with K excluding the absorbed fixed effects (Stata `xtreg, fe` style): 0.0448; - normal-critical-value CI: [0.5122, 0.6967]. I report the most conservative variant (0.0471) as `se_cluster`. ## Limitations and open issues - β is a within-firm, within-year association. It is not a causal effect unless x is strictly exogenous given the fixed effects. - Inference relies on asymptotics in the number of firms. G = 100 is moderate, so it should be adequate. - The choice of finite-sample correction for the clustered SE is a convention. The alternatives differ by about 5%. - These are synthetic data. The conclusions apply only to this dataset.