From 5a1b0f13331332c84809106e24fb24f982d15ccc Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Sun, 11 Aug 2024 08:32:03 -0400 Subject: [PATCH 1/9] tinytable print --- R/print.R | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/R/print.R b/R/print.R index 0ed04a753..4d41ac1f4 100644 --- a/R/print.R +++ b/R/print.R @@ -270,11 +270,7 @@ print.marginaleffects <- function(x, notes <- c(print_type_text, print_columns_text) if (!is.null(notes)) args$notes <- notes tab <- do.call(tinytable::tt, args) - tab <- tinytable::format_tt(tab, escape = TRUE) - theme <- getOption("tinytable_tt_theme", default = NULL) - if (is.function(theme)) { - tab <- theme(tab) - } + tab <- tinytable::format_tt(i = 0, tab, escape = TRUE) if (isTRUE(splitprint)) { msg <- "%s rows omitted" From e18052a6276b574aff1827d9ba03ed0f339cb101 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Wed, 21 Aug 2024 15:16:25 -0500 Subject: [PATCH 2/9] mgcv allows discrete argument --- DESCRIPTION | 2 +- NEWS.md | 1 + R/sanity_dots.R | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a460322e8..5a21de143 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.21.0.16 +Version: 0.21.0.17 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", diff --git a/NEWS.md b/NEWS.md index 574659dc6..5dbb86a78 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,6 +17,7 @@ New: * Global option: `options("marginaleffects_print_omit" = "s.value")` * Round significant digits for labels in `plot_predictions(mod, condition = list(x = "fivenum"))` * `print()` no longer prints `contrast` and `term` columns when values are unique. The labels were often very long, and the content is already explicit in the call itself, so there's no ambiguity. +* No warning raised when `discrete` argument is used with `mgcv::bam` and `mgcv::gam` models objects. Thanks to @Aariq for the request. Bugs: diff --git a/R/sanity_dots.R b/R/sanity_dots.R index 86005e584..7e8b781f4 100644 --- a/R/sanity_dots.R +++ b/R/sanity_dots.R @@ -32,8 +32,8 @@ sanity_dots <- function(model, calling_function = NULL, ...) { valid[["brmsfit_multiple"]] <- valid[["brmsfit"]] valid[["selection"]] <- c("part") # sampleSelection valid[["glmmTMB"]] <- c("re.form", "allow.new.levels", "zitype") # glmmTMB - valid[["bam"]] <- c("exclude") # mgcv - valid[["gam"]] <- c("exclude") # mgcv + valid[["bam"]] <- c("exclude", "discrete") # mgcv + valid[["gam"]] <- c("exclude", "discrete") # mgcv valid[["rlmerMod"]] <- c("re.form", "allow.new.levels") valid[["gamlss"]] <- c("what", "safe") # gamlss valid[["lme"]] <- c("level") # nlme::lme From 77a0c215b21828a09851f8a819691134d360f5b6 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Thu, 22 Aug 2024 09:59:47 -0500 Subject: [PATCH 3/9] comparisons manual computation --- vignettes/brms.qmd | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/vignettes/brms.qmd b/vignettes/brms.qmd index ac94ab208..146627be3 100644 --- a/vignettes/brms.qmd +++ b/vignettes/brms.qmd @@ -885,3 +885,45 @@ avg_slopes(mod, dpar = "sigma") ``` + +# Manual computation: Counterfactual comparisons + +Here is an example which replicates `comparisons()` output manually. Hopefully this will help some readers understand what is going on under the hood: + +```{r, eval = FALSE} +library(marginaleffects) +data("ChickWeight") + +mod = brm(data = ChickWeight, + weight ~ Time * Diet + (Time|Chick), + seed = 123, + backend = "cmdstanr") + +# NA +comparisons(mod, + variables = "Time", + by = "Diet", + re_formula = NA) + +d0 <- ChickWeight +d1 <- transform(d0, Time = Time + 1) +p0 <- posterior_epred(mod, newdata = d0, re_formula = NA) +p1 <- posterior_epred(mod, newdata = d1, re_formula = NA) +p <- p1 - p0 +cmp <- apply(p, 1, function(x) tapply(x, ChickWeight$Diet, mean)) +apply(cmp, 1, quantile, prob = .025) + +# NULL +comparisons(mod, + variables = "Time", + by = "Diet", + re_formula = NULL) + +d0 <- ChickWeight +d1 <- transform(d0, Time = Time + 1) +p0 <- posterior_epred(mod, newdata = d0, re_formula = NULL) +p1 <- posterior_epred(mod, newdata = d1, re_formula = NULL) +p <- p1 - p0 +cmp <- apply(p, 1, function(x) tapply(x, ChickWeight$Diet, mean)) +apply(cmp, 1, quantile, prob = .025) +``` From 23fcddcb7c10e86ada72da71b5069853dac8a9f3 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Thu, 22 Aug 2024 15:49:59 -0500 Subject: [PATCH 4/9] Support class `model_fit` directly #1194 --- R/get_modeldata.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/get_modeldata.R b/R/get_modeldata.R index 5ce689ef1..301c3df69 100644 --- a/R/get_modeldata.R +++ b/R/get_modeldata.R @@ -9,6 +9,12 @@ get_modeldata <- function(model, additional_variables = FALSE, modeldata = NULL, # some pre-processing, and we want to rely on the workflow to do that. # workflows are triggered on `stats::predict()` if (inherits(model, c("model_fit", "workflow"))) { + if ("fit" %in% names(model)) { + tmp <- try(get_modeldata(model$fit), silent = TRUE) + if (inherits(tmp, "data.frame")) { + return(tmp) + } + } return(NULL) } From 422fe4ccfcaa5170278498e0e10e89b04bdc39a8 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Thu, 22 Aug 2024 16:28:57 -0500 Subject: [PATCH 5/9] bump --- DESCRIPTION | 2 +- NEWS.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5a21de143..516f39447 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.21.0.17 +Version: 0.21.0.18 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", diff --git a/NEWS.md b/NEWS.md index 5dbb86a78..3a3c06f70 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,7 @@ New: * Round significant digits for labels in `plot_predictions(mod, condition = list(x = "fivenum"))` * `print()` no longer prints `contrast` and `term` columns when values are unique. The labels were often very long, and the content is already explicit in the call itself, so there's no ambiguity. * No warning raised when `discrete` argument is used with `mgcv::bam` and `mgcv::gam` models objects. Thanks to @Aariq for the request. +* `tidymodels` support is improved. Users can now directly feed some of them without specifying `newdata` explicitly. Thanks to @davidkane9 for the feature request. Bugs: From f2b285ea3d9d5ff169a9a3030b5f8ebdaf4ddf4d Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Sat, 24 Aug 2024 06:50:21 -0500 Subject: [PATCH 6/9] bump --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 516f39447..671bd2b3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.21.0.18 +Version: 0.21.0.19 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", From 5ca9c558a1eacadf3758b9921cda28177bceb8c7 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Fri, 30 Aug 2024 19:22:45 -0400 Subject: [PATCH 7/9] issue #1204 (#1205) * issue1204 * test fix --- DESCRIPTION | 2 +- NEWS.md | 1 + R/backtransform.R | 10 ++++++++++ inst/tinytest/test-marginal_means.R | 4 ++-- inst/tinytest/test-predictions.R | 23 +++++++++++++++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 671bd2b3e..618f7a6a7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.21.0.19 +Version: 0.21.0.20 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", diff --git a/NEWS.md b/NEWS.md index 3a3c06f70..5ae659baf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -25,6 +25,7 @@ Bugs: * Average lift and average comparisons with user-supplied functions could be be calculated incorrectly when all predictors were categorical. Thanks to @Dpananos for Issue #1151. * Indexing bug returned `NA` for some commands in `survey` models. Thanks to @weikang9009 for report #1161. * Respect default `tinytable` theme. +* Inverted confidence interval bounds with some inverse link functions. Thanks to @strengejacke for report #1204. ## 0.21.0 diff --git a/R/backtransform.R b/R/backtransform.R index 54edf9aff..e680a40d5 100644 --- a/R/backtransform.R +++ b/R/backtransform.R @@ -28,6 +28,16 @@ backtransform <- function(x, transform) { x[[col]] <- transform(x[[col]]) } + # Issue #1204: Some inverse link functions swap the order of low and high + if (all(c("conf.low", "conf.high") %in% colnames(x))) { + if (all(x$conf.high < x$conf.low)) { + lo <- x[["conf.low"]] + hi <- x[["conf.high"]] + x[["conf.low"]] <- hi + x[["conf.high"]] <- lo + } + } + for (col in c("std.error", "statistic")) { x[[col]] <- NULL } diff --git a/inst/tinytest/test-marginal_means.R b/inst/tinytest/test-marginal_means.R index ac8236e4e..ea225b052 100644 --- a/inst/tinytest/test-marginal_means.R +++ b/inst/tinytest/test-marginal_means.R @@ -19,8 +19,8 @@ em <- suppressMessages(emmeans(mod, ~wool, type = "response", df = Inf)) mm <- predictions(mod, newdata=datagrid(grid_type="balanced"), by="wool", type = "invlink(link)") expect_equal(data.frame(em)$response, mm$estimate) # TODO: 1/eta link function inverts order of CI. Should we clean this up? -expect_equal(data.frame(em)$asymp.LCL, mm$conf.high) -expect_equal(data.frame(em)$asymp.UCL, mm$conf.low) +expect_equal(data.frame(em)$asymp.UCL, mm$conf.high) +expect_equal(data.frame(em)$asymp.LCL, mm$conf.low) # old tests used to require pre-conversion diff --git a/inst/tinytest/test-predictions.R b/inst/tinytest/test-predictions.R index 211873ab1..99e6e6dda 100644 --- a/inst/tinytest/test-predictions.R +++ b/inst/tinytest/test-predictions.R @@ -3,6 +3,7 @@ using("marginaleffects") requiet("pscl") + tmp <- mtcars tmp$am <- as.logical(tmp$am) mod <- lm(mpg ~ hp + wt + factor(cyl) + am, data = tmp) @@ -239,5 +240,27 @@ p2 <- mod$family$linkinv(as.vector(p2)) expect_equivalent(p1, p2) +# Issue #1204: Swapped intervals for models with inverse-link +requiet("emmeans") +data(warpbreaks) + +mod <- glm(breaks ~ wool * tension, family = Gamma(), data = warpbreaks) +p <- predictions( + mod, + newdata = datagrid(grid_type = "balanced"), + by = c("wool", "tension"), + type = "invlink(link)") +expect_true(all(p$conf.low <= p$conf.high)) + +mod <- glm(breaks ~ wool * tension, family = Gamma("log"), data = warpbreaks) +p <- predictions(mod, + newdata = datagrid(grid_type = "balanced"), + by = c("wool", "tension"), + type = "invlink(link)") +expect_true(all(p$conf.low <= p$conf.high)) + + + + rm(list = ls()) From 25b3b4fc925a61e50f50a5e19173c84b1dec9846 Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Fri, 30 Aug 2024 21:37:07 -0400 Subject: [PATCH 8/9] issue #1202 default value of `type` `plot_comparison()` (#1206) --- DESCRIPTION | 2 +- NEWS.md | 3 ++- R/plot_comparisons.R | 2 +- R/plot_slopes.R | 2 +- inst/tinytest/test-pkg-tidymodels.R | 20 ++++++++++++++++++++ man/plot_comparisons.Rd | 2 +- man/plot_slopes.Rd | 2 +- 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 618f7a6a7..4c69d38aa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.21.0.20 +Version: 0.21.0.21 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", diff --git a/NEWS.md b/NEWS.md index 5ae659baf..5e26b184d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,9 +2,10 @@ ## Development -Breaking change: +Breaking changes: * `type="invlink(link)"` is no longer default in `avg_predictions()` or when calling `predictions()` with the `by` argument. It is still default in `predictions()` without the `by` argument. The backtransform strategy is still available with by setting `type="invlink(link)"` explicitly. +* The `type` argument in `plot_comparisons()` now defaults to `NULL`, which is now consistent with `comparisons()` and `avg_comparisons()`. Before, the default was `type="response"`. Thanks to @giakhang1906 for report #1202. New: diff --git a/R/plot_comparisons.R b/R/plot_comparisons.R index e99be3d6c..8ce4e5086 100644 --- a/R/plot_comparisons.R +++ b/R/plot_comparisons.R @@ -38,7 +38,7 @@ plot_comparisons <- function(model, condition = NULL, by = NULL, newdata = NULL, - type = "response", + type = NULL, vcov = NULL, conf_level = 0.95, wts = FALSE, diff --git a/R/plot_slopes.R b/R/plot_slopes.R index 6c0907de7..78eb208a5 100644 --- a/R/plot_slopes.R +++ b/R/plot_slopes.R @@ -48,7 +48,7 @@ plot_slopes <- function(model, condition = NULL, by = NULL, newdata = NULL, - type = "response", + type = NULL, vcov = NULL, conf_level = 0.95, wts = FALSE, diff --git a/inst/tinytest/test-pkg-tidymodels.R b/inst/tinytest/test-pkg-tidymodels.R index 77c3a2bba..9f3fd4353 100644 --- a/inst/tinytest/test-pkg-tidymodels.R +++ b/inst/tinytest/test-pkg-tidymodels.R @@ -58,6 +58,26 @@ expect_inherits(m, "slopes") expect_false("std.error" %in% colnames(m)) +# Issue #1202 +fit <- linear_reg() |> + set_engine("lm") |> + fit(hp ~ am * vs, data = mtcars) +p <- plot_predictions(fit, condition = "am", draw = FALSE) +expect_inherits(p, "data.frame") + +p <- plot_comparisons(fit, + variables = "am", + condition = "vs", + draw = FALSE) +expect_inherits(p, "data.frame") + +p <- plot_comparisons(fit, + variables = "am", + condition = "vs", + draw = FALSE) +expect_inherits(p, "data.frame") + + rm(list = ls()) diff --git a/man/plot_comparisons.Rd b/man/plot_comparisons.Rd index 6e9a95550..8ca30f128 100644 --- a/man/plot_comparisons.Rd +++ b/man/plot_comparisons.Rd @@ -10,7 +10,7 @@ plot_comparisons( condition = NULL, by = NULL, newdata = NULL, - type = "response", + type = NULL, vcov = NULL, conf_level = 0.95, wts = FALSE, diff --git a/man/plot_slopes.Rd b/man/plot_slopes.Rd index a69c79d11..dff579e0a 100644 --- a/man/plot_slopes.Rd +++ b/man/plot_slopes.Rd @@ -10,7 +10,7 @@ plot_slopes( condition = NULL, by = NULL, newdata = NULL, - type = "response", + type = NULL, vcov = NULL, conf_level = 0.95, wts = FALSE, From eb9a3c4a24f5a8f64e10718f28185356dd54115f Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Fri, 30 Aug 2024 22:06:59 -0400 Subject: [PATCH 9/9] Support `glmtoolbox::glmgee()` (#1207) * support glmtoolbox::glmgee() * fixup test * test fixup * supported models --- DESCRIPTION | 4 +++- NAMESPACE | 3 +++ NEWS.md | 12 ++++++++---- R/methods_glmtoolbox.R | 29 +++++++++++++++++++++++++++++ R/sanity_model.R | 1 + R/type_dictionary.R | 1 + data-raw/supported_models.csv | 1 + inst/tinytest/test-pkg-glmtoolbox.R | 14 ++++++++++++++ man/get_coef.Rd | 10 +++++++--- man/get_predict.Rd | 15 +++++++++------ man/set_coef.Rd | 12 ++++++++---- 11 files changed, 84 insertions(+), 18 deletions(-) create mode 100644 R/methods_glmtoolbox.R create mode 100644 inst/tinytest/test-pkg-glmtoolbox.R diff --git a/DESCRIPTION b/DESCRIPTION index 4c69d38aa..c6617ea30 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: marginaleffects Title: Predictions, Comparisons, Slopes, Marginal Means, and Hypothesis Tests -Version: 0.21.0.21 +Version: 0.21.0.22 Authors@R: c(person(given = "Vincent", family = "Arel-Bundock", @@ -92,6 +92,7 @@ Suggests: ggplot2, ggrepel, glmmTMB, + glmtoolbox, glmx, haven, here, @@ -237,6 +238,7 @@ Collate: 'methods_flexsurv.R' 'methods_gamlss.R' 'methods_glmmTMB.R' + 'methods_glmtoolbox.R' 'methods_glmx.R' 'methods_lme4.R' 'methods_mclogit.R' diff --git a/NAMESPACE b/NAMESPACE index a6095fb17..9c2e7b48f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ S3method(get_coef,data.frame) S3method(get_coef,default) S3method(get_coef,gam) S3method(get_coef,gamlss) +S3method(get_coef,glmgee) S3method(get_coef,glmmTMB) S3method(get_coef,lmerMod) S3method(get_coef,lmerModLmerTest) @@ -62,6 +63,7 @@ S3method(get_predict,flexsurvreg) S3method(get_predict,gamlss) S3method(get_predict,glimML) S3method(get_predict,glm) +S3method(get_predict,glmgee) S3method(get_predict,glmmPQL) S3method(get_predict,glmmTMB) S3method(get_predict,gsm) @@ -143,6 +145,7 @@ S3method(set_coef,flexsurvreg) S3method(set_coef,gamlss) S3method(set_coef,glimML) S3method(set_coef,glm) +S3method(set_coef,glmgee) S3method(set_coef,glmmPQL) S3method(set_coef,glmmTMB) S3method(set_coef,glmx) diff --git a/NEWS.md b/NEWS.md index 5e26b184d..f6c393975 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,13 +7,17 @@ Breaking changes: * `type="invlink(link)"` is no longer default in `avg_predictions()` or when calling `predictions()` with the `by` argument. It is still default in `predictions()` without the `by` argument. The backtransform strategy is still available with by setting `type="invlink(link)"` explicitly. * The `type` argument in `plot_comparisons()` now defaults to `NULL`, which is now consistent with `comparisons()` and `avg_comparisons()`. Before, the default was `type="response"`. Thanks to @giakhang1906 for report #1202. -New: +New models supported: + +* `stpm2`, `pstpm2`, `gsm`, and `aft` models from `rstpm2`. Thanks to @aghaynes and @mclements. +* `glm_weightit`, `coxph_weightit`, `multinom_weightit`, and `ordinal_weightit` models from `Weightit`. Thanks to @ngreifer. +* `glmmgee` from the `glmtoolbox` package. Thanks to @adrianolszewski for the request and @lhvanegasp for help with implementation. + +New feautres: -* `hypotheses(joint=TRUE)`: do not call `stats::nobs()` unless necessary. -* Added support for `stpm2`, `pstpm2`, `gsm`, and `aft` models from `rstpm2`. Thanks to @aghaynes and @mclements. -* Added support for `glm_weightit`, `coxph_weightit`, `multinom_weightit`, and `ordinal_weightit` models from `Weightit`. Thanks to @ngreifer. * Parallel computation with `future` is more efficient by chunking tasks to avoid passing large objects to every worker for every future. Issue #1158. * All columns of `newdata` are passed to the `hypothesis` function when `newdata` is supplied explicitly. Thanks to @gravesti for report #1175. +* `hypotheses(joint=TRUE)`: do not call `stats::nobs()` unless necessary. * `hypotheses()` supports formulas in the `hypothesis` argument: `hypotheses(model, hypothesis = ratio ~ reference)` * Global option: `options("marginaleffects_print_omit" = "s.value")` * Round significant digits for labels in `plot_predictions(mod, condition = list(x = "fivenum"))` diff --git a/R/methods_glmtoolbox.R b/R/methods_glmtoolbox.R new file mode 100644 index 000000000..9db3d4bdf --- /dev/null +++ b/R/methods_glmtoolbox.R @@ -0,0 +1,29 @@ +#' @include get_coef.R +#' @rdname get_coef +#' @export +get_coef.glmgee <- function(model, ...) { + b <- model$coefficients + b <- setNames(as.vector(b), row.names(b)) + return(b) +} + +#' @include set_coef.R +#' @rdname set_coef +#' @export +set_coef.glmgee <- function(model, coefs, ...) { + out <- model + idx <- match(row.names(out$coefficients), names(coefs)) + out$coefficients[, 1] <- coefs[idx] + return(out) +} + +#' @include get_predict.R +#' @rdname get_predict +#' @export +get_predict.glmgee <- function(model, newdata, ...) { + Yhat <- predict(model, newdata = newdata, type = "response") + out <- data.frame( + rowid = seq_len(nrow(Yhat)), + estimate = as.vector(Yhat)) + return(out) +} \ No newline at end of file diff --git a/R/sanity_model.R b/R/sanity_model.R index dbee0cee6..09655cda5 100644 --- a/R/sanity_model.R +++ b/R/sanity_model.R @@ -58,6 +58,7 @@ sanity_model_supported_class <- function(model) { "glmerMod", "glmrob", "glmmTMB", + "glmgee", c("glmmPQL", "lme"), "glimML", "glmx", diff --git a/R/type_dictionary.R b/R/type_dictionary.R index 12e6dff61..b6192c6cc 100644 --- a/R/type_dictionary.R +++ b/R/type_dictionary.R @@ -85,6 +85,7 @@ glm,response glm,link glmerMod,response glmerMod,link +glmgee,response glmrob,response glmrob,link glmmTMB,response diff --git a/data-raw/supported_models.csv b/data-raw/supported_models.csv index 5ff572658..5877edb05 100644 --- a/data-raw/supported_models.csv +++ b/data-raw/supported_models.csv @@ -42,6 +42,7 @@ gam,gam,TRUE,TRUE,,,U,U,TRUE,TRUE gamlss,gamlss,TRUE,TRUE,,,U,U,TRUE,TRUE geepack,geeglm,TRUE,TRUE,,,U,U,TRUE,TRUE glmmTMB,glmmTMB,TRUE,FALSE,,,U,U,TRUE,TRUE +glmtoolbox,glmgee,TRUE,TRUE,,, ,,, glmx,glmx,TRUE,TRUE,,,TRUE,U,U,U ivreg,ivreg,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,U,U lme4,glmer,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE diff --git a/inst/tinytest/test-pkg-glmtoolbox.R b/inst/tinytest/test-pkg-glmtoolbox.R new file mode 100644 index 000000000..baff81244 --- /dev/null +++ b/inst/tinytest/test-pkg-glmtoolbox.R @@ -0,0 +1,14 @@ +source("helpers.R") +using("marginaleffects") +requiet("glmtoolbox") + +data(spruces) +mod <- size ~ poly(days,4) + treat +fit <- glmgee(mod, id=tree, family=Gamma(log), corstr="AR-M-dependent(1)", data=spruces) + +s <- avg_slopes(fit) +expect_inherits(s, "slopes") +p <- avg_predictions(fit, by = "treat") +expect_inherits(p, "predictions") +k <- avg_comparisons(fit) +expect_inherits(k, "comparisons") diff --git a/man/get_coef.Rd b/man/get_coef.Rd index 33b1fc456..ab041b218 100644 --- a/man/get_coef.Rd +++ b/man/get_coef.Rd @@ -2,9 +2,10 @@ % Please edit documentation in R/get_coef.R, R/methods_MASS.R, R/methods_afex.R, % R/methods_betareg.R, R/methods_nnet.R, R/methods_brglm2.R, R/methods_brms.R, % R/methods_dataframe.R, R/methods_gamlss.R, R/methods_glmmTMB.R, -% R/methods_lme4.R, R/methods_mclogit.R, R/methods_mgcv.R, R/methods_mlm.R, -% R/methods_sampleSelection.R, R/methods_scam.R, R/methods_stats.R, -% R/methods_survey.R, R/methods_tidymodels.R +% R/methods_glmtoolbox.R, R/methods_lme4.R, R/methods_mclogit.R, +% R/methods_mgcv.R, R/methods_mlm.R, R/methods_sampleSelection.R, +% R/methods_scam.R, R/methods_stats.R, R/methods_survey.R, +% R/methods_tidymodels.R \name{get_coef} \alias{get_coef} \alias{get_coef.default} @@ -18,6 +19,7 @@ \alias{get_coef.data.frame} \alias{get_coef.gamlss} \alias{get_coef.glmmTMB} +\alias{get_coef.glmgee} \alias{get_coef.merMod} \alias{get_coef.lmerModLmerTest} \alias{get_coef.lmerMod} @@ -55,6 +57,8 @@ get_coef(model, ...) \method{get_coef}{glmmTMB}(model, ...) +\method{get_coef}{glmgee}(model, ...) + \method{get_coef}{merMod}(model, ...) \method{get_coef}{lmerModLmerTest}(model, ...) diff --git a/man/get_predict.Rd b/man/get_predict.Rd index 14a1c3052..9275573d9 100644 --- a/man/get_predict.Rd +++ b/man/get_predict.Rd @@ -4,12 +4,12 @@ % R/methods_betareg.R, R/methods_bife.R, R/methods_biglm.R, R/methods_nnet.R, % R/methods_brglm2.R, R/methods_brms.R, R/methods_crch.R, R/methods_dbarts.R, % R/methods_fixest.R, R/methods_flexsurv.R, R/methods_gamlss.R, -% R/methods_glmmTMB.R, R/methods_lme4.R, R/methods_mclogit.R, -% R/methods_mhurdle.R, R/methods_mlogit.R, R/methods_mlr3.R, -% R/methods_ordinal.R, R/methods_quantreg.R, R/methods_rms.R, -% R/methods_robustlmm.R, R/methods_rstanarm.R, R/methods_rstpm2.R, -% R/methods_stats.R, R/methods_survey.R, R/methods_survival.R, -% R/methods_tidymodels.R, R/methods_tobit1.R +% R/methods_glmmTMB.R, R/methods_glmtoolbox.R, R/methods_lme4.R, +% R/methods_mclogit.R, R/methods_mhurdle.R, R/methods_mlogit.R, +% R/methods_mlr3.R, R/methods_ordinal.R, R/methods_quantreg.R, +% R/methods_rms.R, R/methods_robustlmm.R, R/methods_rstanarm.R, +% R/methods_rstpm2.R, R/methods_stats.R, R/methods_survey.R, +% R/methods_survival.R, R/methods_tidymodels.R, R/methods_tobit1.R \name{get_predict} \alias{get_predict} \alias{get_predict.default} @@ -30,6 +30,7 @@ \alias{get_predict.flexsurvreg} \alias{get_predict.gamlss} \alias{get_predict.glmmTMB} +\alias{get_predict.glmgee} \alias{get_predict.merMod} \alias{get_predict.lmerModLmerTest} \alias{get_predict.lmerMod} @@ -103,6 +104,8 @@ get_predict(model, newdata, type, ...) ... ) +\method{get_predict}{glmgee}(model, newdata, ...) + \method{get_predict}{merMod}(model, newdata = insight::get_data(model), type = "response", ...) \method{get_predict}{lmerModLmerTest}(model, newdata = insight::get_data(model), type = "response", ...) diff --git a/man/set_coef.Rd b/man/set_coef.Rd index a33ebe8cc..32349355f 100644 --- a/man/set_coef.Rd +++ b/man/set_coef.Rd @@ -3,10 +3,11 @@ % R/methods_Rchoice.R, R/methods_afex.R, R/methods_aod.R, R/methods_betareg.R, % R/methods_nnet.R, R/methods_crch.R, R/methods_dataframe.R, % R/methods_flexsurv.R, R/methods_gamlss.R, R/methods_glmmTMB.R, -% R/methods_glmx.R, R/methods_lme4.R, R/methods_mlm.R, R/methods_nlme.R, -% R/methods_pscl.R, R/methods_robustlmm.R, R/methods_rstpm2.R, -% R/methods_sampleSelection.R, R/methods_scam.R, R/methods_stats.R, -% R/methods_survey.R, R/methods_survival.R, R/methods_tidymodels.R +% R/methods_glmtoolbox.R, R/methods_glmx.R, R/methods_lme4.R, +% R/methods_mlm.R, R/methods_nlme.R, R/methods_pscl.R, R/methods_robustlmm.R, +% R/methods_rstpm2.R, R/methods_sampleSelection.R, R/methods_scam.R, +% R/methods_stats.R, R/methods_survey.R, R/methods_survival.R, +% R/methods_tidymodels.R \name{set_coef} \alias{set_coef} \alias{set_coef.default} @@ -25,6 +26,7 @@ \alias{set_coef.flexsurvreg} \alias{set_coef.gamlss} \alias{set_coef.glmmTMB} +\alias{set_coef.glmgee} \alias{set_coef.glmx} \alias{set_coef.merMod} \alias{set_coef.lmerModLmerTest} @@ -83,6 +85,8 @@ set_coef(model, coefs, ...) \method{set_coef}{glmmTMB}(model, coefs, ...) +\method{set_coef}{glmgee}(model, coefs, ...) + \method{set_coef}{glmx}(model, coefs, ...) \method{set_coef}{merMod}(model, coefs, ...)