Skip to content

Is it possible to define custom operators?  #177

@s3alfisc

Description

@s3alfisc

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 =)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions