diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index dc0d054..4f63fc2 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 1.0.8 -Date: 2024-03-02 18:35:10 UTC -SHA: be95cd907b6e1c1cb42c645a50a1a1bbb7a45486 +Version: 1.0.12 +Date: 2024-10-07 18:00:19 UTC +SHA: 1802077891d79bc7df8b64a7d51448970b34ea27 diff --git a/DESCRIPTION b/DESCRIPTION index 87e4c50..b309bec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,17 +1,17 @@ Package: rdss Title: Companion Datasets and Functions for Research Design in the Social Sciences -Version: 1.0.8 +Version: 1.0.12 Authors@R: c(person("Graeme", "Blair", email = "graeme.blair@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9164-2102")), person("Alexander", "Coppock", email = "acoppock@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0002-5733-2386")), person("Macartan", "Humphreys", email = "macartan@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0001-7029-2326"))) Description: Helper functions to accompany the Blair, Coppock, and Humphreys (2022) "Research Design in the Social Sciences: Declaration, Diagnosis, and Redesign" . 'rdss' includes datasets, helper functions, and plotting components to enable use and replication of the book. -Imports: dplyr, rlang (>= 1.0.0), generics, ggplot2, tibble, tidyr, dataverse, readr, prediction, broom, purrr, estimatr, randomizr +Imports: dplyr, rlang (>= 1.0.0), generics, ggplot2, tibble, tidyr, dataverse, readr, marginaleffects, broom, purrr, estimatr, randomizr License: MIT + file LICENSE Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Suggests: testthat (>= 3.0.0), rdrobust, diff --git a/NAMESPACE b/NAMESPACE index 1eab2fe..3258d65 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -53,7 +53,7 @@ importFrom(ggplot2,element_text) importFrom(ggplot2,margin) importFrom(ggplot2,theme) importFrom(ggplot2,theme_minimal) -importFrom(prediction,prediction) +importFrom(marginaleffects,predictions) importFrom(purrr,as_vector) importFrom(purrr,map) importFrom(purrr,map_chr) diff --git a/NEWS.md b/NEWS.md index 85bf7e5..e3c58ce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# rdss 1.0.12 + +* address bugs with future package + +# rdss 1.0.10 + +* Switch from prediction to marginaleffects. + # rdss 1.0.8 * Documentation updates for CRAN. diff --git a/R/helpers-multilevel-regression-poststratification.R b/R/helpers-multilevel-regression-poststratification.R index 7134d5d..737801d 100644 --- a/R/helpers-multilevel-regression-poststratification.R +++ b/R/helpers-multilevel-regression-poststratification.R @@ -13,18 +13,21 @@ #' #' @export #' -#' @importFrom prediction prediction +#' @importFrom marginaleffects predictions #' @importFrom dplyr group_by summarize #' @importFrom stats weighted.mean #' @importFrom rlang `!!` enquo #' post_stratification_helper <- function(model_fit, data, group, weights) { - prediction( + predictions( model_fit, - data = data, - allow.new.levels = TRUE, - type = "response" + newdata = data, + type = "response", + re.form = NA + # For this model type, `marginaleffects` only takes into account the + # uncertainty in fixed-effect parameters. You can use the `re.form=NA` + # argument to acknowledge this explicitly and silence this warning. ) %>% group_by({{group}}) %>% - summarize(estimate = weighted.mean(fitted, !!enquo(weights)), .groups = "drop") + summarize(estimate = weighted.mean(estimate, !!enquo(weights)), .groups = "drop") } diff --git a/cran-comments.md b/cran-comments.md index b08a3bc..5318252 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,6 @@ ## Submission -Submission to resolve internet connection-required example. +rdss 1.0.10 was archived off CRAN, principally because the `prediction` package was archived. This version switches to the `marginaleffects` package. ## Test environments diff --git a/data/lapop_brazil.rda b/data/lapop_brazil.rda index 014c3ae..758d8ab 100644 Binary files a/data/lapop_brazil.rda and b/data/lapop_brazil.rda differ diff --git a/tests/testthat/test-bayesian-regression.R b/tests/testthat/test-bayesian-regression.R index b54cbd1..f4923f5 100644 --- a/tests/testthat/test-bayesian-regression.R +++ b/tests/testthat/test-bayesian-regression.R @@ -19,6 +19,6 @@ test_that("tidy_stan works", { inquiry = "mean_age" ) - expect_error(simulate_design(declaration_9.3, sims = 1), NA) + expect_error(simulate_design(declaration_9.3, sims = 1, future.seed = FALSE), NA) }) diff --git a/tests/testthat/test-causal-forests.R b/tests/testthat/test-causal-forests.R index 169f5f9..16bc358 100644 --- a/tests/testthat/test-causal-forests.R +++ b/tests/testthat/test-causal-forests.R @@ -56,6 +56,6 @@ test_that("causal forest helpers work", { declare_estimator(handler = label_estimator(get_best_predictor), inquiry = "best_predictor", label = "cf") - expect_error(simulate_design(declaration_19.1, sims = 1), NA) + expect_error(simulate_design(declaration_19.1, sims = 1, future.seed = FALSE), NA) }) diff --git a/tests/testthat/test-conjoint-experiments.R b/tests/testthat/test-conjoint-experiments.R index 2e53de0..7cd234e 100644 --- a/tests/testthat/test-conjoint-experiments.R +++ b/tests/testthat/test-conjoint-experiments.R @@ -48,6 +48,6 @@ test_that("conjoint helpers work", { respondent.id = "subject", .method = amce) - expect_error(simulate_design(declaration_17.5, sims = 1), NA) + expect_error(simulate_design(declaration_17.5, sims = 1, future.seed = FALSE), NA) }) diff --git a/tests/testthat/test-difference-in-differences.R b/tests/testthat/test-difference-in-differences.R index 7724383..409e73c 100644 --- a/tests/testthat/test-difference-in-differences.R +++ b/tests/testthat/test-difference-in-differences.R @@ -51,11 +51,12 @@ test_that("lag_by_group and did_multiplegt_tidy work", { G = "units", T = "periods", D = "D", + mode = "old", handler = label_estimator(did_multiplegt_tidy), inquiry = c("ATT", "ATT_switchers"), label = "chaisemartin" ) - expect_error(suppressWarnings(simulate_design(declaration_16.3, sims = 1)), NA) + expect_error(suppressWarnings(simulate_design(declaration_16.3, sims = 1, future.seed = FALSE)), NA) }) diff --git a/tests/testthat/test-experiments-over-networks.R b/tests/testthat/test-experiments-over-networks.R index c94e775..ffb8176 100644 --- a/tests/testthat/test-experiments-over-networks.R +++ b/tests/testthat/test-experiments-over-networks.R @@ -55,6 +55,6 @@ test_that("interference helpers work", { permutatation_matrix = permutatation_matrix, adj_matrix = adj_matrix) - expect_error(simulate_design(declaration_18.13, sims = 1), NA) + expect_error(simulate_design(declaration_18.13, sims = 1, future.seed = FALSE), NA) }) diff --git a/tests/testthat/test-meta-analysis.R b/tests/testthat/test-meta-analysis.R index 096adff..3cce105 100644 --- a/tests/testthat/test-meta-analysis.R +++ b/tests/testthat/test-meta-analysis.R @@ -34,6 +34,6 @@ test_that("rma helpers work", { declaration_19.3 <- redesign(design, tau = c(0, 1)) - expect_error(simulate_design(declaration_19.3, sims = 1), NA) + expect_error(simulate_design(declaration_19.3, sims = 1, future.seed = FALSE), NA) }) diff --git a/tests/testthat/test-multilevel-regression-poststratification.R b/tests/testthat/test-multilevel-regression-poststratification.R index beb77a2..733bfd2 100644 --- a/tests/testthat/test-multilevel-regression-poststratification.R +++ b/tests/testthat/test-multilevel-regression-poststratification.R @@ -49,6 +49,6 @@ test_that("post_stratification_helper works", { label = "Partial pooling", inquiry = "mean_policy_support") - expect_error(simulate_design(declaration_15.4, sims = 1), NA) + expect_error(simulate_design(declaration_15.4, sims = 1, future.seed = FALSE), NA) }) diff --git a/tests/testthat/test-process-tracing.R b/tests/testthat/test-process-tracing.R index 4b2f919..e0fc23b 100644 --- a/tests/testthat/test-process-tracing.R +++ b/tests/testthat/test-process-tracing.R @@ -29,6 +29,6 @@ test_that("process_tracing_estimator works", { query = "Y[X=1] - Y[X=0]", strategies = strategies) - expect_error(simulate_design(declaration_16.1, sims = 1), NA) + expect_error(simulate_design(declaration_16.1, sims = 1, future.seed = FALSE), NA) }) diff --git a/tests/testthat/test-regression-discontinuity.R b/tests/testthat/test-regression-discontinuity.R index e214363..5a352e8 100644 --- a/tests/testthat/test-regression-discontinuity.R +++ b/tests/testthat/test-regression-discontinuity.R @@ -33,6 +33,6 @@ test_that("tidy.rdrobust and rdrobust_helper work", { inquiry = "LATE", label = "optimal" ) - expect_error(simulate_design(declaration_16.5, sims = 1), NA) + expect_error(simulate_design(declaration_16.5, sims = 1, future.seed = FALSE), NA) })