py-econometrics / pyfixest

Fast High-Dimensional Fixed Effects Regression in Python following fixest-syntax
https://py-econometrics.github.io/pyfixest/pyfixest.html
MIT License
117 stars 27 forks source link

Ritest: Implement class agnostic function with numpy API #493

Open s3alfisc opened 3 weeks ago

s3alfisc commented 3 weeks ago

Context

Currently, all code for randomization inference lives in pyfixest/estimation/ritest.py. There is no user facing ritest function - instead, users have to call the .ritest() method to run randomization inference.

It would be cool to design a user facing API to run randomization inference that does not depend on information encoded in PyFixest objects, i.e. that works without passing a Feols or Fepois object to it.

Down the road, this will allow for a ritest method for a numpy API to Feols, see #464 for details.

Additionally, this will potentially allow to "outsource" the ritest functionality to a standalone package for randomization inference not only for objects from PyFixest, but potentially also from statsmodels or other packages. wildboottest is an example for such a package.

To do

Define and implement a user facing function ritest() with a numpy API

def ritest(X: np.ndarray, Y:np.ndarray, D:np.ndarray, rng: np.random.Generator, reps: int, choose_algorithm: str, ...):
      ...

that does not depend on information encoded in a Feols object. Refactor the ritest methods of Feols and associated functions in ritest.py to be compatible & to call the newly implemented ritest function.