benbhansen-stats / propertee

Prognostic Regression Offsets with Propagation of ERrors, for Treatment Effect Estimation (IES R305D210029).
https://benbhansen-stats.github.io/propertee/
Other
2 stars 1 forks source link

current status of absorb #108

Closed josherrickson closed 1 year ago

josherrickson commented 1 year ago

I'm getting ready to head out of town for a few days so just documenting my current status on absorb to get back into when I return.

Current issue is with subset. Problem: When to subset? One of the first things I do is evaluate $weights and $offset to avoid scoping issues, but these don't account for the $subset (in a direct lm() call, I believe subsetting happens during the model.frame call in which said model.frame already has offset/weights included). If I subset too early, that breaks things elsewhere that is expecting an unsubsetted data.

Potential solutions: 1) Subset data immediately and figure out a way to handle it going forward. May require adding a subset= argument to weights and cov_adj(). This also might be problematic with regards to obtaining the data post-estimation. 2) Restructure the whole function to generate a model.frame immediately then pass that around. Not sure how this will play with existing architecture like .get_data_from_model. 3) Ignore subsetting until the final lm. I think this has the most promise. I can strip out the $subset piece of the call as I hack around the calls, then add it just prior to evaluating the final lm().

(One point where this is causing issue - model.matrix.default does not support an na.action= argument. model.matrix.lm DOES support the na.action= argument but does not appear to support subset=.)

josherrickson commented 1 year ago

Solved this. The absorb branch is now (almost) fully working!

The remaining errors in the tests are all in test.SandwichLayerVariance.R or the SandwichLayer stuff of tests.DirectAdjusted.R and almost all in the .get_b* functions, which are being deprecated. I'm going to hold off debugging those until @jwasserman2's branch gets brought in.

I've merged in main which brought in a few more problems related to SandwichLayer, but again I suspect that these will be fixed (or made irrelevant).