grantmcdermott / etwfe

Extended two-way fixed effects
https://grantmcdermott.com/etwfe/
Other
50 stars 11 forks source link

Error: Class of the `.Dtreat` variable is class is not supported. #32

Closed romkhun closed 1 year ago

romkhun commented 1 year ago

Hi Grant,

Thanks for making this package. I would like to use this package on my Ubuntu workstation, but it gives me the following error.

image

I have tried reinstalling R and this package, but the same error occurs. Would there be an easy way to fix it?

image

Thanks again for the package, and I would very much appreciate your help on this issue. Many thanks in advance!

grantmcdermott commented 1 year ago

Hmmm, that definitely doesn't seem right. Can you please paste your sessionInfo()results below.

Also, which version of Ubuntu are you on?

romkhun commented 1 year ago

Thanks for the quick response, Grant. The sessionInfo() is below. I am using Ubuntu 22.10.

image

grantmcdermott commented 1 year ago

Sorry @romkhun, I'm genuinely stumped for the moment. I can see that you have the latest version of the core packages (namely, etwfe and marginaleffects). Let me ask this: Did you install the CRAN version of etwfe or the development version?

romkhun commented 1 year ago

Actually, I tried both.

install.packages("etwfe", repos = "https://grantmcdermott.r-universe.dev") install.packages("etwfe")

Neither works for me.

grantmcdermott commented 1 year ago

Hi again @romkhun. So I just tested the package/example on an Ubuntu docker image and everything works as expected. Combined with the fact that all of my CI tests are passing (incl. two on Ubuntu), I think we can surmise that the problem has something to do with your particular system. Sorry, I know that's not helpful but I really can't reproduce this behaviour.

At this point, my next and possibly only best guess is that you have some kind of weird namespace clash. From your sessionInfo I can see that you have a bunch of other packages loaded. Can you please try in a fresh session with only etwfe loaded?

grantmcdermott commented 1 year ago

@romkhun See my previous comment. Please let me know if it works in a fresh session without a bunch of other libraries loaded at the same time. Otherwise, I'll have to close since I can't reproduce.

grantmcdermott commented 1 year ago

Closing since I cannot reproduce this behaviour.

jsr-p commented 7 months ago

I got the same bug using R version 4.2.3 and the newest versions of etwfe and marginaleffects. The issue seems to be with the insight package and the way it gets the modeldata from fixest; this is done inside the marginaleffects package. The returned data is passed through to get_contrast_data here and because the .Dtreat variable is not to be found inside modeldata the error is raised. Upgrading from insight version 0.19.1 to 0.19.7 solved it for me.

grantmcdermott commented 7 months ago

Upgrading from insight version 0.19.1 to 0.19.7 solved it for me.

Thanks @jsr-p, that's useful to know. I can easily add insight >= 0.19.7 to etwfe's Imports. But I'm wondering if this version requirement should rather be done upstream in marginaleffects, since this behavior may affect other similar cases. Any thoughts @vincentarelbundock?

vincentarelbundock commented 7 months ago

Sure, no problem: https://github.com/vincentarelbundock/marginaleffects/commit/42c49a119cf02b00af1076d29788bce064d5a0c0