fixest icon indicating copy to clipboard operation
fixest copied to clipboard

Keep track of origin variable in fml for simplifying etable variables naming

Open sondalex opened this issue 3 years ago • 0 comments

Feature request

It could be useful to keep track of transformations in formulas fed to fixest models in the form of a map (origin-transformed), in order to simplify renaming of variables reported in etable.

Example: Imagine independent variable age which we lag in a model :

y ~ 1 + l(age, 1)  | time + individual

Currently, in my current knowledge of fixest library, we need to use function setFixest_dict with argument c("l(age, 1)", = "Age" ) in order to rename age variable, but it could be easier for users to just use something like: setFixest_dict("age",="Age", map_non_transformed=TRUE).

When constructing a formula programmatically with lots of transformations, such a feature could be a time saver.

Although, users can build map table from new names to labels table programmatically with a pretty straightforward algorithm:

  • Map manually origin variable names to labels --> list(age="Age")
  • Create map of origin variables to transformed variable using pattern matching --> list(age="l(age, 1)")
  • Based on origin variables as a common key for two previous maps, build a tables, which can then be used by setFixest_dict --> c("l(age, 1)"="Age") --> setFixest_dict(c("l(age, 1)"="Age")) , implementing such a feature on fixest's formula parser side would be less error-prone, particularly less prone to false positives.

sondalex avatar Sep 11 '22 10:09 sondalex