insongkim / PanelMatch

113 stars 34 forks source link

Refactor internal usage of formula objects + parse_and_prep #68

Closed adamrauh closed 1 year ago

adamrauh commented 3 years ago

The parse_and_prep function could be written more efficiently. The internally defined lag function returns the results of an sapply call, which creates a data frame with some weird dimensions. The data frame looks normal upon inspection, but the dimensions are wrong -- I think it's creating some sort of nested list. I accidentally worked around this by converting everything to a matrix, but it needs a better solution.

My proposal is to have a small chunk of code parse the formula objects a little bit so that lag(..., 1:3) becomes something like lag(..., 1) + lag(..., 2) + lag(..., 3) internally, which should be a relatively easy and reasonable fix. Just filing this so I don't forget about the issue.

adamrauh commented 1 year ago

Upon review a few years later, I think it's ok. The dimensions of some objects are weird at times, but I tried a few solutions that I thought might be more intuitive, but that broke other code in surprising ways. It doesnt look like we are doing anything risky and every step of the code seems to be doing what it should be and generating sensible objects. I'm calling it fine.