`R/twfe_did_rc.R`

`twfe_did_rc.Rd`

`twfe_did_rc`

is used to compute linear two-way fixed effects estimators for the ATT
in difference-in-differences (DiD) setups with stationary repeated cross-sectional data. As illustrated
by Sant'Anna and Zhao (2020),this estimator generally do not recover the ATT. We encourage empiricists
to adopt alternative specifications.

```
twfe_did_rc(
y,
post,
D,
covariates = NULL,
i.weights = NULL,
boot = FALSE,
boot.type = "weighted",
nboot = NULL,
inffunc = FALSE
)
```

- y
An \(n\) x \(1\) vector of outcomes from the both pre and post-treatment periods.

- post
An \(n\) x \(1\) vector of Post-Treatment dummies (post = 1 if observation belongs to post-treatment period, and post = 0 if observation belongs to pre-treatment period.)

- D
An \(n\) x \(1\) vector of Group indicators (=1 if observation is treated in the post-treatment period, =0 otherwise).

- covariates
An \(n\) x \(k\) matrix of covariates to be used in the regression estimation. We will always include an intercept.

- i.weights
An \(n\) x \(1\) vector of weights to be used. If NULL, then every observation has the same weights. The weights are normalized and therefore enforced to have mean 1 across all observations.

- boot
Logical argument to whether bootstrap should be used for inference. Default is FALSE.

- boot.type
Type of bootstrap to be performed (not relevant if

`boot = FALSE`

). Options are "weighted" and "multiplier". If`boot = TRUE`

, default is "weighted".- nboot
Number of bootstrap repetitions (not relevant if

`boot = FALSE`

). Default is 999.- inffunc
Logical argument to whether influence function should be returned. Default is FALSE.

A list containing the following components:

- ATT
The TWFE DiD point estimate

- se
The TWFE DiD standard error

- uci
Estimate of the upper bound of a 95% CI for the TWFE parameter.

- lci
Estimate of the lower bound of a 95% CI for the TWFE parameter.

- boots
All Bootstrap draws of the ATT, in case bootstrap was used to conduct inference. Default is NULL

- att.inf.func
Estimate of the influence function. Default is NULL

```
# use the simulated data provided in the package
covX = as.matrix(sim_rc[,5:8])
# Implement TWFE DiD estimator (you probably should consider something else....)
twfe_did_rc(y = sim_rc$y, post = sim_rc$post, D = sim_rc$d,
covariates= covX)
#> $ATT
#> dd:post
#> -25.43961
#>
#> $se
#> [1] 3.710505
#>
#> $uci
#> dd:post
#> -18.16702
#>
#> $lci
#> dd:post
#> -32.7122
#>
#> $boots
#> NULL
#>
#> $att.inf.func
#> NULL
#>
```