Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Error in aggregate.data.frame(as.data.frame(x), ...): arguments must have same length, with att_gt function

Writer Matthew Barrera

I am new to econometrics and I am trying to perform a Group-Time Average Treatment Effects by using the function att_gt() from the did() library in R studio. I am trying to estimate the effect of mergers on R&D expenditures. I have a treatment group with mergers happening in 2014, 2015 and 2016 and a control group with no mergers happening. For both treatment and control I have data either for 2010-2018 or 2011-2019.

I get the following error : Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length

I created a subset with only the variables I am using in the code and made sure that they are all the same length. I also replaced all NAs with 0. However, I still get the same error. Does anybody have an idea what could be going wrong here?

This is my data

This is the code that I am using:

out <- att_gt(yname = "RD_Expense", gname = "treatment_year", idname = "Globa_Company_Key", tname = "Date_Year", xformla = ~SIC4 + ISO_Country_Code, allow_unbalanced_panel = TRUE, data = Mergers_dataset, )
summary(out)

I am trying to run this code because I have 3 treatment periods and I cannot think of aanother way to perform difference-in-differences. If anyone has other suggestions that would be appreciated.

1 Related questions 0 Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length 0 Error in table: all arguments must have the same length 12 Error in aggregate.data.frame : arguments must have same length Related questions 0 Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length 0 Error in table: all arguments must have the same length 12 Error in aggregate.data.frame : arguments must have same length 911 data.table vs dplyr: can one do something well the other can't or does poorly? 2 SummaryBy - "arguments must have same length" 2 R - complete.cases not all arguments have the same length 0 Error: Arguments 'event.e' and 'subgroup' must have the same length 262 How can I plot two histograms together in R? 14 'x' and 'w' must have same length - error in weighted.mean.default Load 6 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.