View source: R/sensitivityresults.R
createSensitivityResults_relativeMagnitudes | R Documentation |
\Delta = \Delta^{RM}(Mbar)
, \Delta^{SDRM}(Mbar)
and their variants that incorporate shape or sign restrictions for a vector of possible Mbar values.
Constructs robust confidence intervals for \Delta = \Delta^{RM}(Mbar)
, \Delta^{SDRM}(Mbar)
and their variants that incorporate shape or sign restrictions for a vector of possible Mbar values. By default, the function constructs sensitivity results for \Delta^{RM}(Mbar)
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)
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 \Delta^{SDRM}
as the base choice of \Delta
. As discussed in Section 2.3.2 of Rambachan & Roth (2021), \Delta^{SDRM}
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.