-
Notifications
You must be signed in to change notification settings - Fork 32
Is it possible to define custom operators? #177
Description
Hi @matthewwardrop,
For pyfixest, @Wenzhi-Ding and I are currently discussing to add more syntactic formula sugar. For example, the original R package comes with a custom operator for interacting variables i() that slightly differs from C() as it allows to "drop" reference level columns from the model matrix, or operators for multiple estimation, which I have implemented in a very clunky and ad hoc way in pyfixest's FormulaParser. Eventually I'd like to revisit this part of the code (hopefully rather sooner than later as I am really not too proud) and am wondering if it is possible to easily integrate new "formula operators"? There are some hints in the docs and codebase that suggest that this might not be an impossible task 😄
As a more concrete example, would it be possible to e.g. introduce a new operator varlist that would evaluate
model_matrix("Y ~ varlist(X*))", data)to Y ~ X1 + X2 + ... + Xk for all k variables in data that start with X by ourselves without "ad hoc" formula parsing on our end? Or would you recommend that we should stick with "ad hoc formula parsing"?
Please feel free to just tell me to take a closer look at the docs if appropriate =)