This function runs the extended two-way fixed effects estimator (etwfe()
) on
simulated data. It is simply a wrapper for etwfe()
: it accepts an object of class
"FETWFE_simulated"
(produced by simulateData()
) and unpacks the necessary
components to pass to etwfe()
. So the outputs match etwfe()
, and the needed inputs
match their counterparts in etwfe()
.
etwfeWithSimulatedData(
simulated_obj,
verbose = FALSE,
alpha = 0.05,
add_ridge = FALSE
)
A named list with the following elements:
The estimated overall average treatment effect for a randomly selected treated unit.
A standard error for the ATT. If the Gram matrix is not invertible, this will be NA.
A named vector containing the estimated average treatment effects for each cohort.
A named vector containing the (asymptotically exact) standard errors for the estimated average treatment effects within each cohort.
A vector of the estimated probabilities of being in each
cohort conditional on being treated, which was used in calculating att_hat
.
If indep_counts
was provided, cohort_probs
was calculated from that;
otherwise, it was calculated from the counts of units in each treated
cohort in pdata
.
A dataframe displaying the cohort names,
average treatment effects, standard errors, and 1 - alpha
confidence
interval bounds.
The full vector of estimated coefficients.
The indices of beta_hat
corresponding to
the treatment effects for each cohort at each time.
The indices of beta_hat
corresponding to the
interactions between the treatment effects for each cohort at each time and
the covariates.
Either the provided sig_eps_sq
or
the estimated one, if a value wasn't provided.
Either
the provided sig_eps_c_sq
or the estimated one, if a value wasn't
provided.
The design matrix created containing all interactions, time and cohort dummies, etc.
The vector of
responses, containing nrow(X_ints)
entries.
The design matrix after applying the change in coordinates to fit the model and also multiplying on the left by the square root inverse of the estimated covariance matrix for each unit.
The final response after multiplying on the left by the square root inverse of the estimated covariance matrix for each unit.
The final number of units that were in the data set used for estimation (after any units may have been removed because they were treated in the first time period).
The number of time periods in the final data set.
The final number of treated cohorts that appear in the final data set.
The final number of covariates that appear in the final data set (after any covariates may have been removed because they contained missing values or all contained the same value for every unit).
The final number of columns in the full set of covariates used to estimate the model.
An object of class "FETWFE_simulated"
containing the simulated panel
data and design matrix.
Logical; if TRUE, more details on the progress of the function will be printed as the function executes. Default is FALSE.
Numeric; function will calculate (1 - alpha
) confidence intervals
for the cohort average treatment effects that will be returned in catt_df
.
(Optional.) Logical; if TRUE, adds a small amount of ridge regularization to the (untransformed) coefficients to stabilize estimation. Default is FALSE.
if (FALSE) {
# Generate coefficients
coefs <- genCoefs(R = 5, T = 30, d = 12, density = 0.1, eff_size = 2, seed = 123)
# Simulate data using the coefficients
sim_data <- simulateData(coefs, N = 120, sig_eps_sq = 5, sig_eps_c_sq = 5)
result <- etwfeWithSimulatedData(sim_data)
}
Run the code above in your browser using DataLab