Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rdss
Title: Companion Datasets and Functions for Research Design in the Social Sciences
Version: 1.0.16
Version: 1.0.16.9000
Authors@R:
c(person("Graeme", "Blair", email = "graeme.blair@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0001-9164-2102")),
person("Alexander", "Coppock", email = "acoppock@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-5733-2386")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rdss (development version)

* The eight helpers that wrap a Suggests package (`tidy_stan()`, `rdrobust_tidy()`, `process_tracing_estimator()`, `rma_helper()`, `did_multiplegt_tidy()`, `causal_forest_helper()`, `post_stratification_helper()`, and `tidy()` on an `amce` object) stop with an error naming the missing package, and offer to install it in an interactive session. They printed a message and returned `NULL` invisibly, so the failure surfaced later, in whatever code used the result.

# rdss 1.0.16

* In the GitHub version, `estimator_AS_tidy()` returns standard errors, p-values, and 95 percent confidence intervals. `interference::estimates()` computes effect variances only when told which condition is control, and rdss had never passed `control_condition`, so the variances were always empty. The Horvitz-Thompson rows use Aronow and Samii's conservative variance, the larger of the Horvitz-Thompson and constant-effects variances, since the plain Horvitz-Thompson variance of a difference can be negative. Intervals for an effect whose exposure condition is rare can undercover; the documentation gives the simulated rates.
Expand Down
5 changes: 1 addition & 4 deletions R/helpers-causal-forests.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
#'
causal_forest_handler <- function(data, covariate_names, share_train = 0.5, ...) {

if(!requireNamespace("grf")){
message("The causal_forest_helper function requires the 'grf' package.")
return(invisible())
}
rlang::check_installed("grf", reason = "to use `causal_forest_helper`.")

X <- as.matrix(data %>% select(all_of(covariate_names)))

Expand Down
5 changes: 1 addition & 4 deletions R/helpers-conjoint-experiments.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
tidy.amce <-
function(x, alpha = 0.05, ...) {

if(!requireNamespace("cjoint")){
message("The tidy function for amce objects requires the 'cjoint' package.")
return(invisible())
}
rlang::check_installed("cjoint", reason = "to use `tidy()` on an amce object.")

z_score <- qnorm(1 - ((alpha) / 2))
summary_fit <- cjoint::summary.amce(x)
Expand Down
5 changes: 1 addition & 4 deletions R/helpers-difference-in-differences.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ lag_by_group <- function(x, groups, n = 1, order_by, default = NA) {
#'
did_multiplegt_tidy <- function(data, ...) {

if(!requireNamespace("DIDmultiplegt")){
message("The did_multiplegt_tidy function requires the 'DIDmultiplegt' package.")
return(invisible())
}
rlang::check_installed("DIDmultiplegt", reason = "to use `did_multiplegt_tidy`.")

args <- list(...)
if (identical(args$mode, "dyn") && is.null(args$graph_off)) {
Expand Down
5 changes: 1 addition & 4 deletions R/helpers-meta-analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ rma_mu_tau <- function(fit) {
#' fit
#'
rma_helper <- function(data, yi, sei, method = "REML", ...){
if(!requireNamespace("metafor")){
message("The rma_helper function requires the 'metafor' package.")
return(invisible())
}
rlang::check_installed("metafor", reason = "to use `rma_helper`.")
fit <- try({metafor::rma(yi = data[[quo_text(enexpr(yi))]], sei = data[[quo_text(enexpr(sei))]], method = method, ... = ...)})
if(inherits(fit, "try-error")) {
class(fit) <- c("rma.uni", "try-error")
Expand Down
5 changes: 1 addition & 4 deletions R/helpers-multilevel-regression-poststratification.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
#'
post_stratification_helper <- function(model_fit, data, group, weights) {

if(!requireNamespace("marginaleffects")){
message("The post_stratification_helper function requires the 'marginaleffects' package.")
return(invisible())
}
rlang::check_installed("marginaleffects", reason = "to use `post_stratification_helper`.")

# `re.form = NA` is an lme4 prediction argument. marginaleffects warns when
# it is passed to a model that does not take it, so it goes only to a mixed
Expand Down
5 changes: 1 addition & 4 deletions R/helpers-process-tracing.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@

process_tracing_estimator <- function(causal_model, query, data, strategies) {

if(!requireNamespace("CausalQueries")){
message("The process_tracing_estimator function requires the 'CausalQueries' package.")
return(invisible())
}
rlang::check_installed("CausalQueries", reason = "to use `process_tracing_estimator`.")

if(nrow(data) !=1) {
stop("please provide a single row dataset")
Expand Down
5 changes: 1 addition & 4 deletions R/helpers-regression-discontinuity.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
#' tidy(fit)
#'
tidy.rdrobust <- function(x, ...) {
if(!requireNamespace("rdrobust")){
message("The rdrobust_tidy function requires the 'rdrobust' package.")
return(invisible())
}
rlang::check_installed("rdrobust", reason = "to use `rdrobust_tidy`.")

ret <- data.frame(rownames(x$coef), x$coef, x$se, x$z, x$pv, x$ci, c = x$c)
row.names(ret) <- NULL
Expand Down
5 changes: 1 addition & 4 deletions R/helpers-stanreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ tidy_stan <- function(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FAL

message("This function is deprecated. Please use the 'tidy' function from the 'broom.mixed' package.")

if(!requireNamespace("broom.mixed")){
message("The tidy_stan function requires the 'broom.mixed' package.")
return(invisible())
}
rlang::check_installed("broom.mixed", reason = "to use `tidy_stan`.")

ret <- broom.mixed::tidy(x, conf.int = conf.int, conf.level = conf.level, exponentiate = exponentiate, ...)

Expand Down
Loading