Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bcallaway11 committed Jan 10, 2025
1 parent af2de45 commit da26ad6
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 144 deletions.
224 changes: 114 additions & 110 deletions R/classes.R

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions R/pte.R
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ pte <- function(yname,
#' package will use the empirical bootstrap no matter what the value of this
#' parameter.
#'
#' @param process_dtt_gt An optional function to customize results when
#' the gt-specific function returns the distribution of treated and untreated
#' potential outcomes.
#'
#' @param ... extra arguments that can be passed to create the correct subsets
#' of the data (depending on \code{subset_fun}), to estimate group time
#' average treatment effects (depending on \code{attgt_fun}), or to
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
@@ -1 +1 @@
utils::globalVariables(c("e","post","ciu","cil","G","Y","att","id","name","period","att.e","att.g","group","length.e","length.group","time.period"))
utils::globalVariables(c("e", "post", "ciu", "cil", "G", "Y", "att", "id", "name", "period", "att.e", "att.g", "group", "length.e", "length.group", "time.period", ".treat"))
10 changes: 2 additions & 8 deletions man/group_time_att.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/pte2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions man/pte_emp_boot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 24 additions & 21 deletions tests/testthat/test-did-inference.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,36 @@ library(did)
library(pbapply)


skip_inf <- menu(c("run", "skip"), title="would you like to run or skip the inference tests?")
skip_inf <- skip_inf == 2
# skip_inf <- menu(c("run", "skip"), title="would you like to run or skip the inference tests?")
# skip_inf <- skip_inf == 2

test_that("tests for inference", {
skip_if(skip_inf)
cl <- as.numeric(readline("how many clusters would like to use for the inference tests? "))
# skip_if(skip_inf)
# cl <- as.numeric(readline("how many clusters would like to use for the inference tests? "))
cl <- 1
mc_sims <- 100
rejs <- pblapply(1:mc_sims, function(mc) {
sp <- did::reset.sim()
data <- did::build_sim_dataset(sp)

res <- pte(yname="Y",
gname="G",
tname="period",
idname="id",
data=data,
setup_pte_fun=setup_pte,
subset_fun=two_by_two_subset,
attgt_fun=did_attgt,
xformla=~X)

res <- pte(
yname = "Y",
gname = "G",
tname = "period",
idname = "id",
data = data,
setup_pte_fun = setup_pte,
subset_fun = two_by_two_subset,
attgt_fun = did_attgt,
xformla = ~X
)
# truth is that att = 1
tstat <- (res$overall_att$overall.att-1) / res$overall_att$overall.se
rej <- 1*( abs(tstat) > qnorm(.975))
tstat <- (res$overall_att$overall.att - 1) / res$overall_att$overall.se
rej <- 1 * (abs(tstat) > qnorm(.975))
rej
}, cl=cl)
}, cl = cl)

rej_frac <- mean(unlist(rejs))
expect_equal(rej_frac, 0.06, tolerance=.05) # make test fail if reject 0
})

expect_equal(rej_frac, 0.06, tolerance = .05) # make test fail if reject 0
})
Binary file added tests/testthat/testthat-problems.rds
Binary file not shown.

0 comments on commit da26ad6

Please sign in to comment.