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
11 changes: 5 additions & 6 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.12.0.22
Version: 0.13.0
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down Expand Up @@ -39,10 +39,10 @@ BugReports: https://github.com/easystats/modelbased/issues
Depends:
R (>= 3.6)
Imports:
bayestestR (>= 0.16.1),
bayestestR (>= 0.17.0),
datawizard (>= 1.2.0),
insight (>= 1.3.1),
parameters (>= 0.27.0),
insight (>= 1.4.1),
parameters (>= 0.28.1),
graphics,
stats,
tools,
Expand Down Expand Up @@ -76,7 +76,7 @@ Suggests:
logspline,
MASS,
Matrix,
marginaleffects (>= 0.26.0),
marginaleffects (>= 0.29.0),
mice,
mgcv,
mvtnorm,
Expand Down Expand Up @@ -115,4 +115,3 @@ Roxygen: list(markdown = TRUE)
Config/Needs/check: stan-dev/cmdstanr
Config/Needs/website: easystats/easystatstemplate
LazyData: true
Remotes: easystats/insight, easystats/parameters, easystats/bayestestR, vincentarelbundock/marginaleffects
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# modelbased (devel)
# modelbased 0.13.0

## Changes

Expand Down
2 changes: 1 addition & 1 deletion R/format.R
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ format.marginaleffects_contrasts <- function(x, model = NULL, p_adjust = NULL, c
params <- data.frame(datawizard::data_restoretype(params, model_data))

# add posterior draws?
insight::check_if_installed("marginaleffects", minimum_version = "0.28.0.22")
insight::check_if_installed("marginaleffects", minimum_version = "0.29.0")
posterior_draws <- suppressWarnings(as.data.frame(marginaleffects::get_draws(
x,
shape = "PxD"
Expand Down
2 changes: 1 addition & 1 deletion R/get_marginalcontrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ get_marginalcontrasts <- function(
...
) {
# check if available
insight::check_if_installed("marginaleffects", minimum_version = "0.25.0")
insight::check_if_installed("marginaleffects", minimum_version = "0.29.0")

# temporarily overwrite settings that error on "too many" rows
me_option <- getOption("marginaleffects_safe")
Expand Down
2 changes: 1 addition & 1 deletion R/get_marginaleffects_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@

# check if marginaleffects objects has posterior draws and thus is Bayesian
.is_bayesian_marginaleffects <- function(model) {
insight::check_if_installed("marginaleffects", minimum_version = "0.28.0.22")
insight::check_if_installed("marginaleffects", minimum_version = "0.29.0")
!is.null(suppressWarnings(marginaleffects::get_draws(model, "PxD")))
}

Expand Down
2 changes: 1 addition & 1 deletion R/get_marginalmeans.R
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

get_marginalmeans <- function(model,
by = "auto",
predict = NULL,
ci = 0.95,
estimate = NULL,
transform = NULL,
keep_iterations = FALSE,
verbose = TRUE,
...) {

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ get_marginalmeans <- function(model,
verbose = TRUE,
...) {
# check if available
insight::check_if_installed("marginaleffects")
insight::check_if_installed("marginaleffects", minimum_version = "0.29.0")

# First step: process arguments --------------------------------------------
# --------------------------------------------------------------------------
Expand Down
34 changes: 16 additions & 18 deletions R/get_marginaltrends.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
#' get_marginaltrends(model, trend = "Petal.Length", by = "Petal.Length")
#' get_marginaltrends(model, trend = "Petal.Length", by = c("Species", "Petal.Length"))
#' @export
get_marginaltrends <- function(model,
trend = NULL,
by = NULL,
predict = NULL,
ci = 0.95,
estimate = NULL,
transform = NULL,
p_adjust = "none",
keep_iterations = FALSE,
verbose = TRUE,
...) {
get_marginaltrends <- function(
model,
trend = NULL,
by = NULL,
predict = NULL,
ci = 0.95,
estimate = NULL,
transform = NULL,
p_adjust = "none",
keep_iterations = FALSE,
verbose = TRUE,
...
) {
# check if available
insight::check_if_installed("marginaleffects")
insight::check_if_installed("marginaleffects", minimum_version = "0.29.0")
dots <- list(...)

# set defaults
Expand Down Expand Up @@ -107,12 +109,7 @@ get_marginaltrends <- function(model,

# setup arguments again
fun_args <- insight::compact_list(c(
list(
model,
variables = myargs$trend,
by = myargs$by,
conf_level = ci
),
list(model, variables = myargs$trend, by = myargs$by, conf_level = ci),
dots
))

Expand All @@ -124,6 +121,7 @@ get_marginaltrends <- function(model,
fun_args$newdata <- datagrid
}

# fmt: skip
# handle distributional parameters
if (!is.null(predict) && inherits(model, "brmsfit") && predict %in% .brms_aux_elements(model)) {
fun_args$dpar <- predict
Expand Down
2 changes: 1 addition & 1 deletion R/p_adjust.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@

int <- paste0(pred, ":", mod)
if (inherits(x, c("marginaleffects_slopes", "slopes", "marginaleffects"))) {
insight::check_if_installed("marginaleffects", minimum_version = "0.28.0.22")
insight::check_if_installed("marginaleffects", minimum_version = "0.29.0")
model <- marginaleffects::components(x, "model")
} else {
model <- attributes(x)$model
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-attributes_estimatefun.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("attributes_means", {
data(iris)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-backtransform_invlink.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("glmmTMB")

test_that("estimate_means correct inverse link for glmmTMB", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-betareg.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
skip_on_cran()
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("betareg")

test_that("estimate_means for betareg", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-bias_correction.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("emmeans")
skip_if_not_installed("lme4")

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-brms-marginaleffects.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ skip_if_offline()
skip_if_not_installed("brms")
skip_if_not_installed("BH")
skip_if_not_installed("RcppEigen")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("httr2")
skip_if_not_installed("withr")

Expand Down
9 changes: 7 additions & 2 deletions tests/testthat/test-brms.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ skip_if_not_installed("brms")
skip_if_not_installed("BH")
skip_if_not_installed("RcppEigen")
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("estimate_means - brms", {
model <- brms::brm(Sepal.Length ~ Species * Sepal.Width, data = iris, refresh = 0, iter = 1000)
model <- brms::brm(
Sepal.Length ~ Species * Sepal.Width,
data = iris,
refresh = 0,
iter = 1000
)
estim <- estimate_means(model, backend = "emmeans")
expect_identical(dim(estim), c(3L, 5L))
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_contrasts-average.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_on_os("mac")


Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_contrasts.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_on_os("mac")

test_that("estimate_contrasts - Frequentist, one factor", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_contrasts_bookexamples.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_on_os("mac")

test_that("estimate_contrasts - book examples 1", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_contrasts_effectsize.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("bootES")
skip_if_not_installed("lme4")
skip_on_os("mac")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_contrasts_inequality.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_on_os("mac")
skip_if(getRversion() < "4.5.0")
skip_if_not_installed("datawizard")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-estimate_expectation.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
skip_if_not_installed("insight", minimum_version = "1.1.0")
skip_if_not_installed("insight", minimum_version = "1.4.1")

test_that("estimate_expectation", {
skip_if_not_installed("lme4")
Expand Down Expand Up @@ -77,7 +77,7 @@ test_that("estimate_expectation - error", {


test_that("estimate_relation and estimate specific", {
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
data(efc, package = "modelbased")
efc <- datawizard::to_factor(efc, c("c161sex", "c172code", "e16sex", "e42dep"))
fit <- lm(neg_c_7 ~ c12hour + barthtot + c161sex + e42dep + c172code, data = efc)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_filter.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_on_os("mac")

test_that("filtering for by and contrast works for different estimate options", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_means-average.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_on_os("mac")


Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-estimate_means.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("estimate_means() - lm", {
data(mtcars)
Expand Down Expand Up @@ -327,7 +327,7 @@ test_that("estimate_means() - glm", {


test_that("get_marginaleffects, overall mean", {
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("emmeans")

model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_means_ci.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("estimate_means() - ci frequentist", {
data(iris)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_means_counterfactuals.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("glmmTMB")
skip_if_not_installed("lme4")

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_means_dotargs.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("estimate_means() - estimate = average", {
data(mtcars)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_means_marginalization.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("estimate_means() - estimate options", {
data(efc, package = "modelbased")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_means_mixed.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("estimate_means() - mixed models", {
skip_if_not_installed("lme4")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_predicted.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
skip_if_not_installed("insight", minimum_version = "1.1.0")
skip_if_not_installed("insight", minimum_version = "1.4.1")

test_that("estimate_relation - shape", {
skip_if_not_installed("gamm4")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-estimate_slopes.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("estimate_slopes", {
data(iris)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-g_computation.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("nanoparquet")
skip_on_os("mac")

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_marginaltrends.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("emmeans")

test_that("get_marginaltrends", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-glmmTMB.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
skip_on_cran()
skip_if_not_installed("glmmTMB")
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

data <- glmmTMB::Salamanders
model <- suppressWarnings(glmmTMB::glmmTMB(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-joint_test.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_on_os("mac")

test_that("estimate_contrasts - joint test, 2-way", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-keep_iterations.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("emmeans")
skip_if_not_installed("brms")
skip_if_not_installed("curl")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-mgcv.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_if_not_installed("emmeans")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("mgcv")
skip_if_not_installed("gamm4")

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-mice.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
skip_if_not_installed("mice")
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("pool_predictions", {
set.seed(123)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-multivariate_response.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
skip_if_not_installed("marginaleffects", minimum_version = "0.28.0.22")
skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")
skip_if_not_installed("lme4")

test_that("multivariate response", {
Expand Down
Loading
Loading