feols
Estimates OLS and IV regressions with high-dimensional fixed effects, providing robust, clustered, or spatial standard errors to support causal inference and decision-making.
Instructions
Estimate OLS / IV with high-dimensional fixed effects via pyfixest. Validation: certified parity evidence. Do NOT use when: vce='conley' on more than ~20,000 rows -- that path is dense O(n^2) (see cost); use sp.conley on the fitted result, which is sparse and scales. Cost: Default (OLS / HC / CRV1) is linear in n. vce='conley' is the exception: it calls conley_vcov_matrix, which materialises several dense n x n float64 arrays (lat/lon differences, distances, the uniform kernel) -- ~0.8 GB at n=10,000, ~80 GB at n=100,000, ~157 GB at n=140,000. Prefer sp.conley (sparse cKDTree) above ~20,000 rows. Assumptions: Strict exogeneity conditional on the absorbed fixed effects; No perfect collinearity after FE absorption (within-transformation rank); Cluster structure for vcov={'CRV1': '...'} matches the relevant dependence. Pre-conditions: Data is a long-format DataFrame; FE columns are categorical or convertible; Every absorbed FE level has more than one observation (singleton dropping behaviour controlled by drop_singletons); Optional IV stage: instruments are at least as many as endogenous regressors. Failure modes: Singleton groups dropped warning -> Aggregate small categories or...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fml | Yes | A pyfixest-style formula. Examples: - ``"Y ~ X1 + X2"`` -- plain OLS - ``"Y ~ X1 | firm + year"`` -- two-way fixed effects - ``"Y ~ 1 | firm | X1 ~ Z1"`` -- IV with fixed effects - ``"Y ~ X1 | csw0(firm, year)"`` -- multiple estimations | |
| ssc | No | Small-sample correction via ``pyfixest.ssc()``. | |
| lean | No | If True, drop large intermediate arrays to save memory. | |
| seed | No | RNG seed for ``vce="wild"``. | |
| vcov | No | Variance-covariance estimator (``vce=`` is the canonical alias). - ``"iid"`` -- classical - ``"HC1"``, ``"HC2"``, ``"HC3"`` -- heteroskedasticity-robust - ``{"CRV1": "firm"}`` -- cluster-robust - ``{"CRV1": "firm + year"}`` -- two-way clustering - ``vce="CR2"`` / ``"CR3"`` / ``"jackknife"`` (with ``cluster=``) -- Pustejovsky-Tipton bias-reduced cluster-robust on the FE-absorbed within design; matches R ``clubSandwich::vcovCR(plm)``. - ``vce="wild"`` (with ``cluster=``) -- WCR wild cluster bootstrap (Cameron-Gelbach-Miller 2008); validated against Stata ``boottest``. - ``vce="conley"`` (with ``conley_lat=/conley_lon=/conley_cutoff=``) -- Conley spatial HAC (Stata ``acreg`` planar-distance convention). | |
| 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 | Cluster id column for the extended ``vce=`` menu; also a shorthand for one-way ``{"CRV1": cluster}``. | |
| weights | No | Column name for regression weights. | |
| fixef_rm | No | How to handle singleton fixed effects: ``"none"`` (keep) or ``"singleton"`` (drop). | none |
| 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_reps | No | Bootstrap replications for ``vce="wild"``. | |
| collin_tol | No | Collinearity tolerance. | |
| conley_lat | No | Coordinate columns (decimal degrees) for ``vce="conley"``. | |
| conley_lon | No | Coordinate columns (decimal degrees) for ``vce="conley"``. | |
| 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. | |
| wild_weight_type | No | Wild weight distribution (``"rademacher"``, ``"webb"``, ``"mammen"``). | rademacher |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||