| Title: | Intersection Difference-in-Differences |
| Version: | 0.2.6 |
| Description: | A wrapper for the Julia package 'DiDInt.jl' https://ebjamieson97.github.io/DiDInt.jl/stable/ which implements intersection difference-in-differences (DID-INT), a method developed by Karim & Webb (2025) <doi:10.48550/arXiv.2412.14447>. Allows for unbiased estimation of the average effect of treatment on the treated (ATT) in cases when the common causal covariates assumption is violated. Also computes p-values for the ATT via the randomization inference procedure described in MacKinnon and Webb (2020) <doi:10.1016/j.jeconom.2020.04.024>. |
| License: | MIT + file LICENSE |
| Depends: | R (≥ 3.4.0) |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| SystemRequirements: | Julia (>= 1.10), DiDInt.jl |
| BugReports: | https://github.com/ebjamieson97/didintrjl/issues |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| URL: | https://ebjamieson97.github.io/didintrjl/, https://github.com/ebjamieson97/undidR |
| Config/testthat/edition: | 3 |
| Imports: | JuliaConnectoR, ggplot2, rlang |
| NeedsCompilation: | no |
| Packaged: | 2026-07-02 00:39:26 UTC; Eric Bruce Jamieson |
| Author: | Eric Jamieson [aut, cre, cph] |
| Maintainer: | Eric Jamieson <ericbrucejamieson@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-07 09:50:02 UTC |
didintrjl: Intersection Difference-in-Differences
Description
An R wrapper for the Julia package DiDInt.jl, implementing intersection difference-in-differences (DID-INT).
Details
Implements intersection difference-in-differences (DID-INT), a method developed by Karim and Webb (2025) that allows for unbiased estimation of the average effect of treatment on the treated (ATT) in settings where the common causal covariates (CCC) assumption is violated. Supports common or staggered adoption and the inclusion of covariates whose effects on the outcome of interest may vary by state, time, or both. The package interfaces with the Julia package DiDInt.jl via JuliaConnectoR.
Estimation
-
didint- Estimates the ATT, returning aDiDIntObjwithprint(),summary(), andcoef()methods.
Plotting
-
didint_plot- Produces parallel trends or event study plots, returning aDiDIntPlotObjwith aplot()method.
Author(s)
Eric B. Jamieson
See Also
Useful links:
Report bugs at https://github.com/ebjamieson97/didintrjl/issues
Extract coefficients from DiDIntObj
Description
Extract coefficients from DiDIntObj
Usage
## S3 method for class 'DiDIntObj'
coef(object, level = c("agg", "sub"), ...)
Arguments
object |
A |
level |
Specify either |
... |
other arguments |
Value
A data frame of coefficient estimates
Estimate the ATT using DID-INT
Description
didint() estimates the average effect of treatment on the treated (ATT)
using intersection difference-in-differences developped by Karim & Webb
(2025). The method adjusts for covariates that may vary across states,
over time, or jointly by state and time. This function is an R wrapper
around the Julia implementation provided in the DiDInt.jl package.
For more details on the didintrjl wrapper, visit the didintrjl
documentation site: https://ebjamieson97.github.io/didintrjl/. For more
details on the backend implementation, see:
https://ebjamieson97.github.io/DiDInt.jl/stable/
Usage
didint(
outcome,
state,
time,
data,
gvar = NULL,
treated_states = NULL,
treatment_times = NULL,
date_format = NULL,
covariates = NULL,
ccc = "int",
agg = "cohort",
weighting = "both",
ref = NULL,
freq = NULL,
freq_multiplier = 1,
start_date = NULL,
end_date = NULL,
nperm = 999,
verbose = TRUE,
seed = sample.int(1e+06, 1),
notyet = NULL,
hc = "hc1",
truejack = FALSE,
edgecase = FALSE
)
Arguments
outcome |
A string giving the column name of the outcome variable. |
state |
A string giving the column identifying states. The state column should be a character column. |
time |
A string giving the column identifying dates. |
data |
A data frame containing the variables used for estimation. |
gvar |
String giving the column that indicates first treatment time for
each state. Use either this option or the combination of |
treated_states |
Character values specifying the treated state(s). |
treatment_times |
Specify the treated_states using strings, numbers,
or Dates, corresponding to |
date_format |
Optional string specifying the input date format
when dates are supplied as character strings. Applies to |
covariates |
Optional string or vector of strings specifying covariates to include. |
ccc |
A string specifying the DID-INT specification.
One of |
agg |
A string indicating the aggregation method.
One of |
weighting |
Weighting scheme to use.
One of |
ref |
Optional named list indicating the reference category for categorical covariates. |
freq |
Optional string specifying the period length for staggered
adoption. One of |
freq_multiplier |
Integer multiplier for |
start_date |
Optional earliest date to retain in the data. |
end_date |
Optional latest date to retain in the data. |
nperm |
Number of permutations for randomization inference. Default is 999. |
verbose |
Logical value, if |
seed |
Integer seed for randomization inference. |
notyet |
Logical value if |
hc |
Heteroskedasticity-consistent covariance matrix estimator.
One of |
truejack |
Logical value, if |
edgecase |
Logical value, if |
Details
The arguments treated_states and treatment_times must be supplied such
that their ordering corresponds with one another. That is, the first
element of treated_states refers to the state treated at the
date given by the first element of treatment_times, and so on.
Dates can be entered as strings, numbers, or Date objects.
When character strings are supplied, the input format must be
specified via the date_format argument (e.g. "yyyy-mm-dd").
Period grids for staggered adoption are constructed automatically,
based on the inputted data. Otherwise, the period grid can be created
manually using the arguments freq, freq_multiplier, start_date,
and end_date. More information on this process can be seen on the DiDInt.jl
documentation site: https://ebjamieson97.github.io/DiDInt.jl/stable/.
Value
An object of class DiDIntObj, a list containing the aggregate
results, sub-aggregate results, and
model specifications. Has associated
print.DiDIntObj, summary.DiDIntObj, and
coef.DiDIntObj methods.
References
Karim & Webb (2025). Good Controls Gone Bad: Difference-in-Differences with Covariates. https://arxiv.org/abs/2412.14447
MacKinnon & Webb (2020). Randomization inference for difference-in-differences with few treated clusters. doi:10.1016/j.jeconom.2020.04.024
Examples
if (Sys.getenv("NOT_CRAN") == "true" && didintrjl_ready()) {
file_path <- system.file("extdata", "merit.csv", package = "didintrjl")
df <- utils::read.csv(file_path)
res <- didint("coll", "state", "year", df, verbose = FALSE,
treated_states = c(71, 58, 64, 59, 85, 57, 72, 61, 34, 88), nperm = 399,
treatment_times = c(1991, 1993, 1996, 1997, 1997, 1998, 1998, 1999, 2000, 2000))
summary(res)
}
Make event study or parallel trends plots
Description
didint_plot() produces either event study plots or parallel trends plots
depending on what is specified via the event argument. The parallel trends
plots, as well as the event study plots, are created using the means
residualized by covariates under different model specifications that account
for different violations of the common causal covaraites (CCC) assumptions.
Usage
didint_plot(
outcome,
state,
time,
data,
gvar = NULL,
treated_states = NULL,
treatment_times = NULL,
date_format = NULL,
covariates = NULL,
ref = NULL,
ccc = "all",
event = FALSE,
weights = TRUE,
ci = 0.95,
freq = NULL,
freq_multiplier = 1,
start_date = NULL,
end_date = NULL,
hc = "hc1"
)
Arguments
outcome |
A string giving the column name of the outcome variable. |
state |
A string giving the column identifying states. The state column should be a character column. |
time |
A string giving the column identifying dates. |
data |
A data frame containing the variables used for estimation. |
gvar |
String giving the column that indicates first treatment time for
each state. Use either this option or the combination of |
treated_states |
Character values specifying the treated state(s). |
treatment_times |
Specify the treated_states using strings, numbers,
or Dates, corresponding to |
date_format |
Optional string specifying the input date format
when dates are supplied as character strings. Applies to |
covariates |
Optional string or vector of strings specifying covariates to include. |
ref |
Optional named list indicating the reference category for categorical covariates. |
ccc |
A string specifying the DID-INT specification.
Any combination of |
event |
A logical value used to specify if event study plots should be
made ( |
weights |
A logical value, if |
ci |
A number between 0 and 1 used to specify the size of the confidence bands. |
freq |
Optional string specifying the period length for staggered
adoption. One of |
freq_multiplier |
Integer multiplier for |
start_date |
Optional earliest date to retain in the data. |
end_date |
Optional latest date to retain in the data. |
hc |
Heteroskedasticity-consistent covariance matrix estimator.
One of |
Details
The arguments treated_states and treatment_times must be supplied such
that their ordering corresponds with one another. That is, the first
element of treated_states refers to the state treated at the
date given by the first element of treatment_times, and so on.
Dates can be entered as strings, numbers, or Date objects.
When character strings are supplied, the input format must be
specified via the date_format argument (e.g. "yyyy-mm-dd").
Period grids are constructed automatically, based on the inputted data
Otherwise, the period grid can be created manually using the arguments
freq, freq_multiplier, start_date, end_date. More information
on this process can be seen on the didintrjl documentation site:
https://ebjamieson97.github.io/didintrjl/.
Value
An object of class DiDIntPlotObj, a list containing the
parallel trends data or event study data (if event is set to TRUE)
and the name of the outcome variable. Has an associated
plot.DiDIntPlotObj method for producing event study
or parallel trends plots.
References
Karim & Webb (2025). Good Controls Gone Bad: Difference-in-Differences with Covariates. https://arxiv.org/abs/2412.14447
Examples
if (Sys.getenv("NOT_CRAN") == "true" && didintrjl_ready()) {
file_path <- system.file("extdata", "merit.csv", package = "didintrjl")
df <- utils::read.csv(file_path)
res_event <- didint_plot(
"coll", "state", "year", df, event = TRUE,
treated_states = c(71, 58, 64, 59, 85, 57, 72, 61, 34, 88),
treatment_times = c(1991, 1993, 1996, 1997, 1997, 1998, 1998, 1999,
2000, 2000),
covariates = c("asian", "black", "male")
)
plot(res_event)
}
Check if didintrjl is ready to go
Description
Checks whether Julia is set up correctly via JuliaConnectoR and the
DiDInt.jl package (version >= 0.9.6) is available. Used to guard
examples and tests that require a live Julia session.
Usage
didintrjl_ready()
Value
A single logical value: TRUE if Julia, JuliaConnectoR, and
DiDInt.jl (>= 0.9.6) are all available; FALSE otherwise.
Plot method for DiDIntPlotObj
Description
Plot method for DiDIntPlotObj
Usage
## S3 method for class 'DiDIntPlotObj'
plot(x, y = NULL, ccc = "all", groupmin = 3, window = NULL, ...)
Arguments
x |
A |
y |
|
ccc |
Specify which |
groupmin |
The minimum number of states used to compute a point on
the event study for which the confidence band should be shown. Defaults
to |
window |
Either |
... |
other arguments |
Value
A ggplot object showing either the event study plot or the
parallel trends plot.
Print method for DiDIntObj
Description
Print method for DiDIntObj
Usage
## S3 method for class 'DiDIntObj'
print(x, level = c("agg", "sub"), ...)
Arguments
x |
A |
level |
Specify either |
... |
other arguments |
Value
The DiDIntObj object, returned invisibly. Called
for its side effect of printing results to the console.
Summary method for DiDIntObj
Description
Summary method for DiDIntObj
Usage
## S3 method for class 'DiDIntObj'
summary(object, level = c("all", "agg", "sub"), ...)
Arguments
object |
A |
level |
Specify either |
... |
other arguments |
Value
The DiDIntObj object, returned invisibly. Called
for its side effect of printing summary results to the console.