Skip to content

Instantly share code, notes, and snippets.

@s3alfisc
s3alfisc / vanilla_regression_benchmark.py
Last active January 11, 2025 15:12 — forked from aeturrell/vanilla_regression_benchmark.py
Self-contained benchmarking script for vanilla regressions with Pyfixest and Statsmodels
# /// script
# python = ">=3.10"
# dependencies = [
# "numpy>=1.21.0",
# "pandas>=1.3.0",
# "statsmodels>=0.13.0",
# "pyfixest>=0.11.0",
# "matplotlib>=3.4.0"
# ]
# ///
import pyfixest as pf
import pandas as pd
import numpy as np
n_workers = 100
n_firms = 50
n_time_periods = 10
worker_effects = np.random.normal(0, 1, n_workers)
firm_effects = np.random.normal(0, 1, n_firms)
@s3alfisc
s3alfisc / fixest-pyfixest-ses-defaults.qmd
Last active October 7, 2023 08:26
Fixest vs PyFixest Standard Errors
# Standard Error Defaults in `fixest` and `PyFixest`
`fixest` and `PyFixest` defaults match exactly - the only difference is that with fixed effects,
the `PyFixest` defaults set `ssc = ssc(adj = "nested")`, while `PyFixest` sets `ssc(adj = "none")`,
as "nested" is not yet implemented in `PyFixest`. Below are some examples:
## OLS without Fixed Effects
By default, both packages choose iid errors if no particular method for inference is specified.