chaisemartinPackages / did_multiplegt_dyn

|| Stata | R || Estimation of event-study Difference-in-Difference (DID) estimators in designs with multiple groups and periods, and with a potentially non-binary treatment that may increase or decrease multiple times.
38 stars 8 forks source link

R: error when running `did_multiplegt_old` with `trends_nonparam` #90

Closed MatthieuStigler closed 4 weeks ago

MatthieuStigler commented 1 month ago

I am seeing two errors when using did_multiplegt_old with trends_nonparam, not sure what is going on?

Thanks!

library(DIDmultiplegt)
if(!require(multiDiff)) remotes::install_github("MatthieuStigler/multiDiff", upgrade = "never")
#> Loading required package: multiDiff

data(GentzkowData)

GentzkowData$st_factor <- factor(GentzkowData$st)
DiDM <- did_multiplegt(mode = "old", GentzkowData, Y="prestout", G="cnty90", T="year", D="numdailies",
                       trends_nonparam ="st")
#> Error in str2lang(x): <text>:2:0: unexpected end of input
#> 1: diff_Y ~ 
#>    ^

DiDM <- did_multiplegt(mode = "old", GentzkowData, Y="prestout", G="cnty90", T="year", D="numdailies",
                       trends_nonparam ="st_factor")
#> Warning: There were 16872 warnings in `summarise()`.
#> The first warning was:
#> ℹ In argument: `Vtrends = (function (x, ...) ...`.
#> ℹ In group 1: `G = 1005` and `T = 1868`.
#> Caused by warning in `mean.default()`:
#> ! argument is not numeric or logical: returning NA
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 16871 remaining warnings.

Created on 2024-10-14 with reprex v2.1.1

chaisemartinPackages commented 1 month ago

Dear Matthieu,

In general, the fix is to use the newest version of the command, which also features the _trendsnonparam option.

Best, Romain

MatthieuStigler commented 4 weeks ago

ok, thanks!