Skip to content

Commit

Permalink
add website, update citation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bcallaway11 committed Jan 31, 2025
1 parent 213c648 commit 4363c18
Show file tree
Hide file tree
Showing 86 changed files with 3,382 additions and 1,048 deletions.
55 changes: 0 additions & 55 deletions .github/workflows/update-citation-cff.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/update-citation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update Citation Files

on:
push:
paths:
- "DESCRIPTION"
workflow_dispatch:

jobs:
update-citation:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up R
uses: r-lib/actions/setup-r@v2

- name: Install dependencies
run: |
Rscript -e 'install.packages(c("usethis", "cffr", "desc"))'
- name: Update inst/CITATION
run: |
Rscript -e '
library(desc);
d <- desc::desc_get();
citation_text <- sprintf("citHeader(\"To cite this package, use:\")\n\nbibentry(\n bibtype = \"Manual\",\n title = \"%s\",\n author = %s,\n year = \"%s\",\n note = \"R package version %s\",\n url = \"%s\"\n)",
d["Title"], d["Authors@R"], format(Sys.Date(), "%Y"), d["Version"], d["URL"]);
writeLines(citation_text, "inst/CITATION")'
- name: Update CITATION.cff
run: |
Rscript -e 'cffr::cff_write()'
- name: Commit and Push if Changed
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add inst/CITATION CITATION.cff
git commit -m "Auto-update citation files" || echo "No changes to commit"
git push
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: ptetools
Title: Panel Treatment Effects Tools
Version: 0.0.1
Version: 1.0.0
Authors@R:
person(given = "Brantly",
family = "Callaway",
role = c("aut", "cre"),
email = "[email protected]")
URL: https://github.com/bcallaway11/pte
URL: https://github.com/bcallaway11/ptetools
Description: This is fairly generic code for estimating treatment effects with panel data. This is useful code in my own work and will perhaps be useful to others. It builds heavily on the \code{did} package. In particular, it breaks into separate steps organizing the data, looping over groups and time periods, computing group-time average treatment effects, and aggregating group-time average treatment effects. Often, one is able to implement a new identification/estimation procedure by simply replacing the step on estimating group-time average treatment effects. See several different examples of this approach in the README.
License: GPL-3
Encoding: UTF-8
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

