Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect date labels and se calculation issue #123

Open
madridista25 opened this issue Apr 18, 2024 · 1 comment
Open

Incorrect date labels and se calculation issue #123

madridista25 opened this issue Apr 18, 2024 · 1 comment

Comments

@madridista25
Copy link

I'm doing SDID Estimator with R using Panel Data. I have historical data with the following form :

df1920trCORN
# A tibble: 192 × 7
   MONTH               CITY        PRODUCT RECEIPTS SHIPMENTS INDIVIDU  TREATMENT
   <dttm>              <chr>       <chr>      <dbl>     <dbl> <chr>         <dbl>
 1 1924-01-01 00:00:00 Chicago     CORN     7572000   4871000 Chicago_…         0
 2 1924-01-01 00:00:00 Duluth      CORN      549327         0 Duluth_C…         0
 3 1924-01-01 00:00:00 Milwaukee   CORN     1111560    981273 Milwauke…         0
 4 1924-01-01 00:00:00 Minneapolis CORN     1398940   1150010 Minneapo…         0
 5 1924-02-01 00:00:00 Chicago     CORN    13424000   4680000 Chicago_…         0
 6 1924-02-01 00:00:00 Duluth      CORN     2109283         0 Duluth_C…         0
 7 1924-02-01 00:00:00 Milwaukee   CORN     3362300   1003363 Milwauke…         0
 8 1924-02-01 00:00:00 Minneapolis CORN     3186480   1636480 Minneapo…         0
 9 1924-03-01 00:00:00 Chicago     CORN    12570000   5737000 Chicago_…         0
10 1924-03-01 00:00:00 Duluth      CORN     2637099         0 Duluth_C…         0

I'm using synthdid library to perform an econometric analysis. TREATMENT is a dummy variable (0 for non-treated observations, 1 for treated observations) My code is this:

setup = panel.matrices(as.data.frame(as_tibble(df1920trCORN)), unit=2, time=1, outcome=4,
                       treatment=7)

tau.hat = synthdid_estimate(setup$Y, setup$N0, setup$T0)
se = sqrt(vcov(tau.hat, method='placebo'))
sprintf('point estimate: %1.2f', tau.hat)
sprintf('95%% CI (%1.2f, %1.2f)', tau.hat - 1.96 * se, tau.hat + 1.96 * se)
plot(tau.hat)+
  labs(title="SDID Estimate", subtitle="Corn : 1920's", x="Date", y="Value")+
  theme_clean()

The function works perfectly but my date (period) labels are incorrect. In the plot, i have this result :
corn3

The date labels are in float format while in my data i have date with Date format. The result of the model is also misformatted for the dates

$estimate
[1] -5300965

$se
     [,1]
[1,]   NA

$controls
            estimate 1
Minneapolis      0.425
Milwaukee        0.378
Duluth           0.197

$periods
            estimate 1
-1391212800      0.465
-1446508800      0.318
-1388534400      0.131

$dimensions
          N1           N0 N0.effective           T1           T0 T0.effective 
       1.000        3.000        2.760       23.000       25.000        2.928 

Also, i don't have the standard error of the estimator.
Can you help me to solve the date problem and the standard error issue ?
Regards,
Constantin

@davidahirshberg
Copy link
Collaborator

Re the date thing, it's hard to tell what's going on with just print output. You may want to try creating your date column exactly like in the example here and doing that after conversion from tibble to dataframe.

By default, we don't return standard error estimates when there's only one treated unit. To get one, we have to use a method that isn't particularly trustworthy. But if you want to do that, say synthdid_estimate(setup$Y, setup$N0, setup$T0)pass se.method='placebo'). See here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants