Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

New (optional) demeaning backend via `within`

Aperta
#714 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start by reading the AbsoringLS backend and the linked within solver documentation to understand the existing demeaning path and the proposed solver. The issue does not specify integration details or tests; done would mean an agreed, optional backend is implemented and validated against the existing behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi @bashtage,

Over the last couple of months, we (mostly @schroedk) have spent quite a bit of time developing a faster demeaning algorithm for fixed effects regression that works particularly well for poorly-connected fixed effects (as e.g. in worker firm panels with little mobility). The core idea is to replace the diagonal preconditioner that linearmodels current LSMR implementation uses with an additive Schwarz preconditioner.

For some fixed effects structures, this new preconditioner works much better than diagonal LSMR:

Image

We have Python bindings published to PyPi as within_py that has a pretty simple API. Here is how you'd fit a simple FWL problem:

beta_true = np.array([1.0, -2.0, 0.5])
X = np.random.randn(n, 3)
y = X @ beta_true + np.random.randn(n)

result = solve_batch(fe, np.column_stack([y, X]))
y_tilde, X_tilde = result.demeaned[:, 0], result.demeaned[:, 1:]
beta_hat = np.linalg.lstsq(X_tilde, y_tilde, rcond=None)[0]
print(np.round(beta_hat, 4))  # [ 0.9982 -2.006   0.5005]

If you are curious how the solver works, we have written up details here and here.

Would you be interested to try this out as a second, optional solver for the AbsoringLS backend? If yes, I'd set up a draft PR in the next days / weeks.

Best, Alex

Lingua principale
Python
Stelle
1.1k
Fork
203
Merge medio
3h 26m
PR unite (30g)
115

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bashtage/linearmodels

Tutte le issue di bashtage/linearmodels

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.