Description Usage Arguments Value Treatment effect formula Default outcome Examples
Generate longitudinal data with staggered treatment
1 2 3 4 5 6 7 8 9 | generateDidData(
i,
t,
hdfe = TRUE,
control = TRUE,
attrition.rate = 0,
treatment = ~d * (k + 1),
ig = ~i%%2
)
|
i |
Numeric. Number of units |
t |
Numeric. Number of periods |
hdfe |
Logical. Should high dimensional fixed effect be added? |
control |
Logical. Should continuous control be added? |
attrition.rate |
Numerical. Default is 0. Probability of missing observation. |
treatment |
one sided formula, default is ~ d * (k + 1). See details. |
ig |
an optional one sided formula, default is |
a data.table with columns
i |
Unit identifier. |
t |
Calendar time. |
g |
Time of treatment. |
a |
Individual fixed effect. ~N(0,1) |
b |
Time fixed effect. ~N(0,1) |
x1 |
A continuous, normally distributed control. ~N(0,2) |
hdfe |
A random effect with {i}/50 modalities. ~ N(0,1) |
e |
Residual. ~ N(0,2) |
hdfefactor |
A fixed effect of size {i}/50. |
k |
Relative time to treatment. |
d |
Dummy variable defined as k >= 0 |
h |
Randomly generated variable at the level of the cohort. |
y |
Outcome. |
true_effect |
True average treatment effect on the treated. |
By default the treatment effect is ~ d * (k + 1)
where d
is an internal
dummy equal to one if observation is treated and k
is the relative time to
event. User can define its own formula to create complex treatment and test
the model effectiveness.
User has access to the following hidden variables:
h
: a cohort-wise randomly generated number
g
: Cohort identifier
a
: Individual fixed effect
b
: Time fixed effect
t
: Calendar time
ig
: a random unit invariant value in 0, 1, 2. Can be used to define heterogeneous effects.
The default data generating process is:
y ~ a + b + hdfe + 2*x1 + d * (k + 1) + e
Variable description is available in previous section.
1 2 | dt <- generateDidData(100,10)
head(dt)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.