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,
k_min = 0,
k_max = 5,
compute_varcov = "none",
by = NULL,
bname = NULL,
normalized = FALSE,
newnames = NULL
)
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. |
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. |
newnames
|
Optional. A list of new names for the output variables. ytildename is the name of the imputed outcome variable. Default is paste0(yname, “_tilde”) . yvarname is the name of the unit-level variance of the outcome variable. Default is paste0(yname, “_var”) . yvarrawname is the name of the raw unit-level variance of the outcome variable, which is the variance before subtracting the variance of the measurement error. Default is paste0(yname, “_varraw”) . yvarerrname is the name of the unit-level variance of the measurement error. Default is paste0(yname, “_varerr”) . ycovname is the name of the unit-level covariance of the outcome variable. Default is paste0(yname, “_cov”) . ycovrawname is the name of the raw unit-level covariance of the outcome variable, which is the covariance before subtracting the covariance of the measurement error. Default is paste0(yname, “_covraw”) . ycoverrname is the name of the unit-level covariance of the measurement error. Default is paste0(yname, “_coverr”) . kprimename is 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".
|
Value
A unitdid
class object.