Simulates a dataset for a Difference-in-Differences analysis with various customizable options.
sim_did(
sample_size,
time_period,
untreated_prop = 0.3,
epsilon_size = 0.001,
cov = "no",
hetero = "all",
second_outcome = FALSE,
second_cov = FALSE,
vary_cov = FALSE,
na = "none",
balanced = TRUE,
seed = NA,
stratify = FALSE,
treatment_assign = "latent",
second_cohort = FALSE,
confound_ratio = 1,
second_het = "all"
)A list containing the simulated dataset (dt) and the treatment effect values (att).
The number of units in the dataset.
The number of time periods in the dataset.
The proportion of untreated units.
The standard deviation for the error term in potential outcomes.
The type of covariate to include ("no", "int", or "cont").
The type of heterogeneity in treatment effects ("all" or "dynamic").
Whether to include a second outcome variable.
Whether to include a second covariate.
include time-varying covariates
Whether to generate missing data ("none", "y", "x", or "both").
Whether to balance the dataset by random sampling.
Seed for random number generation.
Whether to stratify the dataset based on a binary covariate.
The method for treatment assignment ("latent" or "uniform").
include confounding events
extent of event confoundedness
heterogeneity of the second event
# Simulate a DiD dataset with default settings
data <- sim_did(sample_size = 100, time_period = 5)
Run the code above in your browser using DataLab