Skip to content

Commit

Permalink
Prepare CRAN submission (#357)
Browse files Browse the repository at this point in the history
* Prepare CRAN submission

* minor

* required marginaleffects > 0.24.0

* can remove todo

* don't build snaps

* skip test for old marginaleffects

* revert

* skip some tests on CRAN

* minor
  • Loading branch information
strengejacke authored Jan 20, 2025
1 parent c7a09f5 commit 0c08a45
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 39 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
^CRAN-SUBMISSION$
\.code-workspace$
^\.lintr$
^tests/testthat/_snaps/.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: modelbased
Title: Estimation of Model-Based Predictions, Contrasts and Means
Version: 0.8.9.42
Version: 0.9.0
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down Expand Up @@ -89,4 +89,3 @@ Config/testthat/parallel: true
Roxygen: list(markdown = TRUE)
Config/Needs/check: stan-dev/cmdstanr
Config/Needs/website: easystats/easystatstemplate
Remotes: vincentarelbundock/marginaleffects
2 changes: 1 addition & 1 deletion R/estimate_contrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#' # By default: selects first factor
#' estimate_contrasts(model)
#'
#' # Can also run contrasts between points of numeric
#' # Can also run contrasts between points of numeric, stratified by "Species"
#' estimate_contrasts(model, contrast = "Petal.Width", by = "Species", length = 4)
#'
#' # Or both
Expand Down
16 changes: 8 additions & 8 deletions R/estimate_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@
#' which computes a kind of "weighted average" for the values at which these
#' terms are hold constant. These predictions are a good representation of the
#' sample, because all possible values and levels of the non-focal predictors
#' are taken into account. It answers the question, "What is the predicted
#' value for an 'average' observation in *my data*?". It refers to randomly
#' picking a subject of your sample and the result you get on average. This
#' approach is the one taken by default in the `emmeans` package.
#' are considered. It answers the question, "What is the predicted value for
#' an 'average' observation in *my data*?". It refers to randomly picking a
#' subject of your sample and the result you get on average. This approach is
#' the one taken by default in the `emmeans` package.
#' - `"population"`: Non-focal predictors are marginalized over the observations
#' in the sample, where the sample is replicated multiple times to produce
#' "counterfactuals" and then takes the average of these predicted values
#' (aggregated/grouped by the focal terms). It can be considered as
#' extrapolation to a hypothetical target population. Counterfactual
#' predictions are useful, insofar as the results can also be transferred to
#' other contexts (Dickerman and Hernan, 2020). It answers the question, "What
#' is the predicted for the 'average' observation in *the broader target
#' population*?". It does not only refer to the actual data in your observed
#' sample, but also "what would be if" we had more data, or if we had data
#' from a different sample.
#' is the predicted response value for the 'average' observation in *the
#' broader target population*?". It does not only refer to the actual data in
#' your observed sample, but also "what would be if" we had more data, or if
#' we had data from a different sample.
#'
#' In other words, the distinction between marginalization types resides in whether
#' the prediction are made for:
Expand Down
18 changes: 9 additions & 9 deletions man/estimate_contrasts.Rd

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

16 changes: 8 additions & 8 deletions man/estimate_means.Rd

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

16 changes: 8 additions & 8 deletions man/get_emmeans.Rd

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

3 changes: 1 addition & 2 deletions tests/testthat/test-attributes_estimatefun.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## TODO: skip for marginaleffects 0.24.0?

skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects")

Expand Down Expand Up @@ -55,6 +53,7 @@ test_that("attributes_means, contrasts", {


test_that("attributes_means, slopes", {
skip_if_not_installed("marginaleffects", minimum_version = "0.24.1")
data(iris)
model <- lm(Sepal.Length ~ Species + Sepal.Width, data = iris)

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-brms.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
skip_on_cran()
skip_on_os("windows")
skip_if_not_installed("brms")
skip_if_not_installed("BH")
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-estimate_contrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ test_that("estimate_contrasts - Frequentist", {


test_that("estimate_contrasts - Bayesian", {
skip_on_cran()
skip_if_not_installed("logspline")
skip_if_not_installed("rstanarm")
skip_if_not_installed("lme4")
Expand Down Expand Up @@ -254,6 +255,7 @@ test_that("estimate_contrasts - p.adjust", {


test_that("estimate_contrasts - dfs", {
skip_on_cran()
skip_if_not_installed("lme4")
skip_if_not_installed("pbkrtest")
skip_if_not_installed("lmerTest")
Expand All @@ -280,7 +282,7 @@ test_that("estimate_contrasts - dfs", {


test_that("estimate_contrasts - marginaleffects", {
## TODO: skip for marginaleffects 0.24.0?
# ignore failing snapshot tests, should resolve with next marginaleffects version
skip_if_not_installed("Formula")
skip_if_not_installed("ggeffects")
data(coffee_data, package = "ggeffects")
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-estimate_means_mixed.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects")

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-glmmTMB.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
skip_on_cran()
skip_if_not_installed("glmmTMB")
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects")
Expand Down

0 comments on commit 0c08a45

Please sign in to comment.