S3method(print,group_time_att)
S3method(print,pte_results)
S3method(print,summary.dose_obj)
S3method(print,summary.pte_results)
S3method(summary,aggte_obj)
S3method(summary,dose_obj)
S3method(summary,group_time_att)
S3method(summary,pte_emp_boot)
S3method(summary,pte_results)
Expand Down
16 changes: 14 additions & 2 deletions R/classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,15 @@ summary.pte_results <- function(object, ...) {
c1name <- "Event Time"
colnames(out2) <- c(c1name, "Estimate", "Std. Error", cband_text1, "Conf. Band]", "")

target_parameter <- object$ptep$target_parameter

out <- list(
overall_att = out1,
event_study = out2,
alp = alp,
bstrap = bstrap,
cband = cband
cband = cband,
target_parameter = target_parameter
)

class(out) <- "summary.pte_results"
Expand Down Expand Up @@ -252,10 +255,19 @@ print.summary.pte_results <- function(x, ...) {
out1 <- object$overall_att
out2 <- object$event_study
alp <- object$alp
target_parameter <- object$target_parameter

# in a handful of cases, the overall parameter is not an ATT
# (e.g., it could be an ACRT with a continuous treatment),
# allow for possibility of difference here:
att_text <- "Overall ATT" # default
if (isTRUE(target_parameter == "slope")) {
att_text <- "Overall ACRT"
}

# overall att
cat("\n")
cat("Overall ATT: \n")
cat(paste0(att_text, ": \n"))
colnames(out1) <- c("ATT", " Std. Error", paste0(" [ ", 100 * (1 - alp), "% "), "Conf. Int.]", "")
print(out1, row.names = FALSE)
cat("\n\n")
Expand Down
99 changes: 99 additions & 0 deletions R/process_dose_gt.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,102 @@ dose_obj <- function(

out
}

#' @title summary.dose_obj
#'
#' @description summarizes a `dose_obj` object
#'
#' @param object an `dose_obj` object
#' @param ... extra arguments
#'
#' @export
summary.dose_obj <- function(object, ...) {
dose_obj <- object
out <- list(
overall_att = dose_obj$overall_att,
overall_att_se = dose_obj$overall_att_se,
overall_acrt = dose_obj$overall_acrt,
overall_acrt_se = dose_obj$overall_acrt_se,
dose = dose_obj$dose,
att.d = dose_obj$att.d,
att.d_se = dose_obj$att.d_se,
att.d_crit.val = dose_obj$att.d_crit.val,
acrt.d = dose_obj$acrt.d,
acrt.d_se = dose_obj$acrt.d_se,
acrt.d_crit.val = dose_obj$acrt.d_crit.val,
alp = dose_obj$pte_params$alp,
cband = dose_obj$pte_params$cband,
bstrap = dose_obj$pte_params$bstrap
)
class(out) <- "summary.dose_obj"
out
}

#' @title print.summary.dose_obj
#'
#' @description prints a summary of a `dose_obj` object
#'
#' @param x a list containing the summary of a `dose_obj` object
#' @param ... extra arguments
#'
#' @export
print.summary.dose_obj <- function(x, ...) {
# browser()
alp <- x$alp
cband <- x$cband
bstrap <- TRUE # TODO: hardcoded because this only option

# ATT(d)
cat("ATT(d):\n")

cband_text1a <- paste0(100 * (1 - alp), "% ")
cband_text1b <- ifelse(bstrap,
ifelse(cband, "Simult. ", "Pointwise "),
"Pointwise "
)
cband_text1 <- paste0("[", cband_text1a, cband_text1b)

cband_lower <- x$att.d - x$att.d_crit.val * x$att.d_se
cband_upper <- x$att.d + x$att.d_crit.val * x$att.d_se

sig <- (cband_upper < 0) | (cband_lower > 0)
sig[is.na(sig)] <- FALSE
sig_text <- ifelse(sig, "*", "")

out <- cbind.data.frame(x$dose, x$att.d, x$att.d_se, cband_lower, cband_upper)
out <- round(out, 4)
out <- cbind.data.frame(out, sig_text)


colnames(out) <- c("dose", "ATT(d)", "Std. Error", cband_text1, "Conf. Band]", "")
print(out, row.names = FALSE, justify = "centre")
cat("\n\n")

# ATT(d)
cat("ACRT(d):\n")

cband_text1a <- paste0(100 * (1 - alp), "% ")
cband_text1b <- ifelse(bstrap,
ifelse(cband, "Simult. ", "Pointwise "),
"Pointwise "
)
cband_text1 <- paste0("[", cband_text1a, cband_text1b)

cband_lower <- x$acrt.d - x$acrt.d_crit.val * x$acrt.d_se
cband_upper <- x$acrt.d + x$acrt.d_crit.val * x$acrt.d_se

sig <- (cband_upper < 0) | (cband_lower > 0)
sig[is.na(sig)] <- FALSE
sig_text <- ifelse(sig, "*", "")

out <- cbind.data.frame(x$dose, x$acrt.d, x$acrt.d_se, cband_lower, cband_upper)
out <- round(out, 4)
out <- cbind.data.frame(out, sig_text)


colnames(out) <- c("dose", "ACRT(d)", "Std. Error", cband_text1, "Conf. Band]", "")
print(out, row.names = FALSE, justify = "centre")
cat("---\n")
cat("Signif. codes: `*' confidence band does not cover 0")
cat("\n\n")
}
Loading

0 comments on commit 4363c18

Please sign in to comment.