Title: | Robust Inference in Difference-in-Differences and Event Study Designs |
---|---|
Description: | Provides functions to conduct robust inference in difference-in-differences and event study designs by implementing the methods developed in Rambachan & Roth (2023) <doi:10.1093/restud/rdad018>, "A More Credible Approach to Parallel Trends" [Previously titled "An Honest Approach..."]. Inference is conducted under a weaker version of the parallel trends assumption. Uniformly valid confidence sets are constructed based upon conditional confidence sets, fixed-length confidence sets and hybridized confidence sets. |
Authors: | Ashesh Rambachan [aut, cph, cre], Jonathan Roth [aut, cph] |
Maintainer: | Ashesh Rambachan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.6 |
Built: | 2025-02-10 04:14:46 UTC |
Source: | https://github.com/asheshrambachan/honestdid |
Creates a basis vector of length size
with a 1 in the index
position.
# Create the index basis vector in R^size basisVector(index, size)
# Create the index basis vector in R^size basisVector(index, size)
index |
The index at which there should be a one. Default equals one. |
size |
The length of the vector. Default equals one. |
Returns a basis vector of length size
with a 1 in the index
position.
# Create the first basis vector in R^2 basisVector(index = 1, size = 2) # Create the third basis vector in R^6 basisVector(index = 3, size = 6)
# Create the first basis vector in R^2 basisVector(index = 1, size = 2) # Create the third basis vector in R^6 basisVector(index = 3, size = 6)
This list contains the event study estimates from baseline event study specification on profits in Benzarti & Carloni (2019). See discussion in Section 6.1 of Rambachan & Roth (2021).
A list, containing 7 objects:
Vector of estimated event study coefficients.
Estimated variance-covariance matrix.
Vector that contains the time periods associated with the event study coefficients.
Reference period that is normalized to zero.
Vector containing elements of timeVec that correspond to the pre-periods.
Vector containing elements of timeVec that correspond to the post-periods.
.
Computes the conditional confidence set and hybridized confidence set for .
computeConditionalCS_DeltaRM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
computeConditionalCS_DeltaRM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
Mbar |
Tuning parameter Mbar for |
alpha |
Desired level of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set "LF" specifies the conditional least-favorable confidence set. The conditional FLCI hybrid confidence set is not available for |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If TRUE, function only returns the length of the robust confidence. If FALSE, function returns dataframe that contains a grid of possible parameter values and a vector of zeros and ones associated with each value in the grid (one denotes that the grid value lies in the confidence set and zero denotes that the grid value does not fall within the confidence set.) Default equals FALSE. |
postPeriodMomentsOnly |
Logical value. If TRUE, function excludes moments for |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA and sets grid upper bound to equal the upper bound of the identified set under parallel trends plus 20*standard deviation of the point estimate, l_vec'betahat. |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. |
seed |
Random seed for internal computations; included for reproducibility. |
If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for . The set
adds an additional sign restriction to
that restricts the sign of the bias to be either positive (
) or negative (
).
computeConditionalCS_DeltaRMB(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
computeConditionalCS_DeltaRMB(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
Mbar |
Tuning parameter Mbar for |
alpha |
Desired level of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set "LF" specifies the conditional least-favorable confidence set. The conditional FLCI hybrid confidence set is not available for |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If TRUE, function only returns the length of the robust confidence. If FALSE, function returns dataframe that contains a grid of possible parameter values and a vector of zeros and ones associated with each value in the grid (one denotes that the grid value lies in the confidence set and zero denotes that the grid value does not fall within the confidence set.) Default equals FALSE. |
biasDirection |
Specifies direction of bias restriction. If "positive", bias is restricted to be positive, |
postPeriodMomentsOnly |
Logical value. If TRUE, function excludes moments for |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA and sets grid upper bound to equal the upper bound of the identified set under parallel trends plus 20*standard deviation of the point estimate, l_vec'betahat. |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. |
seed |
Random seed for internal computations; included for reproducibility. |
If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for . The set
adds an additional shape restriction to
that restricts the underlying trend to be monotone. It may either be increasing (
) or decreasing (
).
computeConditionalCS_DeltaRMM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
computeConditionalCS_DeltaRMM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
Mbar |
Tuning parameter Mbar for |
alpha |
Desired level of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set "LF" specifies the conditional least-favorable confidence set. The conditional FLCI hybrid confidence set is not available for |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If TRUE, function only returns the length of the robust confidence. If FALSE, function returns dataframe that contains a grid of possible parameter values and a vector of zeros and ones associated with each value in the grid (one denotes that the grid value lies in the confidence set and zero denotes that the grid value does not fall within the confidence set.) Default equals FALSE. |
postPeriodMomentsOnly |
Logical value. If TRUE, function excludes moments for |
monotonicityDirection |
Specifies direction of monotonicity restriction. If "increasing", underlying trend specified to be increasing, |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA and sets grid upper bound to equal the upper bound of the identified set under parallel trends plus 20*standard deviation of the point estimate, l_vec'betahat. |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. |
seed |
Random seed for internal computations; included for reproducibility. |
If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for .
computeConditionalCS_DeltaSD(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), M = 0, alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints =10^3, grid.ub = NA, grid.lb = NA, seed = 0)
computeConditionalCS_DeltaSD(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), M = 0, alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints =10^3, grid.ub = NA, grid.lb = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
M |
Tuning parameter for |
alpha |
Desired size of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set, "FLCI" specifies the conditional FLCI confidence set and "LF" specifies the conditional least-favorable confidence set. Default equals "FLCI". |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If TRUE, function only returns the length of the robust confidence. If FALSE, function returns dataframe that contains a grid of possible parameter values and a vector of zeros and ones associated with each value in the grid (one denotes that the grid value lies in the confidence set and zero denotes that the grid value does not fall within the confidence set. Default equals FALSE.) |
postPeriodMomentsOnly |
Logical value. If TRUE, function excludes moments for |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA and sets grid upper bound to equal the upper bound of the identified set under parallel trends plus 20*standard deviation of the point estimate, l_vec'betahat. |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. |
seed |
Random seed for internal computations; included for reproducibility. |
If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for . The set
adds an additional sign restriction to
that restricts the sign of the bias to be either positive (
) or negative (
).
computeConditionalCS_DeltaSDB(betahat, sigma, numPrePeriods, numPostPeriods, M = 0, l_vec = .basisVector(index = 1, size=numPostPeriods), alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, gridPoints = 10^3, grid.lb = NA, grid.ub = NA, seed = 0)
computeConditionalCS_DeltaSDB(betahat, sigma, numPrePeriods, numPostPeriods, M = 0, l_vec = .basisVector(index = 1, size=numPostPeriods), alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, gridPoints = 10^3, grid.lb = NA, grid.ub = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
M |
Tuning parameter for |
alpha |
Desired size of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set, "FLCI" specifies the conditional FLCI confidence set and "LF" specifies the conditional least-favorable confidence set. Default equals "FLCI". |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If TRUE, function only returns the length of the robust confidence. If FALSE, function returns dataframe that contains a grid of possible parameter values and a vector of zeros and ones associated with each value in the grid (one denotes that the grid value lies in the confidence set and zero denotes that the grid value does not fall within the confidence set.) Default equals FALSE. |
biasDirection |
Specifies direction of bias restriction. If "positive", bias is restricted to be positive, |
postPeriodMomentsOnly |
Logical value. If TRUE, function excludes moments for |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA and sets grid upper bound to equal the upper bound of the identified set under parallel trends plus 20*standard deviation of the point estimate, l_vec'betahat. |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. |
seed |
Random seed for internal computations; included for reproducibility. |
If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for . The set
adds an additional shape restriction to
that restricts the underlying trend to be monotone. It may either be increasing (
) or decreasing (
).
computeConditionalCS_DeltaSDM(betahat, sigma, numPrePeriods, numPostPeriods, M = 0, l_vec = .basisVector(index = 1, size=numPostPeriods), alpha = 0.05, monotonicityDirection = "increasing", hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints = 10^3, grid.lb = NA, grid.ub = NA, seed = 0)
computeConditionalCS_DeltaSDM(betahat, sigma, numPrePeriods, numPostPeriods, M = 0, l_vec = .basisVector(index = 1, size=numPostPeriods), alpha = 0.05, monotonicityDirection = "increasing", hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints = 10^3, grid.lb = NA, grid.ub = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
M |
Tuning parameter for |
alpha |
Desired size of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set, "FLCI" specifies the conditional FLCI confidence set and "LF" specifies the conditional least-favorable confidence set. Default equals "FLCI". |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If TRUE, function only returns the length of the robust confidence. If FALSE, function returns dataframe that contains a grid of possible parameter values and a vector of zeros and ones associated with each value in the grid (one denotes that the grid value lies in the confidence set and zero denotes that the grid value does not fall within the confidence set.) Default equals FALSE. |
monotonicityDirection |
Specifies direction of monotonicity restriction. If "increasing", underlying trend specified to be increasing, |
postPeriodMomentsOnly |
Logical value. If TRUE, function excludes moments for |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA and sets grid upper bound to equal the upper bound of the identified set under parallel trends plus 20*standard deviation of the point estimate, l_vec'betahat. |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. |
seed |
Random seed for internal computations; included for reproducibility. |
If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for .
computeConditionalCS_DeltaSDRM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
computeConditionalCS_DeltaSDRM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. For this function, |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
Mbar |
Tuning parameter Mbar for |
alpha |
Desired level of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set "LF" specifies the conditional least-favorable confidence set. The conditional FLCI hybrid confidence set is not available for |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If |
postPeriodMomentsOnly |
Logical value. If |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals |
seed |
Random seed for internal computations; included for reproducibility. |
For the choice ,
numPrePeriods
must be greater than one. As discussed in Section 2.3.2 of Rambachan & Roth (2021), uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e.,
numPrePeriods
> 1).
If returnLength equals TRUE
, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE
, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for . The set
adds an additional sign restriction to
that restricts the sign of the bias to be either positive (
) or negative (
).
computeConditionalCS_DeltaSDRMB(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, biasDirection = "positive", gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
computeConditionalCS_DeltaSDRMB(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, biasDirection = "positive", gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. For this function, |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
Mbar |
Tuning parameter Mbar for |
alpha |
Desired level of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set "LF" specifies the conditional least-favorable confidence set. The conditional FLCI hybrid confidence set is not available for |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If |
biasDirection |
Specifies direction of bias restriction. If "positive", bias is restricted to be positive, |
postPeriodMomentsOnly |
Logical value. If |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals |
seed |
Random seed for internal computations; included for reproducibility. |
The choice adds an additional sign restriction to
that restricts the sign of the bias to be either positive (
) or negative (
). For this choice
,
numPrePeriods
must be greater than one. As discussed in Section 2.3.2 of Rambachan & Roth (2021), uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e.,
numPrePeriods
> 1).
If returnLength equals TRUE
, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE
, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the conditional confidence set and hybridized confidence set for . The set
adds an additional shape restriction to
that restricts the underlying trend to be monotone. It may either be increasing (
) or decreasing (
).
computeConditionalCS_DeltaSDRMM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
computeConditionalCS_DeltaSDRMM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. For this function, |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
Mbar |
Tuning parameter Mbar for |
alpha |
Desired level of the confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
hybrid_flag |
Flag for whether user wishes to compute a hybridized confidence set. "ARP" specifies the conditional confidence set "LF" specifies the conditional least-favorable confidence set. The conditional FLCI hybrid confidence set is not available for |
hybrid_kappa |
Desired first-stage size of hybridized confidence set. Only specify this value if the user wishes to compute a hybridized confidence set. Default equals alpha/10. If user specifies hybrid_flag = "ARP", set this value to NULL. |
returnLength |
Logical value. If TRUE, function only returns the length of the robust confidence. If FALSE, function returns dataframe that contains a grid of possible parameter values and a vector of zeros and ones associated with each value in the grid (one denotes that the grid value lies in the confidence set and zero denotes that the grid value does not fall within the confidence set.) Default equals FALSE. |
postPeriodMomentsOnly |
Logical value. If TRUE, function excludes moments for |
monotonicityDirection |
Specifies direction of monotonicity restriction. If "increasing", underlying trend specified to be increasing, |
gridPoints |
Number of grid points used in test inversion step. Default equals 1000. |
grid.ub |
Upper bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA and sets grid upper bound to equal the upper bound of the identified set under parallel trends plus 20*standard deviation of the point estimate, l_vec'betahat. |
grid.lb |
Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. |
seed |
Random seed for internal computations; included for reproducibility. |
The choice adds an additional shape restriction to
that restricts the underlying trend to be monotone. For this choice
,
numPrePeriods
must be greater than one. As discussed in Section 2.3.2 of Rambachan & Roth (2021), uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e.,
numPrePeriods
> 1).
If returnLength
equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength
equals FALSE, function returns a dataframe with columns
grid |
Vector of grid values used to construct the confidence interval by test inversion. |
accept |
Vector of zeros-ones associated with grid values, where one denotes a grid value that falls within the confidence interval and zero denotes a grid value that falls outside the confidence interval. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
Constructs original confidence interval for parameter of interest, theta = l_vec'tau using the user-specified estimated event study coefficients and variance-covariance matrix.
constructOriginalCS(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), alpha = 0.05)
constructOriginalCS(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), alpha = 0.05)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
alpha |
Desired size of the robust confidence sets. Default equals 0.05 (corresponding to 95% confidence interval) |
Returns a dataframe with columns
lb |
Lower bound of original confidence set (based on asymptotic normality). |
ub |
Upper bound of original confidence set (based on asymptotic normality). |
method |
Method for constructing confidence set; set to "Original". |
Delta |
The set Delta that was specified; set to NA. |
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> constructOriginalCS(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05)
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> constructOriginalCS(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05)
Constructs event study plot using the estimated event study coefficients and standard errors.
createEventStudyPlot(betahat, stdErrors = NULL, sigma = NULL, numPrePeriods, numPostPeriods, alpha = 0.05, timeVec, referencePeriod, useRelativeEventTime = FALSE)
createEventStudyPlot(betahat, stdErrors = NULL, sigma = NULL, numPrePeriods, numPostPeriods, alpha = 0.05, timeVec, referencePeriod, useRelativeEventTime = FALSE)
betahat |
Vector of estimated event study coefficients. |
stdErrors |
Vector of standard errors associated with the estimated event study coefficients. Default equals NULL. Either stdErrors or sigma must be specified by the user. If stdErrors is not specified but sigma is, the stdErrors are set to equal the square root of the diagonal elements of sigma. |
sigma |
Covariance matrix of event study coefficients. Default equals NULL. Either stdErrors or sigma must be specified by the user. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
alpha |
Desired size of confidence intervals. Default = 0.05. |
timeVec |
Vector that contains the time periods associated with the event study coefficients. This vector should not include the reference period that is normalized to zero. |
referencePeriod |
Scalar that contains the time period associated with the reference period. |
useRelativeEventTime |
Logical that specifies whether user would like the plot to be in relative event time (normalizes the reference period to be zero). Default equals FALSE. |
Returns ggplot object of the event study plot.
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> createEventStudyPlot(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05, timeVec = BCdata_EventStudy$timeVec, referencePeriod = BCdata_EventStudy$referencePeriod)
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> createEventStudyPlot(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05, timeVec = BCdata_EventStudy$timeVec, referencePeriod = BCdata_EventStudy$referencePeriod)
,
and
This function constructs sensitivity plots that examine how the robust confidence sets change as the parameter M varies for ,
and
. Similar plots are constructed in Section 6 of Rambachan & Roth (2021).
createSensitivityPlot(robustResults, originalResults, rescaleFactor = 1, maxM = Inf, add_xAxis = TRUE)
createSensitivityPlot(robustResults, originalResults, rescaleFactor = 1, maxM = Inf, add_xAxis = TRUE)
robustResults |
Dataframe that contains the upper/lower bounds of robust confidence sets for each choice of M. Contains columns: method – Method of constructing robust confidence set (e.g., "FLCI"), lb – Lower bound of robust confidence set, ub – Upper bound of robust confidence set, M – M values associated with each robust confidence set. |
originalResults |
Dataframe that contains the original confidence set for the parameter of interest. Contains columns: method – Method of constructing confidence set (e.g., "Original"), lb – Lower bound of confidence set, ub – Upper bound of confidence set. |
rescaleFactor |
Scalar that is used to rescale the user specified choices of M and the upper/lower bounds of the confidence sets. Default equals one. |
maxM |
Scalar that specifies the maximum M value to plot in the sensitivity plot. Default equals infinity (no truncation). |
add_xAxis |
Logical specifying whether to plot the x-axis in the sensitivity plot. Default equals TRUE. |
Returns ggplot object of the sensitivity plot.
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> robustResults <- createSensitivityResults(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) originalResults <- constructOriginalCS(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) createSensitivityPlot(robustResults, originalResults)
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> robustResults <- createSensitivityResults(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) originalResults <- constructOriginalCS(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) createSensitivityPlot(robustResults, originalResults)
,
and their variants that incorporate additional shape or sign restrictions.
This function constructs sensitivity plots that examine how the robust confidence sets change as the parameter Mbar varies for ,
and their variants that incorporate additional shape or sign restrictions. Similar plots are constructed in Section 6 of Rambachan & Roth (2021).
createSensitivityPlot_relativeMagnitudes(robustResults, originalResults, rescaleFactor = 1, maxMbar = Inf, add_xAxis = TRUE)
createSensitivityPlot_relativeMagnitudes(robustResults, originalResults, rescaleFactor = 1, maxMbar = Inf, add_xAxis = TRUE)
robustResults |
Dataframe that contains the upper/lower bounds of robust confidence sets for each choice of Mbar. Contains columns: method – Method of constructing robust confidence set, lb – Lower bound of robust confidence set, ub – Upper bound of robust confidence set, Mbar – M values associated with each robust confidence set. |
originalResults |
Dataframe that contains the original confidence set for the parameter of interest. Contains columns: method – Method of constructing confidence set (e.g., "Original"), lb – Lower bound of confidence set, ub – Upper bound of confidence set. |
rescaleFactor |
Scalar that is used to rescale the user specified choices of M and the upper/lower bounds of the confidence sets. Default equals one. |
maxMbar |
Scalar that specifies the maximum Mbar value to plot in the sensitivity plot. Default equals infinity (no truncation). |
add_xAxis |
Logical specifying whether to plot the x-axis in the sensitivity plot. Default equals TRUE. |
Returns ggplot object of the sensitivity plot.
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2019.
# Simple use case. For more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> kwargs <- list(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) robustResults <- do.call(createSensitivityResults_relativeMagnitudes, kwargs) originalResults <- do.call(constructOriginalCS, kwargs) createSensitivityPlot_relativeMagnitudes(robustResults, originalResults)
# Simple use case. For more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> kwargs <- list(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) robustResults <- do.call(createSensitivityResults_relativeMagnitudes, kwargs) originalResults <- do.call(constructOriginalCS, kwargs) createSensitivityPlot_relativeMagnitudes(robustResults, originalResults)
,
and
for vector of possible M values.
Constructs robust confidence intervals for a choice ,
and
for vector of possible M values. By default, the function constructs robust confidence intervals for
.
createSensitivityResults(betahat, sigma, numPrePeriods, numPostPeriods, method = NULL, Mvec = NULL, l_vec = .basisVector(index = 1, size = numPostPeriods), monotonicityDirection = NULL, biasDirection = NULL, alpha = 0.05, parallel = FALSE, seed = 0)
createSensitivityResults(betahat, sigma, numPrePeriods, numPostPeriods, method = NULL, Mvec = NULL, l_vec = .basisVector(index = 1, size = numPostPeriods), monotonicityDirection = NULL, biasDirection = NULL, alpha = 0.05, parallel = FALSE, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
method |
String that specifies the choice of method for constructing robust confidence intervals. This must be one of "FLCI", "Conditional", "C-F" (conditional FLCI hybrid), or "C-LF" (conditional least-favorable hybrid). Default equals NULL and the function automatically sets method based on the recommendations in Rambachan & Roth (2021) depending on the choice of Delta. If Delta = DeltaSD, default selects the FLCI. If Delta = DeltaSDB or DeltaSDM, default delects the conditional FLCI hybrid. |
Mvec |
Vector of M values for which the user wishes to construct robust confidence intervals. If NULL, the function constructs a grid of length 10 that starts at M = 0 and ends at M equal to the upper bound constructed from the pre-periods using the function DeltaSD_upperBound_Mpre if number of pre-periods > 1 or the standard deviation of the first pre-period coefficient if number of pre-periods = 1. Default equals null. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
biasDirection |
This must be specified if the user wishes to add an additional bias restriction to |
monotonicityDirection |
This must be specified if the user wishes to add an additional monotonicity restriction to |
alpha |
Desired size of the robust confidence sets. Default equals 0.05 (corresponding to 95% confidence interval) |
parallel |
Logical to indicate whether the user would like to construct the robust confidence intervals in parallel. This uses the Foreach package and doParallel package. Default equals FALSE. |
seed |
Random seed for internal computations; included for reproducibility. |
Returns a dataframe with columns
lb |
Lower bound of robust confidence sets. |
ub |
Upper bound of robust confidence sets. |
method |
Method for constructing robust confidence sets |
Delta |
The set Delta that was specified. |
M |
Values of M associated with each robust confidence set. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> createSensitivityResults(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05)
# Simple use case; for more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> createSensitivityResults(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05)
,
and their variants that incorporate shape or sign restrictions for a vector of possible Mbar values.
Constructs robust confidence intervals for ,
and their variants that incorporate shape or sign restrictions for a vector of possible Mbar values. By default, the function constructs sensitivity results for
and its variants. The confidence sets are constructed through test inversion.
createSensitivityResults_relativeMagnitudes(betahat, sigma, numPrePeriods, numPostPeriods, bound = "deviation from parallel trends", method = "C-LF", Mbarvec = NULL, l_vec = .basisVector(index = 1, size = numPostPeriods), monotonicityDirection = NULL, biasDirection = NULL, alpha = 0.05, gridPoints = 10^3, grid.ub = NA, grid.lb = NA, parallel = FALSE, seed = 0)
createSensitivityResults_relativeMagnitudes(betahat, sigma, numPrePeriods, numPostPeriods, bound = "deviation from parallel trends", method = "C-LF", Mbarvec = NULL, l_vec = .basisVector(index = 1, size = numPostPeriods), monotonicityDirection = NULL, biasDirection = NULL, alpha = 0.05, gridPoints = 10^3, grid.ub = NA, grid.lb = NA, parallel = FALSE, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. If user selects bound = "deviation from linear trends" ( |
numPostPeriods |
Number of post-periods. |
bound |
String that specifies the base choice of Delta (to which additional sign and shape restrictions will be incorporated if specified by the user). This must be either "deviation from parallel trends" or "deviation from linear trend". If bound equals "deviation from parallel trends", then the function will select |
method |
String that specifies the choice of method for constructing robust confidence intervals. This must be either "Conditional", or "C-LF" (conditional least-favorable hybrid). Default equals "C-LF" and the function automatically sets method to be "C-LF" based on the recommendations in Rambachan & Roth (2021). |
Mbarvec |
Vector of Mbar values for which the user wishes to construct robust confidence intervals. If NULL, the function constructs a grid of length 10 that starts at Mbar = 0 and ends at Mbar = 2. Default equals null. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
biasDirection |
This must be specified if the user wishes to add an additional bias restriction to base choice of Delta. If "positive", bias is restricted to be positive, delta >= 0. If "negative", bias is restricted to be negative, delta <= 0. Default equals NULL. |
monotonicityDirection |
This must be specified if the user wishes to add an additional monotonicity restriction to base choice of Delta. If "increasing", underlying trend specified to be increasing, |
alpha |
Desired size of the robust confidence sets. Default equals 0.05 (corresponding to 95% confidence interval) |
parallel |
Logical to indicate whether the user would like to construct the robust confidence intervals in parallel. This uses the Foreach package and doParallel package. Default equals FALSE. |
gridPoints |
Number of grid points used for the underlying test inversion. Default equals 1000. User may wish to change the number of grid points for computational reasons. |
grid.ub |
Upper bound of grid used for underlying test inversion. Default sets grid.ub to be equal to twenty times the standard deviation of the estimated target parameter, l_vec * betahat. User may wish to change the upper bound of the grid to suit their application. |
grid.lb |
Lower bound of grid used for underlying test inversion. Default sets grid.lb to be equal to negative twenty times the standard deviation of the estimated target parameter, l_vec * betahat. User may wish to change the lower bound of the grid to suit their application. |
seed |
Random seed for internal computations; included for reproducibility. |
Note: If the user specifies bound = "deviation from linear trends", then numPrePeriods must be greater than one. By specifying bound = "deviation from linear trends", then the function selects as the base choice of
. As discussed in Section 2.3.2 of Rambachan & Roth (2021),
uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e., numPrePeriods > 1).
Returns a dataframe with columns
lb |
Lower bound of robust confidence sets. |
ub |
Upper bound of robust confidence sets. |
method |
Method for constructing robust confidence sets |
Delta |
The set Delta that was specified. |
M |
Values of M associated with each robust confidence set. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
# Simple use case. For more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> kwargs <- list(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) do.call(createSensitivityResults_relativeMagnitudes, kwargs)
# Simple use case. For more detailed examples, # see <https://github.com/asheshrambachan/HonestDiD#honestdid> kwargs <- list(betahat = BCdata_EventStudy$betahat, sigma = BCdata_EventStudy$sigma, numPrePeriods = length(BCdata_EventStudy$prePeriodIndices), numPostPeriods = length(BCdata_EventStudy$postPeriodIndices), alpha = 0.05) do.call(createSensitivityResults_relativeMagnitudes, kwargs)
based on observed pre-period coefficients.
Constructs a lower bound for M using the observed pre-period coefficients. It constructs a one-sided confidence interval for the maximal second difference of the observed pre-period using the conditional test developed in Andrews, Roth & Pakes (2019). The number of pre-periods (not including the reference period) must be larger than or equal to two.
DeltaSD_lowerBound_Mpre(betahat, sigma, numPrePeriods, alpha = 0.05, grid.ub = NA, gridPoints = 1000)
DeltaSD_lowerBound_Mpre(betahat, sigma, numPrePeriods, alpha = 0.05, grid.ub = NA, gridPoints = 1000)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. Must be larger than or equal to two. |
alpha |
Desired size of the one-sided confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
grid.ub |
Upper bound of grid of values of M that is used to construct the confidence interval by test inversion. Default equals NA and the upper bound of the grid is set equal to three times the maximum standard error of the observed pre-period event-study coefficients. |
gridPoints |
Number of points to include in the grid that is used to construct the confidence interval by test inversion. Default equals 1000 points. |
Returns a scalar that equals the lower bound of a one-sided confidence interval for the maximal second difference of the observed pre-period coefficients.
Ashesh Rambachan
Andrews, Isaiah, Jonathan Roth and Ariel Pakes. "Inference for Linear Conditional Moment Inequalities." 2019. Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
based on observed pre-period coefficients.
Constructs an upper bound for M using the observed pre-period event study coefficients. This is constructed using (1-alpha) level one-sided upper confidence intervala for the second differences of the observed pre-period event study coefficients. The number of pre-periods (not including the reference period) must be larger than or equal to two.
DeltaSD_upperBound_Mpre(betahat, sigma, numPrePeriods, alpha = 0.05)
DeltaSD_upperBound_Mpre(betahat, sigma, numPrePeriods, alpha = 0.05)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. Must be larger than or equal to two. |
alpha |
Desired size of the one-sided confidence set. Default equals 0.05 (corresponding to 95% confidence interval) |
This function returns the maximum of the upper bounds of one-sided upper confidence intervals for the observed second differences of the pre-period event study coefficients.
Returns a scalar that equals the maximum of the upper bounds of one-sided upper confidence intervals for the observed second differences of the pre-period event study coefficients.
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
.
Computes the optimal FLCI for the scalar parameter of interest under .
findOptimalFLCI(betahat, sigma, M = 0, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), numPoints = 100, alpha = 0.05, seed = 0)
findOptimalFLCI(betahat, sigma, M = 0, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), numPoints = 100, alpha = 0.05, seed = 0)
betahat |
Vector of estimated event study coefficients. |
sigma |
Covariance matrix of event study coefficients. |
numPrePeriods |
Number of pre-periods. |
numPostPeriods |
Number of post-periods. |
l_vec |
Vector of length numPostPeriods that describes the scalar parameter of interest, theta = l_vec'tau. Default equals to first basis vector, (1, 0, ..., 0) |
M |
Tuning parameter for |
numPoints |
Number of possible values when optimizing the FLCI. Default equals 100. |
alpha |
Desired size of the FLCI. Default equals 0.05 (corresponding to 95% confidence interval) |
seed |
Random seed for internal computations; included for reproducibility. |
Returns a list containing items
FLCI |
Vector containing lower and upper bounds of optimal FLCI. |
optimalVec |
Vector of length numPrePeriods + numPostPeriods that contains the vector of coefficients associated with the optimal FLCI. |
optimalPrePeriodVec |
Vector of length numPrePeriods that contains the vector of coefficients for the optimal FLCI that are associated with the pre-period event study coefficients. |
optimalHalfLength |
A scalar that equals the half-length of the optimal FLCI. |
M |
Value of M at which the FLCI was computed. |
status |
Status of optimization. |
Ashesh Rambachan
Rambachan, Ashesh and Jonathan Roth. "An Honest Approach to Parallel Trends." 2021.
This list contains the event study estimates from the baseline female specification on employment in Lovenheim & Willen (2019). See discussion in Section 6.2 of Rambachan & Roth (2021).
A list, containing 7 objects:
Vector of estimated event study coefficients.
Estimated variance-covariance matrix.
Vector that contains the time periods associated with the event study coefficients.
Reference period that is normalized to zero.
Vector containing elements of timeVec that correspond to the pre-periods.
Vector containing elements of timeVec that correspond to the post-periods.
Vector of standard errors associated with estimated event study coefficients