| Title: | Intersection Difference-in-Differences |
|---|---|
| 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>. |
| Authors: | Eric Jamieson [aut, cre, cph] |
| Maintainer: | Eric Jamieson <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.6 |
| Built: | 2026-07-07 17:18:59 UTC |
| Source: | https://github.com/cran/didintrjl |
DiDIntObj
Extract coefficients from DiDIntObj
## S3 method for class 'DiDIntObj' coef(object, level = c("agg", "sub"), ...)## S3 method for class 'DiDIntObj' coef(object, level = c("agg", "sub"), ...)
object |
A |
level |
Specify either |
... |
other arguments |
A data frame of coefficient estimates
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/
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 )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 )
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 |
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/.
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.
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
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) }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) }
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.
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" )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" )
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 |
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/.
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.
Karim & Webb (2025). Good Controls Gone Bad: Difference-in-Differences with Covariates. https://arxiv.org/abs/2412.14447
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) }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) }
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.
didintrjl_ready()didintrjl_ready()
A single logical value: TRUE if Julia, JuliaConnectoR, and
DiDInt.jl (>= 0.9.6) are all available; FALSE otherwise.
DiDIntPlotObj
Plot method for DiDIntPlotObj
## S3 method for class 'DiDIntPlotObj' plot(x, y = NULL, ccc = "all", groupmin = 3, window = NULL, ...)## S3 method for class 'DiDIntPlotObj' plot(x, y = NULL, ccc = "all", groupmin = 3, window = NULL, ...)
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 |
A ggplot object showing either the event study plot or the
parallel trends plot.
DiDIntObj
Print method for DiDIntObj
## S3 method for class 'DiDIntObj' print(x, level = c("agg", "sub"), ...)## S3 method for class 'DiDIntObj' print(x, level = c("agg", "sub"), ...)
x |
A |
level |
Specify either |
... |
other arguments |
The DiDIntObj object, returned invisibly. Called
for its side effect of printing results to the console.
DiDIntObj
Summary method for DiDIntObj
## S3 method for class 'DiDIntObj' summary(object, level = c("all", "agg", "sub"), ...)## S3 method for class 'DiDIntObj' summary(object, level = c("all", "agg", "sub"), ...)
object |
A |
level |
Specify either |
... |
other arguments |
The DiDIntObj object, returned invisibly. Called
for its side effect of printing summary results to the console.