-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from marcelortizv/even-faster-did
Even faster did
- Loading branch information
Showing
22 changed files
with
2,756 additions
and
1,236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: did | ||
Title: Treatment Effects with Multiple Periods and Groups | ||
Version: 2.2.0.908 | ||
Version: 2.2.1.909 | ||
Authors@R: c(person("Brantly", "Callaway", email = "[email protected]", role = c("aut", "cre")), person("Pedro H. C.", "Sant'Anna", email="[email protected]", role = c("aut"))) | ||
URL: https://bcallaway11.github.io/did/, https://github.com/bcallaway11/did/ | ||
Description: The standard Difference-in-Differences (DID) setup involves two periods and two groups -- a treated group and untreated group. Many applications of DID methods involve more than two periods and have individuals that are treated at different points in time. This package contains tools for computing average treatment effect parameters in Difference in Differences setups with more than two periods and with variation in treatment timing using the methods developed in Callaway and Sant'Anna (2021) <doi:10.1016/j.jeconom.2020.12.001>. The main parameters are group-time average treatment effects which are the average treatment effect for a particular group at a a particular time. These can be aggregated into a fewer number of treatment effect parameters, and the package deals with the cases where there is selective treatment timing, dynamic treatment effects, calendar time effects, or combinations of these. There are also functions for testing the Difference in Differences assumption, and plotting group-time average treatment effects. | ||
|
@@ -19,8 +19,9 @@ Imports: | |
generics, | ||
methods, | ||
tidyr, | ||
parglm (>= 0.1.7), | ||
data.table (>= 1.15.4), | ||
parglm (>= 0.1.7) | ||
dreamerr (>= 1.4.0) | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.2 | ||
VignetteBuilder: knitr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#' @title DIDparams | ||
#' | ||
#' @description Object to hold DiD parameters that are passed across functions | ||
#' | ||
#' @inheritParams att_gt2 | ||
#' @inheritParams pre_process_did2 | ||
#' @param did_tensor list of outcome tensors that are used in the estimation | ||
#' @param args list of arguments that are used in the estimation | ||
#' @noRd | ||
DIDparams2 <- function(did_tensors, args, call=NULL) { | ||
# get the arguments from args | ||
yname <- args$yname | ||
tname <- args$tname | ||
idname <- args$idname | ||
gname <- args$gname | ||
xformla <- args$xformla # formula of covariates | ||
panel <- args$panel | ||
est_method <- args$est_method | ||
bstrap <- args$bstrap | ||
biters <- args$biters | ||
cband <- args$cband | ||
anticipation <- args$anticipation | ||
control_group <- args$control_group | ||
allow_unbalanced_panel <- args$allow_unbalanced_panel | ||
weightsname <- args$weightsname | ||
base_period <- args$base_period | ||
clustervars <- args$clustervars | ||
cores <- args$cores | ||
pl <- args$pl | ||
print_details <- args$print_details | ||
faster_mode <- args$faster_mode | ||
alp <- args$alp | ||
true_repeated_cross_sections <- args$true_repeated_cross_sections | ||
time_periods_count <- args$time_periods_count | ||
time_periods <- args$time_periods | ||
treated_groups_count <- args$treated_groups_count | ||
treated_groups <- args$treated_groups | ||
id_count <- args$id_count | ||
|
||
# get the arguments from did_tensors | ||
outcomes_tensor <- did_tensors$outcomes_tensor | ||
data <- did_tensors$data | ||
time_invariant_data <- did_tensors$time_invariant_data | ||
cohort_counts <- did_tensors$cohort_counts | ||
period_counts <- did_tensors$period_counts | ||
crosstable_counts <- did_tensors$crosstable_counts | ||
covariates <- did_tensors$covariates # matrix of covariates | ||
cluster_vector <- did_tensors$cluster | ||
weights_vector <- did_tensors$weights | ||
|
||
|
||
out <- list(yname=yname, | ||
tname=tname, | ||
idname=idname, | ||
gname=gname, | ||
xformla=xformla, | ||
panel=panel, | ||
est_method=est_method, | ||
bstrap=bstrap, | ||
biters=biters, | ||
cband=cband, | ||
anticipation=anticipation, | ||
control_group=control_group, | ||
allow_unbalanced_panel=allow_unbalanced_panel, | ||
weightsname=weightsname, | ||
base_period=base_period, | ||
clustervars=clustervars, | ||
cores=cores, | ||
pl = pl, | ||
print_details=print_details, | ||
faster_mode=faster_mode, | ||
alp=alp, | ||
true_repeated_cross_sections=true_repeated_cross_sections, | ||
time_periods_count=time_periods_count, | ||
time_periods=time_periods, | ||
treated_groups_count=treated_groups_count, | ||
treated_groups=treated_groups, | ||
id_count=id_count, | ||
outcomes_tensor=outcomes_tensor, | ||
data=data, | ||
time_invariant_data=time_invariant_data, | ||
cohort_counts=cohort_counts, | ||
period_counts=period_counts, | ||
crosstable_counts=crosstable_counts, | ||
covariates=covariates, | ||
cluster_vector=cluster_vector, | ||
weights_vector=weights_vector, | ||
call=call) | ||
class(out) <- "DIDparams" | ||
return(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.