Skip to content

Commit

Permalink
pte2 renamed pte and default, removed old version of pte, updated doc…
Browse files Browse the repository at this point in the history
…umentation and testing, and now passing check
  • Loading branch information
bcallaway11 committed Jan 31, 2025
1 parent 43a3a6a commit 6c1c8f0
Show file tree
Hide file tree
Showing 81 changed files with 539 additions and 2,297 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export(attgt_if)
export(attgt_noif)
export(attgt_pte_aggregations)
export(compute.pte)
export(compute.pte2)
export(crit_val_checks)
export(did_attgt)
export(dose_obj)
Expand All @@ -28,8 +27,9 @@ export(mboot2)
export(overall_weights)
export(panel_empirical_bootstrap)
export(process_att_gt)
export(process_dose_gt)
export(pte)
export(pte2)
export(pte_aggte)
export(pte_attgt)
export(pte_default)
export(pte_dose_results)
Expand Down
6 changes: 4 additions & 2 deletions R/attgt_functions.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' @title did_attgt
#' @title Difference-in-differences estimates of ATT(g,t), given a group g and
#' time period t.
#'
#' @description Takes a "local" data.frame and computes
#' an estimate of a group time average treatment effect
Expand Down Expand Up @@ -65,7 +66,8 @@ did_attgt <- function(gt_data, xformula = ~1, ...) {
}


#' @title pte_attgt
#' @title A flexible way to estimate ATT(g,t) using difference-in-differences or
#' lagged outcome unconfoundedness, for a particular group and time period
#'
#' @description `pte_attgt` takes a "local" data.frame and computes
#' an estimate of a group time average treatment effect
Expand Down
24 changes: 15 additions & 9 deletions R/classes.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' @title group_time_att
#' @title Class that holds causal effect parameter estimates across
#' timing groups and time periods
#'
#' @description group_time_att class
#'
Expand Down Expand Up @@ -131,7 +132,8 @@ print.group_time_att <- function(x, ...) {
}


#' @title pte_results
#' @title Class for holding overall results with a staggered treatment,
#' including an overall ATT and an event study
#'
#' @description class for holding pte results
#'
Expand Down Expand Up @@ -160,7 +162,7 @@ pte_results <- function(att_gt,

#' @title summary.pte_results
#'
#' @description A function to summarize \code{pte} results.
#' @description A function to summarize `ptetools` results.
#'
#' @param object an \code{pte_results} object
#' @param ... other arguments
Expand Down Expand Up @@ -289,7 +291,8 @@ print.summary.pte_results <- function(x, ...) {
cat("\n\n")
}

#' @title attgt_if
#' @title Class for holding returns from group-time specific estimates
#' in settings when an influence function is returned
#'
#' @description Class for holding group-time average treatment effects
#' along with their influence function
Expand All @@ -312,7 +315,8 @@ attgt_if <- function(attgt, inf_func, extra_gt_returns = NULL) {
out
}

#' @title attgt_noif
#' @title Class for holding returns from group-time specific estimates
#' in settings when an influence function is not returned
#'
#' @description Class for holding group-time average treatment effects
#' which don't include influence functions
Expand All @@ -329,7 +333,8 @@ attgt_noif <- function(attgt, extra_gt_returns = NULL) {
}


#' @title gt_data_frame
#' @title Checks if data satisfies criteria to be used in internal
#' `ptetools` functions
#'
#' @description function to take in a data.frame, check if it has the right
#' columns to be used to calculate a group-time average treatment effect,
Expand All @@ -354,9 +359,9 @@ gt_data_frame <- function(data) {
data
}

#' @title pte_emp_boot
#' @title Class to hold empirical bootstrap results
#'
#' @title Class for holding \code{pte} empirical bootstrap results
#' @description Class for holding `ptetools` empirical bootstrap results
#'
#' @param attgt_results \code{data.frame} holding attgt results
#' @param overall_results \code{data.frame} holding overall results
Expand Down Expand Up @@ -471,14 +476,15 @@ summary.pte_emp_boot <- function(object, ...) {
}


#' @title pte_dose_results
#' @title Class for holding results with a continuous treatment
#'
#' @description class for holding pte results
#'
#' @param att_gt attgt results
#' @param dose vector of doses
#' @param att_d ATT(d) for each value of `dose`
#' @param acrt_d ACRT(d) for each value of `dose`
#' @param ptep a `pte_params` object
#'
#' @export
pte_dose_results <- function(att_gt,
Expand Down
2 changes: 1 addition & 1 deletion R/empirical_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @description Computes empirical bootstrap pointwise standard errors
#'
#' @inheritParams compute.pte
#' @inheritParams pte2
#' @inheritParams pte
#' @inheritParams attgt_if
#' @param attgt.list list of attgt results from \code{compute.pte}
#'
Expand Down
9 changes: 6 additions & 3 deletions R/ggpte.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#' @title ggpte
#' @title The main plotting function in the `ptetools` package. It plots
#' event studies.
#'
#' @description Simple event study plots for panel treatment effects
#' @description Simple event study plots for panel treatment effects. This
#' function is generic enough that most packages that otherwise use
#' the `ptetools` package can call it directly to plot an event study.
#'
#' @param pte_results A \code{pte_results} object
#'
Expand All @@ -19,7 +22,7 @@ ggpte <- function(pte_results) {
}


#' @title ggpte_cont
#' @title Plots dose-specific results in applications with a continuous treatment
#'
#' @description a function for plotting results in applications with a continuous treatment
#'
Expand Down
18 changes: 17 additions & 1 deletion R/process_dose_gt.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#' @title Processes results from each group and time period in settings
#' with a continuous treatment.
#'
#' @description After computing results for each group and time period,
#' `process_dose_gt` combines/averages them into overall effects and/or
#' dose specific effects. This is generic code that can be used
#' from different ways of estimating causal effects across different
#' timing groups and periods in a previous step.
#'
#' @inheritParams process_att_gt
#' @inheritParams pte_results
#'
#' @param gt_results list of group-time specific results
#' @param ... extra arguments
#'
#' @export
process_dose_gt <- function(gt_results, ptep, ...) {
# make the call to att, to get same format of results
att_gt <- process_att_gt(gt_results, ptep)
Expand Down Expand Up @@ -108,7 +124,7 @@ process_dose_gt <- function(gt_results, ptep, ...) {
)
}

#' @title dose_obj
#' @title An object that holds results when there is a continuous treatment
#'
#' @description Holds results from computing dose-specific treatment effects
#' with a continuous treatment
Expand Down
Loading

0 comments on commit 6c1c8f0

Please sign in to comment.