diff --git a/DESCRIPTION b/DESCRIPTION index 4c7a1ffe..238fc44d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,28 +1,28 @@ Type: Package Package: modelbased Title: Estimation of Model-Based Predictions, Contrasts and Means -Version: 0.8.8.1 +Version: 0.8.9 Authors@R: c(person(given = "Dominique", family = "Makowski", role = c("aut", "cre"), email = "dom.makowski@gmail.com", - comment = c(ORCID = "0000-0001-5375-9967", Twitter = "@Dom_Makowski")), + comment = c(ORCID = "0000-0001-5375-9967")), person(given = "Daniel", family = "Lüdecke", role = "aut", email = "d.luedecke@uke.de", - comment = c(ORCID = "0000-0002-8895-3206", Twitter = "@strengejacke")), + comment = c(ORCID = "0000-0002-8895-3206")), person(given = "Mattan S.", family = "Ben-Shachar", role = "aut", email = "matanshm@post.bgu.ac.il", - comment = c(ORCID = "0000-0002-4287-4801", Twitter = "@mattansb")), + comment = c(ORCID = "0000-0002-4287-4801")), person(given = "Indrajeet", family = "Patil", role = "aut", email = "patilindrajeet.science@gmail.com", - comment = c(ORCID = "0000-0003-1995-6531", Twitter = "@patilindrajeets"))) + comment = c(ORCID = "0000-0003-1995-6531"))) Maintainer: Dominique Makowski Description: Implements a general interface for model-based estimations for a wide variety of models, used in the computation of @@ -69,7 +69,7 @@ VignetteBuilder: knitr Encoding: UTF-8 Language: en-US -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Config/testthat/edition: 3 Config/testthat/parallel: true Roxygen: list(markdown = TRUE) diff --git a/R/estimate_contrasts.R b/R/estimate_contrasts.R index 82debbce..b8d4749d 100644 --- a/R/estimate_contrasts.R +++ b/R/estimate_contrasts.R @@ -14,7 +14,8 @@ #' #' @inherit estimate_slopes details #' -#' @examplesIf require("emmeans", quietly = TRUE) +#' @examplesIf require("lme4", quietly = TRUE) && require("emmeans", quietly = TRUE) && require("rstanarm", quietly = TRUE) +#' \dontrun{ #' # Basic usage #' model <- lm(Sepal.Width ~ Species, data = iris) #' estimate_contrasts(model) @@ -44,7 +45,6 @@ #' estimated <- estimate_contrasts(lm(Sepal.Width ~ Species, data = iris)) #' standardize(estimated) #' -#' @examplesIf require("lme4", quietly = TRUE) && require("emmeans", quietly = TRUE) #' # Other models (mixed, Bayesian, ...) #' data <- iris #' data$Petal.Length_factor <- ifelse(data$Petal.Length < 4.2, "A", "B") @@ -52,10 +52,8 @@ #' model <- lme4::lmer(Sepal.Width ~ Species + (1 | Petal.Length_factor), data = data) #' estimate_contrasts(model) #' -#' @examplesIf require("rstanarm", quietly = TRUE) && require("emmeans", quietly = TRUE) #' library(rstanarm) #' -#' \donttest{ #' data <- mtcars #' data$cyl <- as.factor(data$cyl) #' data$am <- as.factor(data$am) diff --git a/R/estimate_slopes.R b/R/estimate_slopes.R index d3587927..1e094f23 100644 --- a/R/estimate_slopes.R +++ b/R/estimate_slopes.R @@ -122,8 +122,12 @@ estimate_slopes <- function(model, if (insight::model_info(model)$is_bayesian) { trends <- parameters::parameters(estimated, ci = ci, ...) trends <- .clean_names_bayesian(trends, model, transform = "none", type = "trend") - trends <- cbind(estimated@grid, trends) - trends[[".wgt."]] <- NULL # Drop the weight column + em_grid <- as.data.frame(estimated@grid) + em_grid[[".wgt."]] <- NULL # Drop the weight column + colums_to_add <- setdiff(colnames(em_grid), colnames(trends)) + if (length(colums_to_add)) { + trends <- cbind(em_grid[colums_to_add], trends) + } } else { trends <- parameters::parameters(estimated, ci = ci, ...) } diff --git a/man/estimate_contrasts.Rd b/man/estimate_contrasts.Rd index 790a74d5..873a483a 100644 --- a/man/estimate_contrasts.Rd +++ b/man/estimate_contrasts.Rd @@ -123,7 +123,8 @@ the effect of x averaged over all conditions, or instead within each condition (\code{using [estimate_slopes]}). } \examples{ -\dontshow{if (require("emmeans", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("lme4", quietly = TRUE) && require("emmeans", quietly = TRUE) && require("rstanarm", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontrun{ # Basic usage model <- lm(Sepal.Width ~ Species, data = iris) estimate_contrasts(model) @@ -152,19 +153,16 @@ estimate_contrasts(model, by = "Petal.Width", length = 4) # Standardized differences estimated <- estimate_contrasts(lm(Sepal.Width ~ Species, data = iris)) standardize(estimated) -\dontshow{\}) # examplesIf} -\dontshow{if (require("lme4", quietly = TRUE) && require("emmeans", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} + # Other models (mixed, Bayesian, ...) data <- iris data$Petal.Length_factor <- ifelse(data$Petal.Length < 4.2, "A", "B") model <- lme4::lmer(Sepal.Width ~ Species + (1 | Petal.Length_factor), data = data) estimate_contrasts(model) -\dontshow{\}) # examplesIf} -\dontshow{if (require("rstanarm", quietly = TRUE) && require("emmeans", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} + library(rstanarm) -\donttest{ data <- mtcars data$cyl <- as.factor(data$cyl) data$am <- as.factor(data$am) diff --git a/man/modelbased-package.Rd b/man/modelbased-package.Rd index d2e92fe2..6c3cc50d 100644 --- a/man/modelbased-package.Rd +++ b/man/modelbased-package.Rd @@ -21,13 +21,13 @@ Useful links: } \author{ -\strong{Maintainer}: Dominique Makowski \email{dom.makowski@gmail.com} (\href{https://orcid.org/0000-0001-5375-9967}{ORCID}) (@Dom_Makowski) +\strong{Maintainer}: Dominique Makowski \email{dom.makowski@gmail.com} (\href{https://orcid.org/0000-0001-5375-9967}{ORCID}) Authors: \itemize{ - \item Daniel Lüdecke \email{d.luedecke@uke.de} (\href{https://orcid.org/0000-0002-8895-3206}{ORCID}) (@strengejacke) - \item Mattan S. Ben-Shachar \email{matanshm@post.bgu.ac.il} (\href{https://orcid.org/0000-0002-4287-4801}{ORCID}) (@mattansb) - \item Indrajeet Patil \email{patilindrajeet.science@gmail.com} (\href{https://orcid.org/0000-0003-1995-6531}{ORCID}) (@patilindrajeets) + \item Daniel Lüdecke \email{d.luedecke@uke.de} (\href{https://orcid.org/0000-0002-8895-3206}{ORCID}) + \item Mattan S. Ben-Shachar \email{matanshm@post.bgu.ac.il} (\href{https://orcid.org/0000-0002-4287-4801}{ORCID}) + \item Indrajeet Patil \email{patilindrajeet.science@gmail.com} (\href{https://orcid.org/0000-0003-1995-6531}{ORCID}) } }