Type: | Package |
Title: | Equivalence Testing Functions |
Version: | 0.1.1 |
Maintainer: | Jack Fitzgerald <j.f.fitzgerald@vu.nl> |
Description: | Contains several functions for equivalence testing and practical significance testing. First, the tsti() command provides an automatic computation of three-sided testing results for a given estimate, standard error, and region of practical equivalence. For details, see Goeman, Solari, & Stijnen (2010) <doi:10.1002/sim.4002> and Isager & Fitzgerald (2024) <doi:10.31234/osf.io/8y925>. Second, the lddtest() command performs logarithmic density discontinuity equivalence testing for regression discontinuity designs. For reference, see Fitzgerald (2025) <doi:10.31222/osf.io/2dgrp_v1>. |
License: | CC BY 4.0 |
Encoding: | UTF-8 |
URL: | https://github.com/jack-fitzgerald/eqtesting |
BugReports: | https://github.com/jack-fitzgerald/eqtesting/issues |
Imports: | data.table, graphics, stats |
NeedsCompilation: | no |
Packaged: | 2025-07-28 08:51:40 UTC; jackfitzgerald |
Author: | Jack Fitzgerald [aut, cre], Peder Isager [ctb] |
Repository: | CRAN |
Date/Publication: | 2025-07-28 11:10:02 UTC |
Logarithmic density discontinuity equivalence tests for regression discontinuity designs
Description
lddtest performs logarithmic density discontinuity equivalence tests (Fitzgerald 2024) for regression discontinuity designs. lddtest requires that the user specify a running variable, a cutoff point (where treatment kicks in when the running variable crosses that cutoff), and a maximal acceptable ratio between running variable density estimates to the left and right of the cutoff, beneath which the discontinuity would be deemed to be practically equivalent to zero. Once that maximal acceptable ratio is specified, the command utilizes the rdd package coding of DCdensity (Dimmery 2016), itself a McCrary (2008) density test, to estimate the logarithmic density discontinuity in the running variable at the cutoff. Thereafter, lddtest uses a two one-sided tests approach to assess whether the density discontinuity in the running variable at the cutoff is significantly bounded beneath the maximal acceptable ratio.
Usage
lddtest(runvar, data, cutpoint, epsilon, alpha = 0.05, cluster = "", bootstrap = FALSE,
breps = 1000, bin = NULL, bw = NULL, verbose = FALSE, plot = TRUE)
Arguments
runvar |
The running variable. Required. Must be a single string denoting the column of the data containing the running variable. |
data |
The dataset. Required. Must be a data.frame object. |
cutpoint |
The cutoff designating the value of the running variable at which treatment kicks in. Required. Scalar. |
epsilon |
Maximal acceptable ratio between running variable density estimates to the left and right of the cutoff. Required. Scalar, strictly greater than 1. |
alpha |
Statistical significance level. Optional, defaults to 0.05. Scalar, strictly between zero and one. |
cluster |
Clustering variable. Optional, defaults to an empty string. If specified, must be a single string denoting the column of the data containing the clustering variable. |
bootstrap |
Indicates whether bootstrap inference should be conducted. Optional, defaults to TRUE. Boolean. Automatically set to TRUE if a cluster variable is specified. |
breps |
Number of bootstrap replications. Optional, defaults to 1000. Scalar. If you specify breps, then you must also set bootstrap to TRUE. |
bin |
Bin width. Optional. See the help guide to DCdensity for more information. |
bw |
Bandwidth. Optional. See the help guide to DCdensity for more information. |
verbose |
Indicator for whether you wish to see verbose diagnostics displayed. Optional. Boolean, defaults to FALSE. |
plot |
Indicator for whether you wish for DCdensity to produce a plot. Optional. Boolean, defaults to TRUE. |
Value
test |
data.frame showing the testing bounds, the logarithmic density discontinuity estimate and its standard error, equivalence confidence interval bounds, and test statistics from the equivalence test. |
conclusion |
String detailing the conclusion that can be derived from the equivalence test. |
boot_estimates |
Vector containing the bootstrap estimates. Empty if no bootstrap procedure is performed. |
Running this code automatically prints a citation disclaimer.
Author(s)
Jack Fitzgerald, Vrije Universiteit Amsterdam and Tinbergen Institute
References
Cattaneo, M. D., Frandsen, B. R., & Titiunik, R. (2015). Randomization inference in the regression discontinuity design: An application to party advantages in the U.S. Senate. Journal of Causal Inference 3(1), 1-24. Dimmery, D. (2016). rdd: Regression discontinuity designs. https://doi.org/10.32614/CRAN.package.rdd. Fitzgerald, J. (2025). Manipulation tests in regression discontinuity design: The need for equivalence testing. MetaArXiv. https://doi.org/10.31222/osf.io/2dgrp_v1. McCrary, J. (2008). Manipulation of the running variable in the regression discontinuity design: A density test. Journal of Econometrics 142(2), 698-714.
Examples
#Load replication data from Cattaneo, Frandsen, & Titiunik (2015)
data = read.csv(paste0("https://raw.githubusercontent.com/",
"rdpackages-replication/CIT_2024_CUP/refs/heads/main/CIT_2024_CUP_locrand.csv"))
#Run the logarithmic density discontinuity equivalence test on
#lagged Democratic vote shares at the 50% victory cutoff
lddtest("demvoteshlag1", data, 50, 1.5)
Function to perform the three-sided testing (TST) procedure (Goeman, Solari, and Stijnen 2010) for a given estimate, and compute relevant confidence intervals for that estimate.
Description
tst performs the three-sided testing (TST) procedure (Goeman, Solari, and Stijnen 2010) for a given estimate. tst requires that the user specify an estimate, its standard error, and a region of practical equivalence (ROPE), within which the estimate would be deemed to be practically equivalent to zero. Once the ROPE is specified, the TST procedure combines a two one-sided tests (TOST) procedure testing whether the estimate is bounded in the ROPE with two further one-sided tests assessing whether the estimate is bounded outside the ROPE.
Usage
tst(estimate, se, ROPE, df = NA, alpha = 0.05, plot = TRUE)
Arguments
estimate |
The estimate of interest. Numeric scalar. |
se |
The standard error of the estimate of interest. Numeric scalar, strictly greater than zero. |
ROPE |
The ROPE. Can either be a single numeric scalar (interpreted as the length of a symmetric ROPE around zero) or a vector of two different numeric scalars (interpreted as the bounds of the ROPE; in this case one must be >= 0 and one must be <= 0). |
df |
Degrees of freedom. Numeric scalar, strictly greater than zero (if provided). If not provided, asymptotically approximate ECIs, ROSEs, and TST results are reported. If provided, exact ECIs, ROSEs, and TST results are reported. |
alpha |
Statistical significance level. Numeric scalar, strictly between zero and one. Defaults to 0.05. |
plot |
Indicates whether a plot with equivalence, classical, and TST confidence intervals should be shown alongside the estimate and the ROPE bounds. Logical, defaults to TRUE. |
Value
bounds |
3x2 data.frame showing the bounds of the (1 - alpha) TST confidence interval (to be used for reporting the estimate's precision), classic confidence interval, and equivalence confidence interval (the latter two of which are to be used for reaching conclusions about the estimate's practical significance). |
test |
3x5 data.frame showing the ROPE, test statistics, and p-values for each of the three tests in the TST procedure, as well as which of the three tests is relevant. |
conclusion |
String detailing the practical significance conclusion that can be reached about the estimate. |
Running this code automatically prints which test was employed (asymptotically approximate or exact) as well as a citation disclaimer.
Author(s)
Jack Fitzgerald, Vrije Universiteit Amsterdam and Tinbergen Institute
References
Fitzgerald, J. (2025). "The Need for Equivalence Testing in Economics". MetaArXiv, https://doi.org/10.31222/osf.io/d7sqr_v1. Goeman, J. J., Solari, A., and Stijnen, T. (2010). "Three-sided hypothesis testing: Simultaneous testing of superiority, equivalence and inferiority." Statistics in Medicine 29(20), 2117-2125. Isager, P. & Fitzgerald, J. (2024). "Three-Sided Testing to Establish Practical Significance: A Tutorial." PsyArXiv, https://doi.org/10.31234/osf.io/8y925.
Examples
tst(1, 2, 3)