diff --git a/NAMESPACE b/NAMESPACE index f04f3af3..4366caf0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -43,7 +43,6 @@ S3method(model_get_model_matrix,clm) S3method(model_get_model_matrix,default) S3method(model_get_model_matrix,fixest) S3method(model_get_model_matrix,glmmTMB) -S3method(model_get_model_matrix,mmrm) S3method(model_get_model_matrix,model_fit) S3method(model_get_model_matrix,multinom) S3method(model_get_model_matrix,plm) @@ -71,10 +70,8 @@ S3method(model_get_terms,betareg) S3method(model_get_terms,brmsfit) S3method(model_get_terms,default) S3method(model_get_terms,glmmTMB) -S3method(model_get_terms,mmrm) S3method(model_get_terms,model_fit) S3method(model_get_weights,default) -S3method(model_get_weights,mmrm) S3method(model_get_weights,model_fit) S3method(model_get_weights,svyglm) S3method(model_get_xlevels,brmsfit) @@ -83,7 +80,6 @@ S3method(model_get_xlevels,felm) S3method(model_get_xlevels,glmerMod) S3method(model_get_xlevels,glmmTMB) S3method(model_get_xlevels,lmerMod) -S3method(model_get_xlevels,mmrm) S3method(model_get_xlevels,model_fit) S3method(model_get_xlevels,plm) S3method(model_identify_variables,aov) diff --git a/R/model_get_model_matrix.R b/R/model_get_model_matrix.R index 046d9768..a957628a 100644 --- a/R/model_get_model_matrix.R +++ b/R/model_get_model_matrix.R @@ -122,15 +122,6 @@ model_get_model_matrix.LORgee <- function(model, ...) { ) } -#' @export -#' @rdname model_get_model_matrix -model_get_model_matrix.mmrm <- function(model, ...) { - stats::model.matrix.default( - model %>% model_get_terms(), - data = stats::model.frame(model) - ) -} - #' @export #' @rdname model_get_model_matrix model_get_model_matrix.betareg <- function(model, ...) { diff --git a/R/model_get_terms.R b/R/model_get_terms.R index 8fe2b4f4..718ed2c2 100644 --- a/R/model_get_terms.R +++ b/R/model_get_terms.R @@ -50,12 +50,6 @@ model_get_terms.model_fit <- function(model) { model_get_terms(model$fit) } -#' @export -#' @rdname model_get_terms -model_get_terms.mmrm <- function(model) { - model$formula_parts$model_formula %>% stats::terms() -} - #' @export #' @rdname model_get_terms model_get_terms.betareg <- function(model) { diff --git a/R/model_get_weights.R b/R/model_get_weights.R index f972b2af..3c0e75d1 100644 --- a/R/model_get_weights.R +++ b/R/model_get_weights.R @@ -74,11 +74,3 @@ model_get_weights.svyglm <- function(model) { model_get_weights.model_fit <- function(model) { model_get_weights(model$fit) } - -#' @export -#' @rdname model_get_weights -model_get_weights.mmrm <- function(model) { - w <- stats::weights(model) - mf <- model %>% model_get_model_frame() - w[as.integer(row.names(mf))] -} diff --git a/R/model_get_xlevels.R b/R/model_get_xlevels.R index e07499c5..ba5b60e6 100644 --- a/R/model_get_xlevels.R +++ b/R/model_get_xlevels.R @@ -81,13 +81,3 @@ model_get_xlevels.plm <- model_get_xlevels.lmerMod model_get_xlevels.model_fit <- function(model) { model_get_xlevels(model$fit) } - -#' @export -#' @rdname model_get_xlevels -model_get_xlevels.mmrm <- function(model) { - xlevels <- stats::.getXlevels( - model %>% model_get_terms(), - model %>% model_get_model_frame() - ) - xlevels %>% .add_xlevels_for_logical_variables(model) -} diff --git a/man/model_get_model_matrix.Rd b/man/model_get_model_matrix.Rd index 73380194..6d57172a 100644 --- a/man/model_get_model_matrix.Rd +++ b/man/model_get_model_matrix.Rd @@ -12,7 +12,6 @@ \alias{model_get_model_matrix.model_fit} \alias{model_get_model_matrix.fixest} \alias{model_get_model_matrix.LORgee} -\alias{model_get_model_matrix.mmrm} \alias{model_get_model_matrix.betareg} \title{Get the model matrix of a model} \usage{ @@ -38,8 +37,6 @@ model_get_model_matrix(model, ...) \method{model_get_model_matrix}{LORgee}(model, ...) -\method{model_get_model_matrix}{mmrm}(model, ...) - \method{model_get_model_matrix}{betareg}(model, ...) } \arguments{ diff --git a/man/model_get_terms.Rd b/man/model_get_terms.Rd index add432ea..d45c0b54 100644 --- a/man/model_get_terms.Rd +++ b/man/model_get_terms.Rd @@ -6,7 +6,6 @@ \alias{model_get_terms.brmsfit} \alias{model_get_terms.glmmTMB} \alias{model_get_terms.model_fit} -\alias{model_get_terms.mmrm} \alias{model_get_terms.betareg} \title{Get the terms of a model} \usage{ @@ -20,8 +19,6 @@ model_get_terms(model) \method{model_get_terms}{model_fit}(model) -\method{model_get_terms}{mmrm}(model) - \method{model_get_terms}{betareg}(model) } \arguments{ diff --git a/man/model_get_weights.Rd b/man/model_get_weights.Rd index fc16e230..7e4718d4 100644 --- a/man/model_get_weights.Rd +++ b/man/model_get_weights.Rd @@ -5,7 +5,6 @@ \alias{model_get_weights.default} \alias{model_get_weights.svyglm} \alias{model_get_weights.model_fit} -\alias{model_get_weights.mmrm} \title{Get sampling weights used by a model} \usage{ model_get_weights(model) @@ -15,8 +14,6 @@ model_get_weights(model) \method{model_get_weights}{svyglm}(model) \method{model_get_weights}{model_fit}(model) - -\method{model_get_weights}{mmrm}(model) } \arguments{ \item{model}{a model object} diff --git a/man/model_get_xlevels.Rd b/man/model_get_xlevels.Rd index 0dcd8940..67438efa 100644 --- a/man/model_get_xlevels.Rd +++ b/man/model_get_xlevels.Rd @@ -10,7 +10,6 @@ \alias{model_get_xlevels.glmmTMB} \alias{model_get_xlevels.plm} \alias{model_get_xlevels.model_fit} -\alias{model_get_xlevels.mmrm} \title{Get xlevels used in the model} \usage{ model_get_xlevels(model) @@ -30,8 +29,6 @@ model_get_xlevels(model) \method{model_get_xlevels}{plm}(model) \method{model_get_xlevels}{model_fit}(model) - -\method{model_get_xlevels}{mmrm}(model) } \arguments{ \item{model}{a model object} diff --git a/tests/testthat/test-tidy_plus_plus.R b/tests/testthat/test-tidy_plus_plus.R index e73dcdd3..a6da970b 100644 --- a/tests/testthat/test-tidy_plus_plus.R +++ b/tests/testthat/test-tidy_plus_plus.R @@ -896,6 +896,38 @@ test_that("tidy_plus_plus() works with betareg::betareg() models", { expect_equal(nrow(res), 24) }) +test_that("tidy_plus_plus() works with mmrm::mmrm() models", { + skip_on_cran() + skip_if_not_installed("mmrm") + + m1 <- mmrm::mmrm(FEV1 ~ SEX + ARMCD + AVISIT + us(AVISIT | USUBJID), data = mmrm::fev_data) + m2 <- mmrm::mmrm(FEV1 ~ SEX + ARMCD * AVISIT + us(AVISIT | USUBJID), data = mmrm::fev_data) + + expect_error( + res <- m1 %>% tidy_plus_plus(intercept = TRUE), + NA + ) + expect_equal(nrow(res), 9) + + expect_error( + res <- m1 %>% tidy_plus_plus(add_header_rows = TRUE), + NA + ) + expect_equal(nrow(res), 11) + + expect_error( + res <- m2 %>% tidy_plus_plus(intercept = TRUE), + NA + ) + expect_equal(nrow(res), 12) + + expect_error( + res <- m2 %>% tidy_plus_plus(add_header_rows = TRUE), + NA + ) + expect_equal(nrow(res), 15) +}) + test_that("tidy_post_fun argument of `tidy_plus_plus()`", { mod <- lm(Petal.Length ~ Petal.Width + Species, iris)