satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.25k stars 903 forks source link

Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 4938, 4937 #4422

Closed KarolinaHelena closed 3 years ago

KarolinaHelena commented 3 years ago

Hi,

I'm trying to do a difference-in-difference analysis using the DID package from Callaway and Sant'Anna (2020). I have a panel data set and want to do conditional DID, and have therefore included some variables in xformula. However, when this is included I get the error: "Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 4938, 4937". In the data I have 4938 rows. Why might this issue arise and how do I solve it?

This only happens when I include the xformula, otherwise it doesn't.

mort70.2 <- att_gt(yname = "mortality70",
                   tname = "year",
                   idname = "muncode",
                   gname = "adoptionyear",
                   xformla = ~ lnetincome65 + shareunied + shareprivateemp  + shareimmigrants65plus + leftmajority +     Kommungruppkod + sharepopabove65 + ltotpop ,
                   data=Data,
                   panel=TRUE,
                   control_group="nevertreated",
                   bstrap=TRUE, #this has to be set when clusters happen
                   clustervars="muncode",
                   est_method = "dr")
KarolinaHelena commented 3 years ago

I'm new to GitHub so I don't know if this is the right place to direct this question and so on.

@pedrohcgs maybe this is something that you can help me with? Also thanks for a great paper and great did package! I have really enjoyed it and am trying to use it for my master thesis analysis in economics, as I have learned that TWFE is not a good option for my staggered DID analysis!

samuel-marsh commented 3 years ago

Hi,

I would suggest posting this question in the issues for the GitHub repo for the DID package https://github.com/bcallaway11/did since it is an issue using the package. This is the repository for the single cell genomics package Seurat.

Best, Sam

KarolinaHelena commented 3 years ago

Thank you!