hdfe_ols
Runs OLS regression with high-dimensional fixed effects, absorbing multiple categorical factors to control for unobserved heterogeneity, while providing robust, clustered, or spatial standard errors for valid causal inference.
Instructions
reghdfe-style OLS with high-dimensional fixed effects. Validation: certified parity evidence. Do NOT use when: vce='conley' on more than ~20,000 rows -- dense O(n^2) memory (see cost); use sp.conley on the fitted result instead. Cost: Absorption is linear in n. vce='conley' is the exception: the within-transformed design goes through conley_vcov_matrix, which builds dense n x n distance and kernel matrices -- ~80 GB at n=100,000. vce='cr2'/'cr3' are per-cluster and cheap by comparison. Assumptions: Linear conditional mean after absorbing high-dimensional fixed effects (Frisch-Waugh-Lovell); Exogeneity of regressors conditional on the absorbed fixed-effect dimensions; Clustered SEs require enough clusters for asymptotics; multiway cluster needs each dimension well-populated. Pre-conditions: Continuous outcome; Fixed-effect factor variable(s) in the '| fe1 + fe2' part of the formula. Failure modes: Singleton groups absorb their own observations and bias clustered SEs -> Keep drop_singletons=True so singletons are removed before estimation; Alternating-projections absorber does not converge -> Raise maxiter / loosen tol, or reduce the number of FE dimensions; Too few clusters make wi...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tol | No | Numerical convergence tolerance. | |
| vce | No | Canonical SE-menu keyword (matches ``sp.regress`` / ``sp.feols``): - ``"robust"`` / ``"hc1"`` -- heteroskedasticity-robust on the FE-absorbed design with reghdfe's small-sample factor ``N/(N-k-df_a)``; matches Stata ``reghdfe ..., vce(robust)``. - ``"hc0"`` -- no small-sample factor. - ``"CR2"`` / ``"CR3"`` / ``"jackknife"`` -- Pustejovsky-Tipton (2018) bias-reduced cluster-robust on the within design (requires ``cluster=``, one-way); matches R ``clubSandwich::vcovCR(plm)``. - ``"conley"`` -- Conley spatial HAC on the within design (requires ``conley_lat=/conley_lon=/conley_cutoff=``; Stata ``acreg`` planar distance convention). - ``"wild"`` -- shorthand for ``wild=True`` (requires ``cluster=``). | |
| wild | No | If True (and ``cluster`` is given), return wild-cluster-bootstrap p-values / CIs alongside classical cluster SE. Applied variable- by-variable. Only supported with a single cluster column. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| detail | No | Payload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip. | agent |
| cluster | No | One-way or multi-way cluster column(s). | |
| formula | Yes | ``"y ~ x1 + x2 | fe1 + fe2 + fe3"``. The ``| fe...`` part is optional. Both sides accept bare names, ``c.x`` / ``i.f``, ``a:b``, ``a*b``, ``f1^f2`` and the varying-slope forms ``i.f#c.x`` / ``i.f##c.x`` / ``f[[x]]`` / ``f[x]`` -- see the module docstring for the full grammar. | |
| maxiter | No | maxiter parameter (int). | |
| se_type | No | Override automatic inference of SE type. Usually inferred from ``cluster`` / ``wild``. | |
| weights | No | Observation weights. Column name or raw array. | |
| as_handle | No | If true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running. | |
| data_path | Yes | Absolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://. | |
| result_id | No | Optional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns. | |
| wild_seed | No | wild_seed parameter (Optional[int]). | |
| conley_lat | No | Coordinate columns (decimal degrees) for ``vce="conley"``. | |
| conley_lon | No | Coordinate columns (decimal degrees) for ``vce="conley"``. | |
| wild_n_boot | No | Bootstrap replications. | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| conley_cutoff | No | Conley distance cutoff in km for ``vce="conley"``. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. | |
| drop_singletons | No | drop_singletons parameter (bool). | |
| wild_weight_type | No | wild_weight_type parameter (str). | webb |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||