A function estimates unit-level difference-in-differences
Description
A function estimates unit-level difference-in-differences
Usage
unitdid(
data,
yname,
iname,
tname,
ename,
first_stage = NULL,
wname = NULL,
ytildename = NULL,
yvarname = NULL,
ycovname = NULL,
kprimename = "kprime",
k_min = 0,
k_max = 5,
compute_varcov = "none",
by = NULL,
bname = NULL,
normalized = FALSE
)
Arguments
data
|
The dataframe containing all the variables |
yname
|
Outcome variable |
iname
|
Unit identifier |
tname
|
Time variable |
ename
|
Event timing variable |
first_stage
|
Formula for Y(0). Formula follows fixest::feols . If not specified, unit (iname ) and time (tname ) fixed effects will be used.
|
wname
|
Optional. The name of the weight variable. |
ytildename
|
Optional. The name of the imputed outcome variable. If not provided, the function will use paste0(yname, “_tilde”) .
|
yvarname
|
Optional. The name of the unit-level variance of the outcome variable. If not provided, the function will use paste0(yname, “_var”) .
|
ycovname
|
Optional. The name of the unit-level covariance of the outcome variable. If not provided, the function will use paste0(yname, “_cov”) .
|
kprimename
|
Optional. The name of the relative time to treatment. This is used for the second column name of the relative time of the unit-level covariance estimation. Default is "kprime". |
k_min
|
Relative time to treatment at which treatment starts. Default is 0. |
k_max
|
Relative time to treatment at which treatment ends. Default is 5. |
compute_varcov
|
One of c("none", "var", "cov") and Default is "none". If "var", the function will estimate the unit-level variance of the outcome variable. If "cov", the function will estimate the unit-level covariance of the outcome variable for each pair within k_min:k_max .
|
by
|
A character vector of variables to estimate separately by. Default is NULL. |
bname
|
Birth year variable. Default is NULL. Necessary to aggregate the estimates by age at event. |
normalized
|
Logical. If TRUE, the function will normalize the outcome variable scale. Default is FALSE. |
Value
A unitdid
class object.