From 9f2fbc6bd1a36e78c90d423d333cc768973c28bf Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 13 Oct 2026 23:05:51 +0300 Subject: [PATCH 01/33] new lmerMod methods --- NAMESPACE | 42 ++++++++----- R/methods_lme4.R | 152 +++++++++++++++++++++++++++++++---------------- 2 files changed, 127 insertions(+), 67 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 7f8dca0f9..e663ab21e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -59,6 +59,7 @@ S3method(ci,list) S3method(ci,lm) S3method(ci,lm_robust) S3method(ci,lme) +S3method(ci,lmerMod) S3method(ci,lmodel2) S3method(ci,logistf) S3method(ci,logitmfx) @@ -288,6 +289,7 @@ S3method(model_parameters,lcmm) S3method(model_parameters,list) S3method(model_parameters,lm_robust) S3method(model_parameters,lme) +S3method(model_parameters,lmerMod) S3method(model_parameters,lmodel2) S3method(model_parameters,logistf) S3method(model_parameters,logitmfx) @@ -500,6 +502,7 @@ S3method(p_value,list) S3method(p_value,lm) S3method(p_value,lm_robust) S3method(p_value,lme) +S3method(p_value,lmerMod) S3method(p_value,lmodel2) S3method(p_value,logistf) S3method(p_value,logitmfx) @@ -851,6 +854,7 @@ S3method(standard_error,lcmm) S3method(standard_error,list) S3method(standard_error,lm_robust) S3method(standard_error,lme) +S3method(standard_error,lmerMod) S3method(standard_error,lmodel2) S3method(standard_error,logistf) S3method(standard_error,logitmfx) @@ -1040,20 +1044,26 @@ export(standardize_parameters) export(standardize_posteriors) export(supported_models) export(visualisation_recipe) -importFrom(bayestestR,ci) -importFrom(bayestestR,equivalence_test) -importFrom(bayestestR,p_direction) -importFrom(bayestestR,p_significance) -importFrom(datawizard,demean) -importFrom(datawizard,describe_distribution) -importFrom(datawizard,kurtosis) -importFrom(datawizard,rescale_weights) -importFrom(datawizard,skewness) -importFrom(datawizard,visualisation_recipe) +importFrom(bayestestR, + ci, + equivalence_test, + p_direction, + p_significance +) +importFrom(datawizard, + demean, + describe_distribution, + kurtosis, + rescale_weights, + skewness, + visualisation_recipe +) importFrom(graphics,plot) -importFrom(insight,display) -importFrom(insight,n_parameters) -importFrom(insight,print_html) -importFrom(insight,print_md) -importFrom(insight,standardize_names) -importFrom(insight,supported_models) +importFrom(insight, + display, + n_parameters, + print_html, + print_md, + standardize_names, + supported_models +) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 354dda08d..18a5518ae 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -1,56 +1,8 @@ -############# .merMod ----------------- +# merMod ----------------------------------------------------------------- #' @export model_parameters.merMod <- model_parameters.coxme -# helper ---------------------------------------------------------------------- - -.add_random_effects_lme4 <- function( - model, - params, - ci, - ci_method, - ci_random, - effects, - group_level, - verbose = TRUE, - ... -) { - params_random <- params_variance <- NULL - - # only proceed if random effects are requested - if (effects %in% c("random", "all")) { - # group level estimates (BLUPs) or random effects variances? - if (isTRUE(group_level)) { - params_random <- .extract_random_parameters(model, ci = ci, effects = effects) - } else { - params_variance <- .extract_random_variances( - model, - ci = ci, - effects = effects, - ci_method = ci_method, - ci_random = ci_random, - verbose = verbose - ) - } - - # merge random and fixed effects, if necessary - if (!is.null(params) && (!is.null(params_random) || !is.null(params_variance))) { - params$Level <- NA - params$Group <- "" - - if (is.null(params_random)) { - params <- params[match(colnames(params_variance), colnames(params))] - } else { - params <- params[match(colnames(params_random), colnames(params))] - } - } - } - - rbind(params, params_random, params_variance) -} - - #' @export ci.merMod <- function(x, ci = 0.95, dof = NULL, method = "wald", iterations = 500, ...) { method <- tolower(method) @@ -135,9 +87,92 @@ standard_error.merMod <- function( out } +#' @export +p_value.merMod <- p_value.cpglmm + + +# lmerMod and lmerModTest ----------------------------------------------------------------- + +#' @export +model_parameters.lmerMod <- function() { + NextMethod( + "model_parameters", + model, + ci_method = .attempt_satterthwaite_method(ci_method) + ) +} +formals(model_parameters.lmerMod) <- formals(model_parameters.merMod) +formals(model_parameters.lmerMod)$ci_method <- NULL + +#' @export +ci.lmerMod <- function() { + NextMethod("ci", x, method = .attempt_satterthwaite_method(method)) +} +formals(ci.lmerMod) <- formals(ci.merMod) +formals(ci.lmerMod)$method <- NULL + +#' @export +standard_error.lmerMod <- function() { + NextMethod("standard_error", model, method = .attempt_satterthwaite_method(method)) +} +formals(standard_error.lmerMod) <- formals(standard_error.merMod) +formals(standard_error.lmerMod)$method <- NULL + +#' @export +p_value.lmerMod <- function() { + NextMethod("p_value", model, method = .attempt_satterthwaite_method(method)) +} +formals(p_value.lmerMod) <- formals(p_value.merMod) +formals(p_value.lmerMod)$method <- NULL + # helpers -------------- +.add_random_effects_lme4 <- function( + model, + params, + ci, + ci_method, + ci_random, + effects, + group_level, + verbose = TRUE, + ... +) { + params_random <- params_variance <- NULL + + # only proceed if random effects are requested + if (effects %in% c("random", "all")) { + # group level estimates (BLUPs) or random effects variances? + if (isTRUE(group_level)) { + params_random <- .extract_random_parameters(model, ci = ci, effects = effects) + } else { + params_variance <- .extract_random_variances( + model, + ci = ci, + effects = effects, + ci_method = ci_method, + ci_random = ci_random, + verbose = verbose + ) + } + + # merge random and fixed effects, if necessary + if (!is.null(params) && (!is.null(params_random) || !is.null(params_variance))) { + params$Level <- NA + params$Group <- "" + + if (is.null(params_random)) { + params <- params[match(colnames(params_variance), colnames(params))] + } else { + params <- params[match(colnames(params_random), colnames(params))] + } + } + } + + rbind(params, params_random, params_variance) +} + .standard_errors_random <- function(model) { insight::check_if_installed("lme4") @@ -172,6 +207,21 @@ se_mixed_default <- function(model) { .data_frame(Parameter = params, SE = .get_se_from_summary(model)) } +.attempt_satterthwaite_method <- function(method, fallback = "wald") { + if (!is.null(method)) { + return(method) + } + + if ( + insight::check_if_installed( + package = "lmerTest", + reason = "for Satterthwaite df (default)", + stop = FALSE, + prompt = TRUE + ) + ) { + return("satterthwaite") + } -#' @export -p_value.merMod <- p_value.cpglmm + return(fallback) +} From 4c4f2598a00d3d8ee7d31d26843f98a585e90bbd Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 13 Oct 2026 23:06:14 +0300 Subject: [PATCH 02/33] docs --- R/1_model_parameters.R | 2 ++ man/ci.default.Rd | 2 ++ man/model_parameters.Rd | 2 ++ man/model_parameters.brmsfit.Rd | 2 ++ man/model_parameters.default.Rd | 2 ++ man/model_parameters.glmmTMB.Rd | 2 ++ man/p_value.Rd | 2 ++ 7 files changed, 14 insertions(+) diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index 5940d8668..f8f91befb 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -196,6 +196,8 @@ #' - Applies to *linear mixed models*. CIs computed using the #' Wald method (SE and a *t-distribution with Satterthwaite df*); p-values #' computed using the Wald method with a *t-distribution with Satterthwaite df*. +#' This is the default for `lmerMod` and `lmerModLmerTest` when the corresponding +#' method argument (`ci_method` or `method`) is `NULL`. #' #' `"kenward"` #' - Applies to *linear mixed models*. CIs computed using the Wald diff --git a/man/ci.default.Rd b/man/ci.default.Rd index 4c4b64b90..eb1887f97 100644 --- a/man/ci.default.Rd +++ b/man/ci.default.Rd @@ -141,6 +141,8 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. +This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL}. } \code{"kenward"} diff --git a/man/model_parameters.Rd b/man/model_parameters.Rd index 769e191cb..2c1829120 100644 --- a/man/model_parameters.Rd +++ b/man/model_parameters.Rd @@ -221,6 +221,8 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. +This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL}. } \code{"kenward"} diff --git a/man/model_parameters.brmsfit.Rd b/man/model_parameters.brmsfit.Rd index 07efe8b65..1319cade2 100644 --- a/man/model_parameters.brmsfit.Rd +++ b/man/model_parameters.brmsfit.Rd @@ -298,6 +298,8 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. +This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL}. } \code{"kenward"} diff --git a/man/model_parameters.default.Rd b/man/model_parameters.default.Rd index ed48da46e..393dc66d3 100644 --- a/man/model_parameters.default.Rd +++ b/man/model_parameters.default.Rd @@ -226,6 +226,8 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. +This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL}. } \code{"kenward"} diff --git a/man/model_parameters.glmmTMB.Rd b/man/model_parameters.glmmTMB.Rd index 419eb0cc0..87bc75f1c 100644 --- a/man/model_parameters.glmmTMB.Rd +++ b/man/model_parameters.glmmTMB.Rd @@ -402,6 +402,8 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. +This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL}. } \code{"kenward"} diff --git a/man/p_value.Rd b/man/p_value.Rd index e85c7e623..c5fb5826b 100644 --- a/man/p_value.Rd +++ b/man/p_value.Rd @@ -159,6 +159,8 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. +This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL}. } \code{"kenward"} From 90d8a87726fae701a52ebf0e01c6263dd7097a03 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 13 Oct 2026 23:06:24 +0300 Subject: [PATCH 03/33] news and version bump --- DESCRIPTION | 4 ++-- NEWS.md | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 10e414f84..6a6f75547 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.29.3.21 +Version: 0.29.3.22 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -241,5 +241,5 @@ Config/testthat/parallel: false Config/Needs/website: easystats/easystatstemplate Config/Needs/check: stan-dev/cmdstanr Config/rcmdcheck/ignore-inconsequential-notes: true -Config/roxygen2/version: 8.0.0 +Config/roxygen2/version: 8.1.0 Remotes: easystats/insight, glmmTMB/glmmTMB/glmmTMB diff --git a/NEWS.md b/NEWS.md index caa8293f4..e75430fff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ # parameters (devel) +## Breaking Changes + +* `model_parameters()`, `ci()`, `standard_error()`, and `p_value()` now default + to the Satterthwaite approximation for `lmerMod` and `lmerModTest` models when + `{lmerTest}` is available, making the outputs more consistent with `summary()` + (#989). + ## Changes * `model_parameters()` now saves information about the type of HC-vcov From 7cb0086e1146131ccdb745f39e65e6ce32ac432c Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 13 Oct 2026 23:13:52 +0300 Subject: [PATCH 04/33] use explicit function def --- R/methods_lme4.R | 68 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 18a5518ae..e78ef75d4 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -94,36 +94,64 @@ p_value.merMod <- p_value.cpglmm # lmerMod and lmerModTest ----------------------------------------------------------------- #' @export -model_parameters.lmerMod <- function() { - NextMethod( - "model_parameters", - model, - ci_method = .attempt_satterthwaite_method(ci_method) - ) +model_parameters.lmerMod <- function( + model, + ci = 0.95, + ci_method = NULL, + ci_random = NULL, + bootstrap = FALSE, + iterations = 1000, + standardize = NULL, + effects = "all", + group_level = FALSE, + exponentiate = FALSE, + p_adjust = NULL, + vcov = NULL, + vcov_args = NULL, + wb_component = FALSE, + include_info = getOption("parameters_mixed_info", FALSE), + include_sigma = FALSE, + keep = NULL, + drop = NULL, + verbose = TRUE, + ... +) { + cl <- match.call() + cl[[1]] <- model_parameters.merMod + cl$ci_method <- .attempt_satterthwaite_method(ci_method) + eval.parent(cl) } -formals(model_parameters.lmerMod) <- formals(model_parameters.merMod) -formals(model_parameters.lmerMod)$ci_method <- NULL #' @export -ci.lmerMod <- function() { - NextMethod("ci", x, method = .attempt_satterthwaite_method(method)) +ci.lmerMod <- function(x, ci = 0.95, dof = NULL, method = NULL, iterations = 500, ...) { + cl <- match.call() + cl[[1]] <- ci.merMod + cl$method <- .attempt_satterthwaite_method(method) + eval.parent(cl) } -formals(ci.lmerMod) <- formals(ci.merMod) -formals(ci.lmerMod)$method <- NULL #' @export -standard_error.lmerMod <- function() { - NextMethod("standard_error", model, method = .attempt_satterthwaite_method(method)) +standard_error.lmerMod <- function( + model, + effects = "fixed", + method = NULL, + vcov = NULL, + vcov_args = NULL, + ... +) { + cl <- match.call() + cl[[1]] <- standard_error.merMod + cl$method <- .attempt_satterthwaite_method(method) + eval.parent(cl) } -formals(standard_error.lmerMod) <- formals(standard_error.merMod) -formals(standard_error.lmerMod)$method <- NULL #' @export -p_value.lmerMod <- function() { - NextMethod("p_value", model, method = .attempt_satterthwaite_method(method)) +p_value.lmerMod <- function(model, method = NULL, ...) { + cl <- match.call() + cl[[1]] <- p_value.merMod + cl$method <- .attempt_satterthwaite_method(method) + eval.parent(cl) } -formals(p_value.lmerMod) <- formals(p_value.merMod) -formals(p_value.lmerMod)$method <- NULL # helpers -------------- From 66e06c89ff61d373e965fae9a17e821c1cd665c5 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 13 Oct 2026 23:32:32 +0300 Subject: [PATCH 05/33] Update methods_lme4.R --- R/methods_lme4.R | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index e78ef75d4..172398ab2 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -240,14 +240,21 @@ se_mixed_default <- function(model) { return(method) } - if ( - insight::check_if_installed( - package = "lmerTest", - reason = "for Satterthwaite df (default)", - stop = FALSE, - prompt = TRUE - ) - ) { + installed <- insight::check_if_installed( + package = "lmerTest", + reason = "for Satterthwaite df (default)", + stop = FALSE, + prompt = TRUE + ) + + # This is a workaround for the fact that check_if_installed() returns FALSE + # even if the package is not installed, but the user chooses to install it. In + # that case, we need to check again if the package is actually installed. + if (!installed) { + installed <- requireNamespace("lmerTest", quietly = TRUE) + } + + if (installed) { return("satterthwaite") } From 7671027f301423647c0dfb9f59dbf60d79311a23 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 13 Oct 2026 23:56:48 +0300 Subject: [PATCH 06/33] don't use Satterthwaite when bootstrapping --- R/methods_lme4.R | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 172398ab2..fab632b2a 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -118,7 +118,7 @@ model_parameters.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- model_parameters.merMod - cl$ci_method <- .attempt_satterthwaite_method(ci_method) + cl$ci_method <- .attempt_satterthwaite_method(ci_method, bootstrap = bootstrap) eval.parent(cl) } @@ -235,16 +235,15 @@ se_mixed_default <- function(model) { .data_frame(Parameter = params, SE = .get_se_from_summary(model)) } -.attempt_satterthwaite_method <- function(method, fallback = "wald") { - if (!is.null(method)) { +.attempt_satterthwaite_method <- function(method, fallback = "wald", bootstrap = FALSE) { + if (!is.null(method) || bootstrap) { return(method) } installed <- insight::check_if_installed( package = "lmerTest", reason = "for Satterthwaite df (default)", - stop = FALSE, - prompt = TRUE + stop = FALSE ) # This is a workaround for the fact that check_if_installed() returns FALSE From 324cd55019649d3b948b2dee12c260f01b12b267 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Wed, 14 Oct 2026 00:03:05 +0300 Subject: [PATCH 07/33] add tests --- tests/testthat/test-lmerTest.R | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-lmerTest.R b/tests/testthat/test-lmerTest.R index b0706718c..df8f4bdc8 100644 --- a/tests/testthat/test-lmerTest.R +++ b/tests/testthat/test-lmerTest.R @@ -4,7 +4,10 @@ skip_if_not_installed("lmerTest") skip_if_not_installed("pbkrtest") data("carrots", package = "lmerTest") -m1 <- lmerTest::lmer(Preference ~ sens2 + Homesize + (1 + sens2 | Consumer), data = carrots) +m1 <- lmerTest::lmer( + Preference ~ sens2 + Homesize + (1 + sens2 | Consumer), + data = carrots +) test_that("model_parameters, satterthwaite", { params <- model_parameters(m1, effects = "fixed", ci_method = "satterthwaite") @@ -21,3 +24,28 @@ test_that("model_parameters, kenward", { expect_equal(params$t, as.vector(s$coefficients[, "t value"]), tolerance = 1e-4) expect_equal(params$p, as.vector(s$coefficients[, "Pr(>|t|)"]), tolerance = 1e-4) }) + + +test_that("mixed-model defaults use satterthwaite for lmerMod", { + params_default <- model_parameters(m1, effects = "fixed") + params_satterthwaite <- model_parameters(m1, effects = "fixed", ci_method = "s") + params_wald <- model_parameters(m1, effects = "fixed", ci_method = "wald") + + expect_identical(params_default, params_satterthwaite) + expect_false(identical(params_default, params_wald)) + expect_true(all(params_wald$p < params_default$p)) + expect_identical(params_wald$t, params_default$t) + + expect_identical(ci(m1), ci(m1, method = "satterthwaite")) + expect_identical(standard_error(m1), standard_error(m1, method = "satterthwaite")) + expect_identical(p_value(m1), p_value(m1, method = "satterthwaite")) + + glmer_model <- lme4::glmer(vs ~ cyl + (1 | gear), data = mtcars, family = "binomial") + + expect_identical(ci(glmer_model), ci(glmer_model, method = "wald")) + expect_identical( + standard_error(glmer_model), + standard_error(glmer_model, method = "wald") + ) + expect_identical(p_value(glmer_model), p_value(glmer_model, method = "wald")) +}) From 23f2bd075bce50a031df6573a1b5cd2dcddf6b8f Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Wed, 14 Oct 2026 00:07:33 +0300 Subject: [PATCH 08/33] fix some tests --- tests/testthat/_snaps/glmer.md | 83 ++---------------- .../testthat/_snaps/model_parameters.mixed.md | 84 +++++++++---------- tests/testthat/test-lavaan.R | 4 +- tests/testthat/test-random_effects_ci.R | 3 +- 4 files changed, 52 insertions(+), 122 deletions(-) diff --git a/tests/testthat/_snaps/glmer.md b/tests/testthat/_snaps/glmer.md index 91d43a084..9632f078b 100644 --- a/tests/testthat/_snaps/glmer.md +++ b/tests/testthat/_snaps/glmer.md @@ -1,72 +1,3 @@ -# print model_parameters - - Code - params - Output - # Fixed Effects - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -1.36 | 0.23 | [-1.81, -0.91] | -5.98 | < .001 - period [2] | -0.98 | 0.30 | [-1.57, -0.38] | -3.22 | 0.001 - period [3] | -1.11 | 0.32 | [-1.75, -0.48] | -3.43 | < .001 - period [4] | -1.56 | 0.42 | [-2.39, -0.73] | -3.67 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - - The model has a log- or logit-link. Consider using `exponentiate = - TRUE` to interpret coefficients as ratios. - ---- - - Code - mp - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | 0.26 | 0.06 | [0.16, 0.40] | -5.98 | < .001 - period [2] | 0.38 | 0.11 | [0.21, 0.68] | -3.22 | 0.001 - period [3] | 0.33 | 0.11 | [0.17, 0.62] | -3.43 | < .001 - period [4] | 0.21 | 0.09 | [0.09, 0.48] | -3.67 | < .001 - - # Random Effects - - Parameter | Coefficient - ---------------------------------- - SD (Intercept: herd) | 0.64 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - mp - Output - # Fixed Effects - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -1.40 | 0.23 | [-1.85, -0.94] | -6.02 | < .001 - period [2] | -0.99 | 0.31 | [-1.59, -0.39] | -3.24 | 0.001 - period [3] | -1.13 | 0.33 | [-1.77, -0.49] | -3.46 | < .001 - period [4] | -1.58 | 0.43 | [-2.42, -0.74] | -3.70 | < .001 - - # Random Effects - - Parameter | Coefficient | SE | 95% CI - -------------------------------------------------------- - SD (Intercept: herd) | 0.64 | 0.18 | [0.37, 1.11] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - # robust SE/VCOV, using FPC Code @@ -74,10 +5,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t(174) | p - --------------------------------------------------------------------- - (Intercept) | 251.41 | 6.48 | [238.61, 264.20] | 38.77 | < .001 - Days | 10.47 | 1.49 | [ 7.52, 13.42] | 7.01 | < .001 + Parameter | Coefficient | SE | 95% CI | t(17.00) | p + ----------------------------------------------------------------------- + (Intercept) | 251.41 | 6.48 | [237.01, 265.80] | 38.77 | < .001 + Days | 10.47 | 1.49 | [ 7.21, 13.73] | 7.01 | < .001 # Random Effects @@ -90,7 +21,7 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. Uncertainty intervals for - random effect variances computed using a Wald z-distribution - approximation. + using a Wald t-distribution with Satterthwaite approximation. + Uncertainty intervals for random effect variances computed using a Wald + z-distribution approximation. diff --git a/tests/testthat/_snaps/model_parameters.mixed.md b/tests/testthat/_snaps/model_parameters.mixed.md index 685934ad5..f26a1db31 100644 --- a/tests/testthat/_snaps/model_parameters.mixed.md +++ b/tests/testthat/_snaps/model_parameters.mixed.md @@ -3,26 +3,26 @@ Code model_parameters(model, effects = "fixed", wb_component = TRUE) Output - Parameter | Coefficient | SE | 95% CI | t(558) | p - ------------------------------------------------------------------- - (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | < .001 - time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 0.089 + Parameter | Coefficient | SE | 95% CI | t | df | p + --------------------------------------------------------------------------- + (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | 559.94 | < .001 + time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 374.00 | 0.089 # Within-Effects - Parameter | Coefficient | SE | 95% CI | t(558) | p - ------------------------------------------------------------------- - phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | < .001 + Parameter | Coefficient | SE | 95% CI | t(374.00) | p + ---------------------------------------------------------------------- + phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | < .001 # Between-Effects - Parameter | Coefficient | SE | 95% CI | t(558) | p - -------------------------------------------------------------------- - phq4 between | -6.28 | 0.50 | [-7.27, -5.30] | -12.53 | < .001 + Parameter | Coefficient | SE | 95% CI | t(186.00) | p + ----------------------------------------------------------------------- + phq4 between | -6.28 | 0.50 | [-7.27, -5.29] | -12.53 | < .001 Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. + using a Wald t-distribution with Satterthwaite approximation. --- @@ -31,16 +31,16 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t(558) | p - -------------------------------------------------------------------- - (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | < .001 - time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 0.089 - phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | < .001 - phq4 between | -6.28 | 0.50 | [-7.27, -5.30] | -12.53 | < .001 + Parameter | Coefficient | SE | 95% CI | t | df | p + ----------------------------------------------------------------------------- + (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | 559.94 | < .001 + time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 374.00 | 0.089 + phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | 374.00 | < .001 + phq4 between | -6.28 | 0.50 | [-7.27, -5.29] | -12.53 | 186.00 | < .001 Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. + using a Wald t-distribution with Satterthwaite approximation. # print-model_parameters-2 @@ -49,10 +49,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t(28) | p - ----------------------------------------------------------------- - (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 - cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 + Parameter | Coefficient | SE | 95% CI | t | df | p + ------------------------------------------------------------------------ + (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 + cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 # Random Effects @@ -63,9 +63,9 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. Uncertainty intervals for - random effect variances computed using a Wald z-distribution - approximation. + using a Wald t-distribution with Satterthwaite approximation. + Uncertainty intervals for random effect variances computed using a Wald + z-distribution approximation. --- @@ -74,10 +74,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t(28) | p - ----------------------------------------------------------------- - (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 - cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 + Parameter | Coefficient | SE | 95% CI | t | df | p + ------------------------------------------------------------------------ + (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 + cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 # Random Effects @@ -88,9 +88,9 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. Uncertainty intervals for - random effect variances computed using a Wald z-distribution - approximation. + using a Wald t-distribution with Satterthwaite approximation. + Uncertainty intervals for random effect variances computed using a Wald + z-distribution approximation. --- @@ -99,10 +99,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t(28) | p - ----------------------------------------------------------------- - (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 - cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 + Parameter | Coefficient | SE | 95% CI | t | df | p + ------------------------------------------------------------------------ + (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 + cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 Model: wt ~ cyl (32 Observations) Sigma: 0.594 (df = 28) @@ -111,7 +111,7 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. + using a Wald t-distribution with Satterthwaite approximation. --- @@ -120,10 +120,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t(28) | p - ----------------------------------------------------------------- - (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 - cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 + Parameter | Coefficient | SE | 95% CI | t | df | p + ------------------------------------------------------------------------ + (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 + cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 Model: wt ~ cyl (32 Observations) Sigma: 0.594 (df = 28) @@ -132,5 +132,5 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. + using a Wald t-distribution with Satterthwaite approximation. diff --git a/tests/testthat/test-lavaan.R b/tests/testthat/test-lavaan.R index 210469514..b879af2e7 100644 --- a/tests/testthat/test-lavaan.R +++ b/tests/testthat/test-lavaan.R @@ -64,7 +64,7 @@ test_that("standardized no CI", { test_that("simulate_model and equivalence_test work for lavaan", { skip_on_cran() - skip_if_not_installed("bayestestR") + skip_if_not_installed("bayestestR", minimum_version = "0.19.0.2") skip_if_not_installed("lavaan") skip_if_not_installed("insight", minimum_version = "1.5.2") @@ -94,7 +94,7 @@ test_that("simulate_model and equivalence_test work for lavaan", { "", " ROPE: [-0.20 0.20]", "", - "Parameter | H0 | inside ROPE | 95% HDI", + "Parameter | H0 | inside ROPE | 95% ETI", "--------------------------------------------------", "y~x | Undecided | 23.05 % | [0.09, 0.42]", "y~~y | Rejected | 0.00 % | [0.43, 0.76]", diff --git a/tests/testthat/test-random_effects_ci.R b/tests/testthat/test-random_effects_ci.R index 86919ee3b..c6abf167d 100644 --- a/tests/testthat/test-random_effects_ci.R +++ b/tests/testthat/test-random_effects_ci.R @@ -60,9 +60,8 @@ expect_message( test_that("random effects CIs, two slopes, categorical", { # fmt: skip expect_equal( - mp1$CI_low, + mp1$CI_low[mp1$Effects=="random"], c( - 28.75405, 4.97865, -1.95011, -2.70111, -3.62199, -2.69102, 4.28813, 0.21457, 0.5742, 0.28738, 0.02089, 1e-05, 0.55402, 0, 0, 0.2781, 0.38107, 0.00945, -0.65343, -0.7222, -1, -0.99521, -0.97784, -1, -1, -1, -1, -1, -1, -0.99594, -1, -0.90229, -0.99736, From be07cd04e74a2e6eeee5b086f5d72bfab2a86fe8 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Wed, 14 Oct 2026 09:28:26 +0300 Subject: [PATCH 09/33] fix vcov being overwritten by satterthwaite --- R/methods_lme4.R | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index fab632b2a..c1a3b8f10 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -118,15 +118,30 @@ model_parameters.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- model_parameters.merMod - cl$ci_method <- .attempt_satterthwaite_method(ci_method, bootstrap = bootstrap) + cl$ci_method <- .attempt_satterthwaite_method( + ci_method, + bootstrap = bootstrap, + vcov = vcov + ) eval.parent(cl) } #' @export -ci.lmerMod <- function(x, ci = 0.95, dof = NULL, method = NULL, iterations = 500, ...) { +ci.lmerMod <- function( + x, + ci = 0.95, + dof = NULL, + method = NULL, + iterations = 500, + component = "all", + vcov = NULL, + vcov_args = NULL, + verbose = TRUE, + ... +) { cl <- match.call() cl[[1]] <- ci.merMod - cl$method <- .attempt_satterthwaite_method(method) + cl$method <- .attempt_satterthwaite_method(method, vcov = vcov) eval.parent(cl) } @@ -141,15 +156,24 @@ standard_error.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- standard_error.merMod - cl$method <- .attempt_satterthwaite_method(method) + cl$method <- .attempt_satterthwaite_method(method, vcov = vcov) eval.parent(cl) } #' @export -p_value.lmerMod <- function(model, method = NULL, ...) { +p_value.lmerMod <- function( + model, + dof = NULL, + method = NULL, + component = "all", + vcov = NULL, + vcov_args = NULL, + verbose = TRUE, + ... +) { cl <- match.call() cl[[1]] <- p_value.merMod - cl$method <- .attempt_satterthwaite_method(method) + cl$method <- .attempt_satterthwaite_method(method, vcov = vcov) eval.parent(cl) } @@ -235,8 +259,13 @@ se_mixed_default <- function(model) { .data_frame(Parameter = params, SE = .get_se_from_summary(model)) } -.attempt_satterthwaite_method <- function(method, fallback = "wald", bootstrap = FALSE) { - if (!is.null(method) || bootstrap) { +.attempt_satterthwaite_method <- function( + method, + fallback = "wald", + bootstrap = FALSE, + vcov = NULL +) { + if (!is.null(method) || bootstrap || !is.null(vcov)) { return(method) } From 06ca11d5b427349d4ef59fec48684b19d4de5b50 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Wed, 14 Oct 2026 09:32:20 +0300 Subject: [PATCH 10/33] correctly name lmerModLmerTest --- NEWS.md | 6 +++--- R/methods_lme4.R | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index e75430fff..98c026e18 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,9 +3,9 @@ ## Breaking Changes * `model_parameters()`, `ci()`, `standard_error()`, and `p_value()` now default - to the Satterthwaite approximation for `lmerMod` and `lmerModTest` models when - `{lmerTest}` is available, making the outputs more consistent with `summary()` - (#989). + to the Satterthwaite approximation for `lmerMod` and `lmerModLmerTest` models + when `{lmerTest}` is available, making the outputs more consistent with + `summary()` (#989). ## Changes diff --git a/R/methods_lme4.R b/R/methods_lme4.R index c1a3b8f10..2a4b12145 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -91,7 +91,7 @@ standard_error.merMod <- function( p_value.merMod <- p_value.cpglmm -# lmerMod and lmerModTest ----------------------------------------------------------------- +# lmerMod (and lmerModLmerTest) ----------------------------------------------------------------- #' @export model_parameters.lmerMod <- function( From 8a08d4c68568519df14db1e8845f4446bec060cb Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 10:42:15 +0300 Subject: [PATCH 11/33] fix a zillion tests --- R/methods_lme4.R | 22 ++- tests/testthat/test-ci.R | 25 ++-- tests/testthat/test-glmer.R | 7 +- tests/testthat/test-model_parameters.mixed.R | 7 +- .../test-model_parameters_df_method.R | 33 ++--- tests/testthat/test-p_value.R | 5 +- tests/testthat/test-parameters_table.R | 3 +- tests/testthat/test-random_effects_ci.R | 135 +++--------------- .../testthat/test-random_effects_covstruct.R | 4 +- tests/testthat/test-robust.R | 7 +- 10 files changed, 79 insertions(+), 169 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 2a4b12145..cdfe869c1 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -118,11 +118,7 @@ model_parameters.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- model_parameters.merMod - cl$ci_method <- .attempt_satterthwaite_method( - ci_method, - bootstrap = bootstrap, - vcov = vcov - ) + cl$ci_method <- .attempt_satterthwaite_method(ci_method, effects, bootstrap = bootstrap) eval.parent(cl) } @@ -133,7 +129,7 @@ ci.lmerMod <- function( dof = NULL, method = NULL, iterations = 500, - component = "all", + effects = "all", vcov = NULL, vcov_args = NULL, verbose = TRUE, @@ -141,7 +137,7 @@ ci.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- ci.merMod - cl$method <- .attempt_satterthwaite_method(method, vcov = vcov) + cl$method <- .attempt_satterthwaite_method(method, effects) eval.parent(cl) } @@ -156,7 +152,7 @@ standard_error.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- standard_error.merMod - cl$method <- .attempt_satterthwaite_method(method, vcov = vcov) + cl$method <- .attempt_satterthwaite_method(method, effects) eval.parent(cl) } @@ -165,7 +161,7 @@ p_value.lmerMod <- function( model, dof = NULL, method = NULL, - component = "all", + effects = "all", vcov = NULL, vcov_args = NULL, verbose = TRUE, @@ -173,7 +169,7 @@ p_value.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- p_value.merMod - cl$method <- .attempt_satterthwaite_method(method, vcov = vcov) + cl$method <- .attempt_satterthwaite_method(method, effects) eval.parent(cl) } @@ -261,11 +257,11 @@ se_mixed_default <- function(model) { .attempt_satterthwaite_method <- function( method, + effects, fallback = "wald", - bootstrap = FALSE, - vcov = NULL + bootstrap = FALSE ) { - if (!is.null(method) || bootstrap || !is.null(vcov)) { + if (effects == "random" || !is.null(method) || bootstrap) { return(method) } diff --git a/tests/testthat/test-ci.R b/tests/testthat/test-ci.R index 8203f8be5..2d7fa34db 100644 --- a/tests/testthat/test-ci.R +++ b/tests/testthat/test-ci.R @@ -3,26 +3,34 @@ test_that("ci", { model <- lm(mpg ~ wt, data = mtcars) expect_equal(suppressMessages(ci(model))[1, 3], 33.4505, tolerance = 0.01) - expect_equal(suppressMessages(ci(model, ci = c(0.7, 0.8)))[1, 3], 35.30486, tolerance = 0.01) + expect_equal( + suppressMessages(ci(model, ci = c(0.7, 0.8)))[1, 3], + 35.30486, + tolerance = 0.01 + ) model <- glm(vs ~ wt, family = "binomial", data = mtcars) expect_equal(suppressMessages(ci(model))[1, 3], 1.934013, tolerance = 0.01) model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars) - expect_equal(suppressMessages(ci(model, method = "normal"))[1, 3], -0.335063, tolerance = 0.01) + expect_equal( + suppressMessages(ci(model, method = "normal"))[1, 3], + -0.335063, + tolerance = 0.01 + ) model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars) - expect_equal(ci(model)[1, 3], -0.3795646, tolerance = 0.01) + expect_equal(ci(model, method = "wald")[1, 3], -0.3795646, tolerance = 0.01) set.seed(1) val <- ci(model, method = "boot")[1, 3] expect_equal(val, -0.555424, tolerance = 0.01) model <- lme4::glmer(vs ~ cyl + (1 | gear), data = mtcars, family = "binomial") - expect_equal(ci(model)[1, 3], -0.7876679, tolerance = 0.01) + expect_equal(ci(model, method = "wald")[1, 3], -0.7876679, tolerance = 0.01) model <- lme4::glmer(vs ~ drat + cyl + (1 | gear), data = mtcars, family = "binomial") - expect_equal(ci(model)[1, 3], -48.14195, tolerance = 0.01) + expect_equal(ci(model, method = "wald")[1, 3], -48.14195, tolerance = 0.01) }) @@ -42,7 +50,8 @@ test_that("vs. sandwich & lmtest", { expect_equal(unknown[["CI_low"]], known[, "2.5 %"], ignore_attr = TRUE) expect_equal(unknown[["CI_high"]], known[, "97.5 %"], ignore_attr = TRUE) - suppressMessages( - expect_message(ci(model, vcov = sandwich::vcovHC), regexp = "vcov.*are not available with.*profile") - ) + suppressMessages(expect_message( + ci(model, vcov = sandwich::vcovHC), + regexp = "vcov.*are not available with.*profile" + )) }) diff --git a/tests/testthat/test-glmer.R b/tests/testthat/test-glmer.R index ee55e6343..8bafd340d 100644 --- a/tests/testthat/test-glmer.R +++ b/tests/testthat/test-glmer.R @@ -94,6 +94,11 @@ test_that("robust SE/VCOV, using FPC", { ignore_attr = TRUE, tolerance = 1e-4 ) - out <- model_parameters(model, vcov = "fpc", vcov_args = list(population_size = 500)) + out <- model_parameters( + model, + ci_method = "s", + vcov = "fpc", + vcov_args = list(population_size = 500) + ) expect_snapshot(print(out, table_width = Inf)) }) diff --git a/tests/testthat/test-model_parameters.mixed.R b/tests/testthat/test-model_parameters.mixed.R index 3e7aa6d5f..e12bc404c 100644 --- a/tests/testthat/test-model_parameters.mixed.R +++ b/tests/testthat/test-model_parameters.mixed.R @@ -18,7 +18,7 @@ test_that("model_parameters.mixed", { expect_identical(c(nrow(params), ncol(params)), c(2L, 10L)) expect_equal(params$CI_high, c(1.6373105660317, 0.554067677205595), tolerance = 1e-3) - params <- model_parameters(m1, effects = "fixed") + params <- model_parameters(m1, ci_method = "wald", effects = "fixed") expect_identical(c(nrow(params), ncol(params)), c(2L, 10L)) expect_equal(params$CI_high, c(1.68181, 0.56083), tolerance = 1e-3) @@ -49,11 +49,6 @@ test_that("model_parameters.mixed", { expect_equal(params$CI_high_0.8, c(1.31154, 0.50455), tolerance = 1e-3) expect_equal(params$CI_high_0.9, c(1.50707, 0.53427), tolerance = 1e-3) - params <- model_parameters(m1, ci = c(0.8, 0.9), effects = "fixed") - expect_identical(c(nrow(params), ncol(params)), c(2L, 11L)) - expect_equal(params$CI_high_0.8, c(1.31154, 0.50455), tolerance = 1e-3) - expect_equal(params$CI_high_0.9, c(1.50707, 0.53427), tolerance = 1e-3) - params <- model_parameters(m2, effects = "fixed") expect_identical(c(nrow(params), ncol(params)), c(2L, 10L)) diff --git a/tests/testthat/test-model_parameters_df_method.R b/tests/testthat/test-model_parameters_df_method.R index 459fff46c..02a6ac317 100644 --- a/tests/testthat/test-model_parameters_df_method.R +++ b/tests/testthat/test-model_parameters_df_method.R @@ -30,30 +30,27 @@ mp2 <- model_parameters(model, digits = 5, ci_method = "s", effects = "fixed") mp3 <- model_parameters(model, digits = 5, ci_method = "kr", effects = "fixed") mp4 <- model_parameters(model, digits = 5, ci_method = "wald", effects = "fixed") mp5 <- model_parameters(model3, digits = 5, ci_method = "kr", effects = "fixed") -mp6 <- model_parameters( - model3, - digits = 5, - ci_method = "satterthwaite", - effects = "fixed" -) +mp6 <- model_parameters(model3, digits = 5, ci_method = "residual", effects = "fixed") -test_that("model_parameters, ci_method default (residual)", { +test_that("model_parameters, ci_method default (satterthwaite)", { expect_equal( mp0$SE, c(2.77457, 3.69574, 3.521, 0.01574, 1.58514, 0.86316, 0.02973, 0.01668), tolerance = 1e-3 ) - expect_equal(mp0$df, c(22, 22, 22, 22, 22, 22, 22, 22), tolerance = 1e-3) + expect_equal(mp0$df, c(24, 24, 24, 24, 24, 24, 24, 24), tolerance = 1e-3) expect_equal( mp0$p, - c(0, 0.00258, 0.14297, 0.17095, 0.84778, 0.00578, 0.00151, 0.32653), + c(0, 0.00236, 0.14179, 0.16979, 0.84763, 0.00542, 0.00136, 0.32563), tolerance = 1e-3 ) expect_equal( mp0$CI_low, - c(24.54722, 4.89698, -1.95317, -0.05493, -2.97949, -4.42848, -0.16933, -0.05133), + c(24.57489, 4.93385, -1.91805, -0.05477, -2.96368, -4.41987, -0.16904, -0.05117), tolerance = 1e-3 ) + expect_equal(mp0$SE, mp6$SE, tolerance = 1e-3) + expect_equal(mp0$df_error, mp2$df_error, tolerance = 1e-3) }) test_that("model_parameters, ci_method normal", { @@ -75,25 +72,23 @@ test_that("model_parameters, ci_method normal", { ) }) -test_that("model_parameters, ci_method satterthwaite", { +test_that("model_parameters, ci_method residual", { expect_equal( - mp2$SE, + mp6$SE, c(2.77457, 3.69574, 3.521, 0.01574, 1.58514, 0.86316, 0.02973, 0.01668), tolerance = 1e-3 ) - expect_equal(mp2$df, c(24, 24, 24, 24, 24, 24, 24, 24), tolerance = 1e-3) + expect_equal(mp6$df, c(22, 22, 22, 22, 22, 22, 22, 22), tolerance = 1e-3) expect_equal( - mp2$p, - c(0, 0.00236, 0.14179, 0.16979, 0.84763, 0.00542, 0.00136, 0.32563), + mp6$p, + c(0, 0.00258, 0.14297, 0.17095, 0.84778, 0.00578, 0.00151, 0.32653), tolerance = 1e-3 ) expect_equal( - mp2$CI_low, - c(24.57489, 4.93385, -1.91805, -0.05477, -2.96368, -4.41987, -0.16904, -0.05117), + mp6$CI_low, + c(24.54722, 4.89698, -1.95317, -0.05493, -2.97949, -4.42848, -0.16933, -0.05133), tolerance = 1e-3 ) - expect_equal(mp2$SE, mp6$SE, tolerance = 1e-3) - expect_equal(mp2$df_error, mp6$df_error, tolerance = 1e-3) }) test_that("model_parameters, ci_method kenward", { diff --git a/tests/testthat/test-p_value.R b/tests/testthat/test-p_value.R index a378d0101..53d9275e6 100644 --- a/tests/testthat/test-p_value.R +++ b/tests/testthat/test-p_value.R @@ -10,7 +10,6 @@ test_that("p_value", { }) - skip_on_cran() test_that("p_value", { @@ -122,10 +121,10 @@ test_that("p_value", { skip_if(is.null(model)) expect_equal(p_value(model)$p[2], 0, tolerance = 0.01) - # Mixed models + skip_if_not_installed("lmerTest") model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars) - expect_equal(p_value(model)$p[1], 0.206219, tolerance = 0.01) + expect_equal(p_value(model)$p[1], 0.2242536, tolerance = 0.01) expect_equal(p_value(model, method = "normal")$p[1], 0.1956467, tolerance = 0.01) expect_equal(p_value(model, method = "kr")$p[1], 0.319398, tolerance = 0.01) diff --git a/tests/testthat/test-parameters_table.R b/tests/testthat/test-parameters_table.R index d3ba8ec56..2ee8a5d7c 100644 --- a/tests/testthat/test-parameters_table.R +++ b/tests/testthat/test-parameters_table.R @@ -14,7 +14,8 @@ test_that("parameters_table 2", { skip_if_not_installed("lme4") x <- model_parameters( lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris), - effects = "fixed" + effects = "fixed", + ci_method = "wald" ) tab <- insight::format_table(x) expect_true(all( diff --git a/tests/testthat/test-random_effects_ci.R b/tests/testthat/test-random_effects_ci.R index c6abf167d..4f035b493 100644 --- a/tests/testthat/test-random_effects_ci.R +++ b/tests/testthat/test-random_effects_ci.R @@ -30,26 +30,26 @@ m5 <- suppressMessages(lme4::lmer( expect_message( { - mp1 <- model_parameters(m1, ci_random = TRUE) + mp1 <- model_parameters(m1, ci_random = TRUE, effects = "random") }, regex = "meaningful" ) -mp2 <- model_parameters(m2, ci_random = TRUE) +mp2 <- model_parameters(m2, ci_random = TRUE, effects = "random") expect_message( { - mp3 <- model_parameters(m3, ci_random = TRUE) + mp3 <- model_parameters(m3, ci_random = TRUE, effects = "random") }, regex = "meaningful" ) expect_message( { - mp4 <- model_parameters(m4, ci_random = TRUE) + mp4 <- model_parameters(m4, ci_random = TRUE, effects = "random") }, regex = "meaningful" ) expect_message( { - mp5 <- model_parameters(m5, ci_random = TRUE) + mp5 <- model_parameters(m5, ci_random = TRUE, effects = "random") }, regex = "meaningful" ) @@ -60,7 +60,7 @@ expect_message( test_that("random effects CIs, two slopes, categorical", { # fmt: skip expect_equal( - mp1$CI_low[mp1$Effects=="random"], + mp1$CI_low, c( 4.28813, 0.21457, 0.5742, 0.28738, 0.02089, 1e-05, 0.55402, 0, 0, 0.2781, 0.38107, 0.00945, -0.65343, -0.7222, -1, -0.99521, @@ -75,12 +75,6 @@ test_that("random effects CIs, two slopes, categorical", { expect_identical( mp1$Parameter, c( - "(Intercept)", - "temperature.L", - "temperature.Q", - "temperature.C", - "temperature^4", - "temperature^5", "SD (Intercept)", "SD (Intercept)", "SD (temperature.L)", @@ -130,12 +124,6 @@ test_that("random effects CIs, two slopes, categorical", { expect_identical( mp1$Group, c( - "", - "", - "", - "", - "", - "", "replicate", "recipe", "replicate", @@ -189,24 +177,17 @@ test_that("random effects CIs, two slopes, categorical", { test_that("random effects CIs, simple slope", { expect_equal( mp2$CI_low, - c(237.93546, 7.41637, 15.5817, 3.91828, -0.50907, 22.80044), + c(15.5817, 3.91828, -0.50907, 22.80044), tolerance = 1e-3, ignore_attr = TRUE ) expect_identical( mp2$Parameter, - c( - "(Intercept)", - "Days", - "SD (Intercept)", - "SD (Days)", - "Cor (Intercept~Days)", - "SD (Observations)" - ) + c("SD (Intercept)", "SD (Days)", "Cor (Intercept~Days)", "SD (Observations)") ) - expect_identical(mp2$Group, c("", "", "Subject", "Subject", "Subject", "Residual")) + expect_identical(mp2$Group, c("Subject", "Subject", "Subject", "Residual")) }) @@ -214,40 +195,15 @@ test_that("random effects CIs, simple slope", { test_that("random effects CIs, categorical slope-1", { expect_equal( - mp3$CI_low[14:28], + mp3$CI_low[8:22], c(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7.09933), tolerance = 1e-2, ignore_attr = TRUE ) - expect_equal( - mp3$CI_low[1:12], - c( - 30.91139, - 4.33247, - -2.6798, - -3.20703, - -4.07681, - -3.27237, - 0.06301, - 0, - 0, - 0.1192, - 0.32213, - 0 - ), - tolerance = 1e-2, - ignore_attr = TRUE - ) expect_identical( mp3$Parameter, c( - "(Intercept)", - "temperature.L", - "temperature.Q", - "temperature.C", - "temperature^4", - "temperature^5", "SD (Intercept)", "SD (temperature.L)", "SD (temperature.Q)", @@ -276,12 +232,6 @@ test_that("random effects CIs, categorical slope-1", { expect_identical( mp3$Group, c( - "", - "", - "", - "", - "", - "", "recipe", "recipe", "recipe", @@ -316,7 +266,6 @@ test_that("random effects CIs, categorical slope-2", { expect_equal( mp4$CI_low, c( - 28.88447, 4.96795, -1.93231, -1.98596, -2.68856, -2.55248, 4.28006, 0.51326, 0.23954, 0.01238, 0, 0.5001, -0.68888, -0.74701, -1, -0.99746, -0.98211, -1, -0.99788, -1, -0.92289, -0.99878, -1, -0.98562, -1, -1, -1, 4.21137 @@ -328,12 +277,6 @@ test_that("random effects CIs, categorical slope-2", { expect_identical( mp4$Parameter, c( - "(Intercept)", - "temperature.L", - "temperature.Q", - "temperature.C", - "temperature^4", - "temperature^5", "SD (Intercept)", "SD (temperature.L)", "SD (temperature.Q)", @@ -362,12 +305,6 @@ test_that("random effects CIs, categorical slope-2", { expect_identical( mp4$Group, c( - "", - "", - "", - "", - "", - "", "replicate", "replicate", "replicate", @@ -400,7 +337,7 @@ test_that("random effects CIs, categorical slope-2", { test_that("random effects CIs, double slope", { expect_equal( mp5$CI_low, - c(237.99863, 7.4022, 12.63814, 3.91669, 0, -0.58599, -1, -1, 22.65226), + c(12.63814, 3.91669, 0, -0.58599, -1, -1, 22.65226), tolerance = 1e-3, ignore_attr = TRUE ) @@ -408,8 +345,6 @@ test_that("random effects CIs, double slope", { expect_identical( mp5$Parameter, c( - "(Intercept)", - "Days", "SD (Intercept)", "SD (Days)", "SD (Months)", @@ -422,17 +357,7 @@ test_that("random effects CIs, double slope", { expect_identical( mp5$Group, - c( - "", - "", - "Subject", - "Subject", - "Subject", - "Subject", - "Subject", - "Subject", - "Residual" - ) + c("Subject", "Subject", "Subject", "Subject", "Subject", "Subject", "Residual") ) }) @@ -446,37 +371,22 @@ test_that("random effects CIs, simple slope", { m2 <- lme4::lmer(Reaction ~ Days + (0 + Days | Subject), data = sleepstudy) m5 <- lme4::lmer(Reaction ~ Days + (0 + Days + Months | Subject), data = sleepstudy) - mp2 <- model_parameters(m2) - mp5 <- model_parameters(m5) - expect_equal( - mp2$CI_low, - c(243.47155, 6.77765, 5.09041, 26.01525), - tolerance = 1e-3, - ignore_attr = TRUE - ) + mp2 <- model_parameters(m2, effects = "random") + mp5 <- model_parameters(m5, effects = "random") + expect_equal(mp2$CI_low, c(5.09041, 26.01525), tolerance = 1e-3, ignore_attr = TRUE) - expect_identical( - mp2$Parameter, - c("(Intercept)", "Days", "SD (Days)", "SD (Observations)") - ) + expect_identical(mp2$Parameter, c("SD (Days)", "SD (Observations)")) expect_equal( mp5$CI_low, - c(241.61021, 7.43503, 4.11446, 2.69857, -0.40595, 24.632), + c(4.11446, 2.69857, -0.40595, 24.632), tolerance = 1e-3, ignore_attr = TRUE ) expect_identical( mp5$Parameter, - c( - "(Intercept)", - "Days", - "SD (Days)", - "SD (Months)", - "Cor (Days~Months)", - "SD (Observations)" - ) + c("SD (Days)", "SD (Months)", "Cor (Days~Months)", "SD (Observations)") ) }) @@ -490,13 +400,13 @@ test_that("random effects CIs, poly slope", { data = cake ) }) - mp <- model_parameters(m, ci_random = TRUE) + mp <- model_parameters(m, ci_random = TRUE, effects = "random") # fmt: skip expect_equal( mp$CI_low, c( - 28.78854, 33.56292, -12.84337, 4.27419, 0.16217, 2.30959, 0.87852, + 4.27419, 0.16217, 2.30959, 0.87852, -0.81742, -0.80941, -1, 4.32856 ), tolerance = 1e-3, @@ -506,9 +416,6 @@ test_that("random effects CIs, poly slope", { expect_identical( mp$Parameter, c( - "(Intercept)", - "poly(temp, 2)1", - "poly(temp, 2)2", "SD (Intercept)", "SD (Intercept)", "SD (poly(temp, 2)1)", @@ -532,7 +439,7 @@ test_that("random effects CIs, poly categorical slope", { angle ~ poly(temp, 2) + (poly(temp, 2) | replicate) + (temperature | recipe), data = cake ) - mp <- model_parameters(m, effects = "random", ci = TRUE) + mp <- model_parameters(m, effects = "random", ci_random = TRUE) # fmt: skip expect_equal( diff --git a/tests/testthat/test-random_effects_covstruct.R b/tests/testthat/test-random_effects_covstruct.R index 058f2a4d0..af0dc3d3b 100644 --- a/tests/testthat/test-random_effects_covstruct.R +++ b/tests/testthat/test-random_effects_covstruct.R @@ -142,7 +142,7 @@ test_that("random effects, lme4, cov-struct AR1", { y ~ 1 + (as.numeric(time) | id) + ar1(time + 0 | id), data = dat )) - out <- model_parameters(m_ar1, effects = "random", ci_random = 0.95, verbose = FALSE) + out <- model_parameters(m_ar1, effects = "random", verbose = FALSE) expect_named( out, c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "Effects", "Group") @@ -164,8 +164,6 @@ test_that("random effects, lme4, cov-struct AR1", { c(0.3929, 0.0747, 0.9012, 0.1467, 0.242, 0.1319), tolerance = 1e-3 ) - out <- model_parameters(m_ar1, effects = "random", ci_random = FALSE, verbose = FALSE) - expect_named(out, c("Parameter", "Coefficient", "SE", "Effects", "Group", "CI")) }) test_that("random effects, glmmTMB, cov-struct OU", { diff --git a/tests/testthat/test-robust.R b/tests/testthat/test-robust.R index 1a6649f5a..af1b1cc8c 100644 --- a/tests/testthat/test-robust.R +++ b/tests/testthat/test-robust.R @@ -396,7 +396,12 @@ test_that("robust-ci lmer", { Sepal.Length ~ Species * Sepal.Width + Petal.Length + (1 | grp), data = iris ) - ci1 <- ci(m, vcov = "vcovCR", vcov_args = list(type = "CR1", cluster = iris$grp)) + ci1 <- ci( + m, + method = "wald", + vcov = "vcovCR", + vcov_args = list(type = "CR1", cluster = iris$grp) + ) # robust CI manually params <- insight::get_parameters(m) se <- sqrt(diag(clubSandwich::vcovCR(m, type = "CR1", cluster = iris$grp))) From 88cb5faf9e7c5c914f4b2963ca5450079b47b81e Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 10:42:25 +0300 Subject: [PATCH 12/33] just the snaps --- .../equivalence_test/equivalence-test-1.svg | 70 ----- .../equivalence_test/equivalence-test-2.svg | 73 ----- .../equivalence_test/equivalence-test-3.svg | 93 ------ .../equivalence_test/equivalence-test-4.svg | 93 ------ .../equivalence_test/equivalence-test-5.svg | 93 ------ tests/testthat/_snaps/glmer.md | 69 +++++ tests/testthat/_snaps/glmmTMB.new.md | 279 ++++++++++++++++++ tests/testthat/_snaps/include_reference.md | 245 --------------- tests/testthat/_snaps/ivreg.md | 20 -- tests/testthat/_snaps/lcmm.md | 257 ---------------- tests/testthat/_snaps/mipo.md | 42 --- .../testthat/_snaps/model_parameters.anova.md | 30 -- .../_snaps/model_parameters.fixest.md | 25 -- .../_snaps/model_parameters.fixest_multi.md | 160 ---------- .../_snaps/model_parameters.glmgee.md | 20 -- .../_snaps/model_parameters.mclogit.md | 80 ----- tests/testthat/_snaps/plm.md | 34 --- tests/testthat/_snaps/print_AER_labels.md | 19 -- tests/testthat/_snaps/printing-stan.new.md | 256 ++++++++++++++++ tests/testthat/_snaps/sampleSelection.md | 71 ----- tests/testthat/_snaps/serp.md | 24 -- tests/testthat/_snaps/svylme.md | 26 -- .../_snaps/tinyplot/tinyplot-forest-1.svg | 63 ---- .../_snaps/tinyplot/tinyplot-forest-2.svg | 63 ---- .../tinyplot-forest-exponentiated.svg | 57 ---- tests/testthat/_snaps/weightit.md | 51 ---- tests/testthat/_snaps/wrs2.md | 11 - 27 files changed, 604 insertions(+), 1720 deletions(-) delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg create mode 100644 tests/testthat/_snaps/glmmTMB.new.md delete mode 100644 tests/testthat/_snaps/include_reference.md delete mode 100644 tests/testthat/_snaps/ivreg.md delete mode 100644 tests/testthat/_snaps/lcmm.md delete mode 100644 tests/testthat/_snaps/mipo.md delete mode 100644 tests/testthat/_snaps/model_parameters.fixest_multi.md delete mode 100644 tests/testthat/_snaps/model_parameters.glmgee.md delete mode 100644 tests/testthat/_snaps/model_parameters.mclogit.md delete mode 100644 tests/testthat/_snaps/plm.md delete mode 100644 tests/testthat/_snaps/print_AER_labels.md create mode 100644 tests/testthat/_snaps/printing-stan.new.md delete mode 100644 tests/testthat/_snaps/sampleSelection.md delete mode 100644 tests/testthat/_snaps/serp.md delete mode 100644 tests/testthat/_snaps/svylme.md delete mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg delete mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg delete mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg delete mode 100644 tests/testthat/_snaps/weightit.md delete mode 100644 tests/testthat/_snaps/wrs2.md diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg deleted file mode 100644 index 533976c27..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Speciesvirginica -Speciesversicolor - - - - - - -0.0 -0.5 -1.0 -1.5 - -Equivalence - - - -Rejected -Equivalence-Test 1 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg deleted file mode 100644 index a987aae10..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Speciesvirginica -Speciesversicolor - - - - - - - --100 --75 --50 --25 -0 - -Equivalence - - - -Rejected -Equivalence-Test 2 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg deleted file mode 100644 index f6d783bb3..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cyl8 -cyl6 -gear5 -gear4 -hp - - - - - - - - - --5 -0 -5 -10 - -Equivalence - - - - - - - - - -Accepted -Rejected -Undecided -Equivalence-Test 3 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg deleted file mode 100644 index 6f6c286e7..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cyl8 -cyl6 -gear5 -gear4 -hp - - - - - - - - - --5 -0 -5 -10 - -Equivalence - - - - - - - - - -Accepted -Rejected -Undecided -Equivalence-Test 4 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg deleted file mode 100644 index 5a9d29a42..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cyl8 -cyl6 -gear5 -gear4 -hp - - - - - - - - - --5 -0 -5 -10 - -Equivalence - - - - - - - - - -Accepted -Rejected -Undecided -Equivalence-Test 5 - - diff --git a/tests/testthat/_snaps/glmer.md b/tests/testthat/_snaps/glmer.md index 9632f078b..702716130 100644 --- a/tests/testthat/_snaps/glmer.md +++ b/tests/testthat/_snaps/glmer.md @@ -1,3 +1,72 @@ +# print model_parameters + + Code + params + Output + # Fixed Effects + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -1.36 | 0.23 | [-1.81, -0.91] | -5.98 | < .001 + period [2] | -0.98 | 0.30 | [-1.57, -0.38] | -3.22 | 0.001 + period [3] | -1.11 | 0.32 | [-1.75, -0.48] | -3.43 | < .001 + period [4] | -1.56 | 0.42 | [-2.39, -0.73] | -3.67 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + + The model has a log- or logit-link. Consider using `exponentiate = + TRUE` to interpret coefficients as ratios. + +--- + + Code + mp + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | 0.26 | 0.06 | [0.16, 0.40] | -5.98 | < .001 + period [2] | 0.38 | 0.11 | [0.21, 0.68] | -3.22 | 0.001 + period [3] | 0.33 | 0.11 | [0.17, 0.62] | -3.43 | < .001 + period [4] | 0.21 | 0.09 | [0.09, 0.48] | -3.67 | < .001 + + # Random Effects + + Parameter | Coefficient + ---------------------------------- + SD (Intercept: herd) | 0.64 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + mp + Output + # Fixed Effects + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -1.40 | 0.23 | [-1.85, -0.94] | -6.02 | < .001 + period [2] | -0.99 | 0.31 | [-1.59, -0.39] | -3.24 | 0.001 + period [3] | -1.13 | 0.33 | [-1.77, -0.49] | -3.46 | < .001 + period [4] | -1.58 | 0.43 | [-2.42, -0.74] | -3.70 | < .001 + + # Random Effects + + Parameter | Coefficient | SE | 95% CI + -------------------------------------------------------- + SD (Intercept: herd) | 0.64 | 0.18 | [0.37, 1.11] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + # robust SE/VCOV, using FPC Code diff --git a/tests/testthat/_snaps/glmmTMB.new.md b/tests/testthat/_snaps/glmmTMB.new.md new file mode 100644 index 000000000..32cb6690f --- /dev/null +++ b/tests/testthat/_snaps/glmmTMB.new.md @@ -0,0 +1,279 @@ +# print-model_parameters glmmTMB + + Code + out[-5] + Output + [1] "# Fixed Effects" + [2] "" + [3] "Parameter | Log-Mean | SE | 95% CI | z | p" + [4] "----------------------------------------------------------------" + [5] "child | -1.04 | 0.09 | [-1.22, -0.87] | -11.60 | < .001" + [6] "camper [1] | 0.27 | 0.09 | [ 0.09, 0.44] | 2.98 | 0.003 " + +# print-model_parameters glmmTMB digits + + Code + out[-c(5, 14)] + Output + [1] "# Fixed Effects (Count Model)" + [2] "" + [3] "Parameter | Log-Mean | SE | 95% CI | z | p" + [4] "--------------------------------------------------------------------------" + [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" + [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " + [7] "" + [8] "# Fixed Effects (Zero-Inflation Component)" + [9] "" + [10] "Parameter | Log-Odds | SE | 95% CI | z | p" + [11] "--------------------------------------------------------------------------" + [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" + [13] "camper [1] | -4.8291 | | | | " + [14] "" + [15] "# Random Effects Variances" + [16] "" + [17] "Parameter | Coefficient | 95% CI" + [18] "----------------------------------------------------------------" + [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" + [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" + [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" + [22] "" + [23] "# Random Effects (Zero-Inflation Component)" + [24] "" + [25] "Parameter | Coefficient | 95% CI" + [26] "----------------------------------------------------------------" + [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" + [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" + [29] "Cor (Intercept~zg: persons) | 0.9790 | " + +--- + + Code + out[-c(5, 14)] + Output + [1] "# Fixed Effects (Count Model)" + [2] "" + [3] "Parameter | Log-Mean | SE | 95% CI | z | p" + [4] "--------------------------------------------------------------------------" + [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" + [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " + [7] "" + [8] "# Fixed Effects (Zero-Inflation Component)" + [9] "" + [10] "Parameter | Log-Odds | SE | 95% CI | z | p" + [11] "--------------------------------------------------------------------------" + [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" + [13] "camper [1] | -4.8291 | | | | " + [14] "" + [15] "# Random Effects Variances" + [16] "" + [17] "Parameter | Coefficient | 95% CI" + [18] "----------------------------------------------------------------" + [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" + [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" + [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" + [22] "" + [23] "# Random Effects (Zero-Inflation Component)" + [24] "" + [25] "Parameter | Coefficient | 95% CI" + [26] "----------------------------------------------------------------" + [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" + [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" + [29] "Cor (Intercept~zg: persons) | 0.9790 | " + +# print-model_parameters glmmTMB CI alignment + + Code + print(mp) + Output + # Random Effects: conditional + + Parameter | Coefficient | 95% CI + ---------------------------------------------------------------- + SD (Intercept: Session:Participant) | 0.27 | [0.08, 0.87] + SD (Intercept: Participant) | 0.38 | [0.16, 0.92] + + # Random Effects: zero_inflated + + Parameter | Coefficient | 95% CI + ---------------------------------------------------------------- + SD (Intercept: Session:Participant) | 0.69 | [0.40, 1.19] + SD (Intercept: Participant) | 2.39 | [1.25, 4.57] + Message + + Uncertainty intervals for random effect variances computed using a + Wald z-distribution approximation. + +--- + + Code + print(mp) + Output + # Fixed Effects + + Parameter | Log-Mean | SE | 95% CI | z | p + --------------------------------------------------------------------- + (Intercept) | 2.12 | 0.30 | [ 1.53, 2.71] | 7.05 | < .001 + Surface [Lingual] | 0.01 | 0.29 | [-0.56, 0.58] | 0.04 | 0.971 + Surface [Occlusal] | 0.54 | 0.22 | [ 0.10, 0.98] | 2.43 | 0.015 + Side [Anterior] | 0.04 | 0.32 | [-0.58, 0.66] | 0.14 | 0.889 + Side [Left] | -0.04 | 0.20 | [-0.44, 0.37] | -0.17 | 0.862 + Jaw [Maxillar] | -0.10 | 0.21 | [-0.51, 0.30] | -0.51 | 0.612 + + # Zero-Inflation + + Parameter | Log-Odds | SE | 95% CI | z | p + ---------------------------------------------------------------------- + (Intercept) | 4.87 | 0.93 | [ 3.04, 6.69] | 5.23 | < .001 + Surface [Lingual] | 0.93 | 0.34 | [ 0.27, 1.60] | 2.75 | 0.006 + Surface [Occlusal] | -1.01 | 0.29 | [-1.59, -0.44] | -3.45 | < .001 + Side [Anterior] | -0.20 | 0.37 | [-0.93, 0.52] | -0.55 | 0.583 + Side [Left] | -0.38 | 0.27 | [-0.91, 0.14] | -1.44 | 0.151 + Jaw [Maxillar] | 0.59 | 0.24 | [ 0.11, 1.07] | 2.42 | 0.016 + + # Dispersion + + Parameter | Coefficient | 95% CI + ---------------------------------------- + (Intercept) | 2.06 | [1.30, 3.27] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# print-model_parameters + + Code + mp + Output + # Fixed Effects + + Parameter | Log-Mean | SE | 95% CI | z | p + ---------------------------------------------------------------- + (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 + child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 + camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 + + # Zero-Inflation + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 + child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 + camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 + +--- + + Code + mp + Output + # Fixed Effects + + Parameter | IRR | SE | 95% CI | z | p + ---------------------------------------------------------- + (Intercept) | 3.54 | 1.68 | [1.39, 8.98] | 2.66 | 0.008 + child | 0.32 | 0.03 | [0.27, 0.38] | -12.27 | < .001 + camper [1] | 2.08 | 0.19 | [1.73, 2.50] | 7.85 | < .001 + + # Zero-Inflation + + Parameter | Odds Ratio | SE | 95% CI | z | p + ---------------------------------------------------------------- + (Intercept) | 0.68 | 0.44 | [0.19, 2.43] | -0.60 | 0.551 + child | 7.80 | 2.42 | [4.25, 14.32] | 6.63 | < .001 + camper [1] | 0.36 | 0.12 | [0.19, 0.69] | -3.12 | 0.002 + +--- + + Code + mp + Output + # Fixed Effects (Count Model) + + Parameter | Log-Mean | SE | 95% CI | z | p + ---------------------------------------------------------------- + (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 + child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 + camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 + + # Fixed Effects (Zero-Inflation Component) + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 + child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 + camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 + + # Random Effects Variances + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 0.93 | [0.46, 1.89] + + # Random Effects (Zero-Inflation Component) + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 1.17 | [0.54, 2.57] + +# robust SE/VCOV + + Code + print(out, table_width = Inf) + Output + # Fixed Effects (Count Model) + + Parameter | Log-Mean | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | 1.26 | 0.46 | [ 0.36, 2.17] | 2.74 | 0.006 + child | -1.14 | 0.30 | [-1.73, -0.55] | -3.80 | < .001 + camper [1] | 0.73 | 0.41 | [-0.06, 1.53] | 1.80 | 0.072 + + # Fixed Effects (Zero-Inflation Component) + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -0.39 | 0.58 | [-1.52, 0.75] | -0.67 | 0.501 + child | 2.05 | 0.39 | [ 1.30, 2.81] | 5.33 | < .001 + camper [1] | -1.01 | 0.39 | [-1.77, -0.24] | -2.59 | 0.010 + + # Random Effects Variances + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 0.93 | [0.46, 1.89] + + # Random Effects (Zero-Inflation Component) + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 1.17 | [0.54, 2.57] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(out, table_width = Inf) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | p + -------------------------------------------------------------------- + (Intercept) | 251.40 | 6.28 | [239.09, 263.72] | 40.02 | < .001 + Days | 10.47 | 1.45 | [ 7.63, 13.31] | 7.23 | < .001 + + # Random Effects + + Parameter | Coefficient | 95% CI + ------------------------------------------------------------ + SD (Intercept: Subject) | 23.78 | [15.02, 37.66] + SD (Days: Subject) | 5.72 | [ 3.81, 8.59] + Cor (Intercept~Days: Subject) | 0.08 | [-0.49, 0.59] + SD (Residual) | 25.59 | [22.80, 28.72] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/include_reference.md b/tests/testthat/_snaps/include_reference.md deleted file mode 100644 index aa2d2b4b9..000000000 --- a/tests/testthat/_snaps/include_reference.md +++ /dev/null @@ -1,245 +0,0 @@ -# include_reference, on-the-fly factors - - Code - print(out1) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 - gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 - am [0] | 0.00 | | | | - am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 - hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out2) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 - gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 - am [0] | 0.00 | | | | - am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 - hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print_md(out) - Output - - - |Parameter | m1 | m2 | - |:------------|:--------------------|:--------------------| - |(Intercept) |27.48 (23.43, 31.53) |27.48 (23.43, 31.53) | - |gear (3) | 0.00 | 0.00 | - |gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | - |gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | - |am (0) | 0.00 | 0.00 | - |am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | - |hp |-0.06 (-0.09, -0.04) |-0.06 (-0.09, -0.04) | - | | | | - |Observations | 32 | 32 | - ---- - - Code - display(out, format = "tt") - Output - - +--------------+----------------------+----------------------+ - | Parameter | m1 | m2 | - +==============+======================+======================+ - | (Intercept) | 27.48 (23.43, 31.53) | 27.48 (23.43, 31.53) | - +--------------+----------------------+----------------------+ - | gear (3) | 0.00 | 0.00 | - +--------------+----------------------+----------------------+ - | gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | - +--------------+----------------------+----------------------+ - | gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | - +--------------+----------------------+----------------------+ - | am (0) | 0.00 | 0.00 | - +--------------+----------------------+----------------------+ - | am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | - +--------------+----------------------+----------------------+ - | hp | -0.06 (-0.09, -0.04) | -0.06 (-0.09, -0.04) | - +--------------+----------------------+----------------------+ - | | | | - +--------------+----------------------+----------------------+ - | Observations | 32 | 32 | - +--------------+----------------------+----------------------+ - -# include_reference, different contrasts - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------- - (Intercept) | 19.70 | 1.18 | [ 17.28, 22.11] | 16.71 | < .001 - cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 - cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 - gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------- - (Intercept) | 25.43 | 1.88 | [ 21.57, 29.29] | 13.52 | < .001 - cyl [4] | 0.00 | | | | - cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 - cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 - gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------- - (Intercept) | 20.64 | 0.67 | [ 19.26, 22.01] | 30.76 | < .001 - cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 - cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 - gear [1] | -0.94 | 1.09 | [ -3.18, 1.30] | -0.86 | 0.396 - gear [2] | 0.38 | 1.11 | [ -1.90, 2.67] | 0.34 | 0.734 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 15.83 | 1.24 | [13.28, 18.37] | 12.75 | < .001 - cyl [8] | 0.00 | | | | - cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 - cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 - gear [1] | -0.94 | 1.09 | [-3.18, 1.30] | -0.86 | 0.396 - gear [2] | 0.38 | 1.11 | [-1.90, 2.67] | 0.34 | 0.734 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 14.89 | 0.92 | [13.00, 16.77] | 16.19 | < .001 - cyl [8] | 0.00 | | | | - cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 - cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 - gear [3] | 0.00 | | | | - gear [4] | 1.32 | 1.93 | [-2.63, 5.28] | 0.69 | 0.498 - gear [5] | 1.50 | 1.85 | [-2.31, 5.31] | 0.81 | 0.426 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - -# include_reference, random effects models - - Code - print(out) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------------------- - (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 - flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 - island [Biscoe] | 1.00 | | | | - island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 - island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 - - # Random Effects - - Parameter | Coefficient | 95% CI - ------------------------------------------------ - SD (Intercept: year) | 3.05e-05 | [0.00, Inf] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(out, include_reference = TRUE) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------------------- - (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 - flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 - island [Biscoe] | 1.00 | | | | - island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 - island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 - - # Random Effects - - Parameter | Coefficient | 95% CI - ------------------------------------------------ - SD (Intercept: year) | 3.05e-05 | [0.00, Inf] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(out) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------------------- - (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 - flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 - island [Biscoe] | 1.00 | | | | - island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 - island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/ivreg.md b/tests/testthat/_snaps/ivreg.md deleted file mode 100644 index 9d4941d5e..000000000 --- a/tests/testthat/_snaps/ivreg.md +++ /dev/null @@ -1,20 +0,0 @@ -# print-model_parameters - - Code - tmp - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | t(45) | p - -------------------------------------------------------------------- - (Intercept) | 9.89 | 1.06 | [ 7.76, 12.03] | 9.35 | < .001 - rprice [log] | -1.28 | 0.26 | [-1.81, -0.75] | -4.85 | < .001 - rincome [log] | 0.28 | 0.24 | [-0.20, 0.76] | 1.18 | 0.246 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - - The model has a log-transformed response variable. Consider using - `exponentiate = TRUE` to interpret coefficients as ratios. - diff --git a/tests/testthat/_snaps/lcmm.md b/tests/testthat/_snaps/lcmm.md deleted file mode 100644 index d74cb291d..000000000 --- a/tests/testthat/_snaps/lcmm.md +++ /dev/null @@ -1,257 +0,0 @@ -# model_parameters lcmm - - Code - print(model_parameters(out$mx_linear), zap_small = TRUE) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------------------- - intercept class1 | 1.12 | 0.90 | [ -0.64, 2.89] | 1.25 | 0.211 - intercept class2 | 1.19 | 0.74 | [ -0.26, 2.65] | 1.61 | 0.107 - X1 class1 | 1.85 | 13.74 | [ -25.08, 28.77] | 0.13 | 0.893 - X1 class2 | 4.12 | 12.32 | [ -20.03, 28.26] | 0.33 | 0.738 - X2 class1 | 10.50 | 2079.25 | [-4064.75, 4085.74] | 0.01 | 0.996 - X2 class2 | 9.64 | 2078.80 | [-4064.73, 4084.02] | 0.00 | 0.996 - X3 class1 | -0.60 | 0.90 | [ -2.36, 1.17] | -0.66 | 0.508 - X3 class2 | 0.12 | 0.55 | [ -0.95, 1.19] | 0.23 | 0.822 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - - The model has a log- or logit-link. Consider using `exponentiate = - TRUE` to interpret coefficients as ratios. - - Some coefficients are very large, which may indicate issues with - complete separation. - ---- - - Code - print(model_parameters(out$mx_beta), zap_small = TRUE) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - ----------------------------------------------------------------------- - intercept class1 | 0.12 | 67.86 | [-132.89, 133.13] | 0.00 | 0.999 - intercept class2 | 1.55 | 35.86 | [ -68.73, 71.83] | 0.04 | 0.966 - X1 class1 | 0.51 | 24.20 | [ -46.92, 47.94] | 0.02 | 0.983 - X1 class2 | -1.02 | 26.22 | [ -52.41, 50.36] | -0.04 | 0.969 - X2 class1 | 15.95 | 14.97 | [ -13.39, 45.28] | 1.07 | 0.287 - X2 class2 | 15.44 | 9.01 | [ -2.22, 33.09] | 1.71 | 0.087 - X3 class1 | 0.44 | 14.56 | [ -28.09, 28.97] | 0.03 | 0.976 - X3 class2 | -0.35 | 18.61 | [ -36.81, 36.12] | -0.02 | 0.985 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$mx_splines), zap_small = TRUE) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------------------- - intercept class1 | -1.46 | 0.83 | [ -3.09, 0.17] | -1.75 | 0.080 - intercept class2 | -1.53 | 0.83 | [ -3.16, 0.11] | -1.83 | 0.067 - X1 class1 | 1.58 | 0.71 | [ 0.18, 2.97] | 2.22 | 0.027 - X1 class2 | 0.86 | 1.83 | [ -2.73, 4.45] | 0.47 | 0.639 - X2 class1 | 0.47 | 0.98 | [ -1.44, 2.38] | 0.48 | 0.631 - X2 class2 | -21.31 | 1194.95 | [-2363.38, 2320.75] | -0.02 | 0.986 - X3 class1 | 0.80 | 0.38 | [ 0.05, 1.54] | 2.10 | 0.036 - X3 class2 | 0.30 | 0.63 | [ -0.95, 1.54] | 0.47 | 0.638 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m1_linear), zap_small = TRUE) - Output - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Time | -0.78 | 0.19 | [-1.15, -0.40] | -4.09 | < .001 - I(Time^2) | -0.18 | 0.08 | [-0.33, -0.04] | -2.44 | 0.015 - - # linear - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------------------- - Linear 1 (intercept) | 25.40 | 0.23 | [24.96, 25.85] | 112.34 | < .001 - Linear 2 (std err) | 2.24 | 0.04 | [ 2.15, 2.33] | 50.37 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m1_beta), zap_small = TRUE) - Output - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Time | -0.88 | 0.19 | [-1.25, -0.51] | -4.62 | < .001 - I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.34 | 0.180 - - # beta - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Beta1 | 0.54 | 0.07 | [ 0.41, 0.68] | 7.97 | < .001 - Beta2 | -0.76 | 0.09 | [-0.94, -0.58] | -8.36 | < .001 - Beta3 | 0.70 | 0.02 | [ 0.67, 0.74] | 42.20 | < .001 - Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 20.53 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m1_splines), zap_small = TRUE) - Output - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Time | -0.89 | 0.19 | [-1.26, -0.52] | -4.68 | < .001 - I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.28 | 0.200 - - # splines - - Parameter | Coefficient | SE | 95% CI | z | p - ------------------------------------------------------------------ - I-splines1 | -7.76 | 0.59 | [-8.92, -6.59] | -13.04 | < .001 - I-splines2 | 0.76 | 0.28 | [ 0.21, 1.31] | 2.71 | 0.007 - I-splines3 | 0.81 | 0.41 | [ 0.00, 1.63] | 1.96 | 0.049 - I-splines4 | 1.44 | 0.13 | [ 1.18, 1.70] | 10.85 | < .001 - I-splines5 | -1.67 | 0.06 | [-1.80, -1.54] | -25.86 | < .001 - I-splines6 | 1.62 | 0.05 | [ 1.52, 1.72] | 32.56 | < .001 - I-splines7 | 1.30 | 0.05 | [ 1.20, 1.40] | 25.33 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m2_linear), zap_small = TRUE) - Output - # membership - - Parameter | Coefficient | SE | 95% CI | z | p - -------------------------------------------------------------------- - intercept class1 | 1.69 | 0.95 | [-0.18, 3.56] | 1.77 | 0.076 - intercept class2 | 2.47 | 0.79 | [ 0.91, 4.02] | 3.11 | 0.002 - - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------------- - intercept class2 | 0.68 | 0.33 | [ 0.03, 1.32] | 2.06 | 0.039 - intercept class3 | -0.63 | 0.68 | [-1.97, 0.70] | -0.93 | 0.353 - Time class1 | -1.12 | 0.56 | [-2.21, -0.03] | -2.01 | 0.045 - Time class2 | -0.37 | 0.25 | [-0.86, 0.13] | -1.44 | 0.151 - Time class3 | -2.90 | 1.48 | [-5.80, 0.00] | -1.96 | 0.050 - I(Time^2) class1 | -0.52 | 0.24 | [-0.98, -0.06] | -2.21 | 0.027 - I(Time^2) class2 | -0.15 | 0.09 | [-0.34, 0.03] | -1.67 | 0.094 - I(Time^2) class3 | 0.79 | 0.70 | [-0.59, 2.18] | 1.13 | 0.260 - - # linear - - Parameter | Coefficient | SE | 95% CI | z | p - --------------------------------------------------------------------------- - Linear 1 (intercept) | 24.46 | 0.60 | [23.28, 25.64] | 40.56 | < .001 - Linear 2 (std err) | 2.23 | 0.04 | [ 2.14, 2.32] | 50.22 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m2_beta), zap_small = TRUE) - Output - # membership - - Parameter | Coefficient | SE | 95% CI | z | p - -------------------------------------------------------------------- - intercept class1 | 0.93 | 1.48 | [-1.97, 3.83] | 0.63 | 0.531 - intercept class2 | 1.36 | 1.10 | [-0.79, 3.51] | 1.24 | 0.214 - - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ----------------------------------------------------------------------- - intercept class2 | -0.54 | 0.44 | [-1.41, 0.33] | -1.22 | 0.221 - intercept class3 | -0.99 | 0.64 | [-2.25, 0.27] | -1.54 | 0.123 - Time class1 | -0.52 | 0.67 | [-1.83, 0.79] | -0.77 | 0.438 - Time class2 | -1.68 | 0.33 | [-2.32, -1.04] | -5.14 | < .001 - Time class3 | 1.61 | 1.09 | [-0.52, 3.74] | 1.48 | 0.138 - I(Time^2) class1 | 0.02 | 0.23 | [-0.43, 0.47] | 0.07 | 0.943 - I(Time^2) class2 | -0.07 | 0.13 | [-0.33, 0.20] | -0.50 | 0.618 - I(Time^2) class3 | -0.69 | 0.39 | [-1.46, 0.09] | -1.74 | 0.082 - - # beta - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Beta1 | 0.60 | 0.06 | [ 0.48, 0.73] | 9.34 | < .001 - Beta2 | -0.83 | 0.09 | [-1.01, -0.66] | -9.39 | < .001 - Beta3 | 0.73 | 0.03 | [ 0.67, 0.80] | 22.27 | < .001 - Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 21.88 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m2_splines), zap_small = TRUE) - Output - # membership - - Parameter | Coefficient | SE | 95% CI | z | p - --------------------------------------------------------------------- - intercept class1 | -0.46 | 0.45 | [-1.33, 0.42] | -1.01 | 0.310 - intercept class2 | -1.40 | 1.06 | [-3.48, 0.68] | -1.32 | 0.186 - - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ----------------------------------------------------------------------- - intercept class2 | -1.03 | 0.67 | [-2.34, 0.27] | -1.55 | 0.121 - intercept class3 | -0.55 | 0.41 | [-1.36, 0.26] | -1.34 | 0.182 - Time class1 | -0.48 | 0.59 | [-1.63, 0.67] | -0.81 | 0.415 - Time class2 | 1.65 | 1.10 | [-0.50, 3.80] | 1.50 | 0.133 - Time class3 | -1.72 | 0.32 | [-2.35, -1.09] | -5.36 | < .001 - I(Time^2) class1 | 0.01 | 0.20 | [-0.38, 0.40] | 0.03 | 0.972 - I(Time^2) class2 | -0.70 | 0.40 | [-1.49, 0.08] | -1.76 | 0.078 - I(Time^2) class3 | -0.04 | 0.13 | [-0.30, 0.22] | -0.33 | 0.743 - - # splines - - Parameter | Coefficient | SE | 95% CI | z | p - ------------------------------------------------------------------ - I-splines1 | -7.87 | 0.62 | [-9.09, -6.66] | -12.67 | < .001 - I-splines2 | 0.72 | 0.27 | [ 0.20, 1.24] | 2.70 | 0.007 - I-splines3 | 0.77 | 0.41 | [-0.03, 1.57] | 1.88 | 0.060 - I-splines4 | 1.37 | 0.13 | [ 1.11, 1.63] | 10.35 | < .001 - I-splines5 | -1.66 | 0.06 | [-1.79, -1.54] | -25.77 | < .001 - I-splines6 | 1.64 | 0.05 | [ 1.54, 1.73] | 33.01 | < .001 - I-splines7 | 1.28 | 0.05 | [ 1.18, 1.39] | 24.94 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/mipo.md b/tests/testthat/_snaps/mipo.md deleted file mode 100644 index ba22deb84..000000000 --- a/tests/testthat/_snaps/mipo.md +++ /dev/null @@ -1,42 +0,0 @@ -# param ordinal - - Code - print(mp) - Output - # 6 response - - Parameter | Coefficient | SE | 95% CI | Statistic | df | p - -------------------------------------------------------------------------------- - (Intercept) | -54.29 | 46.90 | [-151.05, 42.46] | -1.16 | 24.19 | 0.258 - disp | 0.22 | 0.39 | [ -0.58, 1.02] | 0.58 | 23.81 | 0.570 - hp | 0.20 | 0.57 | [ -0.97, 1.38] | 0.36 | 23.73 | 0.724 - - # 8 response - - Parameter | Coefficient | SE | 95% CI | Statistic | df | p - -------------------------------------------------------------------------------- - (Intercept) | -92.86 | 67.62 | [-232.47, 46.75] | -1.37 | 23.87 | 0.182 - disp | 0.26 | 0.40 | [ -0.57, 1.09] | 0.64 | 23.53 | 0.528 - hp | 0.43 | 0.63 | [ -0.88, 1.73] | 0.67 | 24.15 | 0.507 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald distribution approximation. - -# param normal - - Code - print(mp) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | Statistic | df | p - ---------------------------------------------------------------------------------- - (Intercept) | 30.65 | 1.43 | [27.72, 33.58] | 21.46 | 26.96 | < .001 - disp | -0.03 | 7.52e-03 | [-0.05, -0.02] | -4.40 | 25.57 | < .001 - hp | -0.02 | 0.01 | [-0.05, 0.01] | -1.37 | 24.82 | 0.182 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald distribution approximation. - diff --git a/tests/testthat/_snaps/model_parameters.anova.md b/tests/testthat/_snaps/model_parameters.anova.md index da9f8cd8f..5fad54b2d 100644 --- a/tests/testthat/_snaps/model_parameters.anova.md +++ b/tests/testthat/_snaps/model_parameters.anova.md @@ -26,33 +26,3 @@ Anova Table (Type 3 tests) -# anova survey - - Code - print(model_parameters(out)) - Output - # Fixed Effects - - Parameter | DEff | Chi2(1) | df (error) | p - ----------------------------------------------- - ell | 0.77 | 1.13 | 38 | 0.236 - meals | 1.24 | 4.82 | 37 | 0.058 - ell:meals | 1.48 | 16.52 | 36 | 0.002 - - Anova Table (Type 1 tests) - ---- - - Code - print(model_parameters(out)) - Output - # Fixed Effects - - Parameter | df | df (error) | F | p - ------------------------------------------ - ell | 1 | 38 | 1.47 | 0.234 - meals | 1 | 37 | 3.54 | 0.068 - ell:meals | 1 | 36 | 9.10 | 0.005 - - Anova Table (Type 1 tests) - diff --git a/tests/testthat/_snaps/model_parameters.fixest.md b/tests/testthat/_snaps/model_parameters.fixest.md index e7c7c527b..59cc0556c 100644 --- a/tests/testthat/_snaps/model_parameters.fixest.md +++ b/tests/testthat/_snaps/model_parameters.fixest.md @@ -15,28 +15,3 @@ RMSE : 10.069 r2: 0.743; ar2: 0.613; wr2: 0.180; war2: 0.175 -# model_parameters works for fixest-negbin - - Code - print(out) - Output - # Fixed Effects - - Parameter | Log-Mean | SE | 95% CI | t(636) | p - ---------------------------------------------------------------- - (Intercept) | -1.46 | 0.21 | [-1.86, -1.06] | -7.11 | < .001 - mined [no] | 2.04 | 0.15 | [ 1.75, 2.33] | 13.72 | < .001 - spp [PR] | -1.23 | 0.29 | [-1.80, -0.65] | -4.20 | < .001 - spp [DM] | 0.40 | 0.23 | [-0.05, 0.86] | 1.75 | 0.080 - spp [EC-A] | -0.67 | 0.26 | [-1.18, -0.16] | -2.60 | 0.010 - spp [EC-L] | 0.64 | 0.22 | [ 0.20, 1.07] | 2.89 | 0.004 - spp [DES-L] | 0.82 | 0.22 | [ 0.38, 1.26] | 3.69 | < .001 - spp [DF] | 0.36 | 0.24 | [-0.10, 0.82] | 1.52 | 0.128 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - - The model has a log- or logit-link. Consider using `exponentiate = - TRUE` to interpret coefficients as ratios. - diff --git a/tests/testthat/_snaps/model_parameters.fixest_multi.md b/tests/testthat/_snaps/model_parameters.fixest_multi.md deleted file mode 100644 index 82362a7f2..000000000 --- a/tests/testthat/_snaps/model_parameters.fixest_multi.md +++ /dev/null @@ -1,160 +0,0 @@ -# model_parameters.fixest_multi - - Code - print(model_parameters(mod)) - Output - # Petal.Width ~ x - - Parameter | Coefficient | SE | 95% CI | t(146) | p - --------------------------------------------------------------- - x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 - - # Sepal.Width ~ x - - Parameter | Coefficient | SE | 95% CI | t(146) | p - --------------------------------------------------------------- - x | 0.05 | 0.03 | [-0.01, 0.10] | 1.56 | 0.120 - - # Petal.Width ~ x + Petal.Length - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 - Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 - - # Sepal.Width ~ x + Petal.Length - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 - Petal.Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 - - # Petal.Width ~ x + Petal.Length + Sepal.Length - - Parameter | Coefficient | SE | 95% CI | t(144) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 - Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 - Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 - - # Sepal.Width ~ x + Petal.Length + Sepal.Length - - Parameter | Coefficient | SE | 95% CI | t(144) | p - ------------------------------------------------------------------- - x | 0.03 | 0.03 | [-0.02, 0.09] | 1.37 | 0.171 - Petal.Length | -0.04 | 0.08 | [-0.21, 0.13] | -0.45 | 0.651 - Sepal.Length | 0.37 | 0.07 | [ 0.23, 0.51] | 5.23 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(ci(mod)) - Output - Parameter CI CI_low CI_high Response - 1 x 0.95 -0.01929491 0.05165987 Petal.Width - 2 x 0.95 -0.01715341 0.04515343 Petal.Width - 3 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width - 4 x 0.95 -0.01722960 0.04542622 Petal.Width - 5 Petal.Length 0.95 0.12908917 0.33808245 Petal.Width - 6 Sepal.Length 0.95 -0.09172321 0.08324053 Petal.Width - 7 x 0.95 -0.01227870 0.10484812 Sepal.Width - 8 x 0.95 -0.01093910 0.09787861 Sepal.Width - 9 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width - 10 x 0.95 -0.01527889 0.08504860 Sepal.Width - 11 Petal.Length 0.95 -0.20565718 0.12899281 Sepal.Width - 12 Sepal.Length 0.95 0.23032902 0.51048930 Sepal.Width - Group - 1 x - 2 x + Petal.Length - 3 x + Petal.Length - 4 x + Petal.Length + Sepal.Length - 5 x + Petal.Length + Sepal.Length - 6 x + Petal.Length + Sepal.Length - 7 x - 8 x + Petal.Length - 9 x + Petal.Length - 10 x + Petal.Length + Sepal.Length - 11 x + Petal.Length + Sepal.Length - 12 x + Petal.Length + Sepal.Length - ---- - - Code - print(model_parameters(mod)) - Output - # Petal.Width response - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 - Petal Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 - - # Sepal.Width response - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 - Petal Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(ci(mod)) - Output - Parameter CI CI_low CI_high Response - 1 x 0.95 -0.01715341 0.04515343 Petal.Width - 2 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width - 3 x 0.95 -0.01093910 0.09787861 Sepal.Width - 4 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width - ---- - - Code - print(model_parameters(mod)) - Output - # x - - Parameter | Coefficient | SE | 95% CI | t(146) | p - --------------------------------------------------------------- - x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 - - # x + Petal.Length - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 - Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 - - # x + Petal.Length + Sepal.Length - - Parameter | Coefficient | SE | 95% CI | t(144) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 - Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 - Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(ci(mod)) - Output - Parameter CI CI_low CI_high Group - 1 x 0.95 -0.01929491 0.05165987 x - 2 x 0.95 -0.01715341 0.04515343 x + Petal.Length - 3 Petal.Length 0.95 0.16163902 0.29786840 x + Petal.Length - 4 x 0.95 -0.01722960 0.04542622 x + Petal.Length + Sepal.Length - 5 Petal.Length 0.95 0.12908917 0.33808245 x + Petal.Length + Sepal.Length - 6 Sepal.Length 0.95 -0.09172321 0.08324053 x + Petal.Length + Sepal.Length - diff --git a/tests/testthat/_snaps/model_parameters.glmgee.md b/tests/testthat/_snaps/model_parameters.glmgee.md deleted file mode 100644 index da1e47fb8..000000000 --- a/tests/testthat/_snaps/model_parameters.glmgee.md +++ /dev/null @@ -1,20 +0,0 @@ -# model_parameters.glmgee - - Code - print(out) - Output - # Fixed Effects - - Parameter | Log-Prevalence | SE | 95% CI | z | p - --------------------------------------------------------------------------------- - (Intercept) | 5.90 | 0.10 | [ 5.70, 6.11] | 56.30 | < .001 - days [1st degree] | 19.20 | 0.52 | [18.18, 20.22] | 37.03 | < .001 - days [2nd degree] | -2.86 | 0.21 | [-3.26, -2.45] | -13.88 | < .001 - days [3rd degree] | 5.42 | 0.18 | [ 5.06, 5.77] | 29.69 | < .001 - days [4th degree] | -3.57 | 0.12 | [-3.82, -3.33] | -28.64 | < .001 - treat [ozone-enriched] | -0.26 | 0.13 | [-0.51, -0.01] | -2.01 | 0.044 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/model_parameters.mclogit.md b/tests/testthat/_snaps/model_parameters.mclogit.md deleted file mode 100644 index 5db8ac5a9..000000000 --- a/tests/testthat/_snaps/model_parameters.mclogit.md +++ /dev/null @@ -1,80 +0,0 @@ -# model_parameters.mclogit - - Code - params - Output - Parameter | Log-Odds | SE | 95% CI | z | p - -------------------------------------------------------------- - distance | -1.44 | 0.05 | [-1.54, -1.34] | -27.07 | < .001 - cost | -0.98 | 0.04 | [-1.06, -0.90] | -24.52 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# model_parameters.mblogit - - Code - params - Output - # Response level: medium - - Parameter | Log-Odds | SE | 95% CI | z | p - ----------------------------------------------------------------- - (Intercept) | -0.42 | 0.17 | [-0.76, -0.08] | -2.42 | 0.015 - InflMedium | 0.45 | 0.14 | [ 0.17, 0.72] | 3.15 | 0.002 - InflHigh | 0.66 | 0.19 | [ 0.30, 1.03] | 3.57 | < .001 - TypeApartment | -0.44 | 0.17 | [-0.77, -0.10] | -2.53 | 0.012 - TypeAtrium | 0.13 | 0.22 | [-0.31, 0.57] | 0.59 | 0.556 - TypeTerrace | -0.67 | 0.21 | [-1.07, -0.26] | -3.23 | 0.001 - ContHigh | 0.36 | 0.13 | [ 0.10, 0.62] | 2.73 | 0.006 - - # Response level: high - - Parameter | Log-Odds | SE | 95% CI | z | p - ----------------------------------------------------------------- - (Intercept) | -0.14 | 0.16 | [-0.45, 0.17] | -0.87 | 0.384 - InflMedium | 0.73 | 0.14 | [ 0.47, 1.00] | 5.37 | < .001 - InflHigh | 1.61 | 0.17 | [ 1.29, 1.94] | 9.65 | < .001 - TypeApartment | -0.74 | 0.16 | [-1.04, -0.43] | -4.74 | < .001 - TypeAtrium | -0.41 | 0.21 | [-0.82, 0.01] | -1.93 | 0.054 - TypeTerrace | -1.41 | 0.20 | [-1.80, -1.02] | -7.06 | < .001 - ContHigh | 0.48 | 0.12 | [ 0.24, 0.73] | 3.88 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# simulate_parameters.mblogit - - Code - params - Output - # Medium response - - Parameter | Coefficient | 95% CI | p - ----------------------------------------------------- - (Intercept) | -0.41 | [-0.75, -0.10] | 0.016 - InflMedium | 0.44 | [ 0.18, 0.71] | < .001 - InflHigh | 0.66 | [ 0.34, 1.03] | < .001 - TypeApartment | -0.44 | [-0.79, -0.10] | 0.008 - TypeAtrium | 0.12 | [-0.28, 0.58] | 0.582 - TypeTerrace | -0.66 | [-1.09, -0.28] | 0.004 - ContHigh | 0.36 | [ 0.11, 0.61] | < .001 - - # High response - - Parameter | Coefficient | 95% CI | p - ----------------------------------------------------- - (Intercept) | -0.13 | [-0.43, 0.16] | 0.378 - InflMedium | 0.73 | [ 0.45, 0.98] | < .001 - InflHigh | 1.61 | [ 1.29, 1.94] | < .001 - TypeApartment | -0.73 | [-1.05, -0.44] | < .001 - TypeAtrium | -0.41 | [-0.82, 0.01] | 0.054 - TypeTerrace | -1.42 | [-1.81, -1.03] | < .001 - ContHigh | 0.47 | [ 0.22, 0.73] | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a MCMC distribution approximation. - diff --git a/tests/testthat/_snaps/plm.md b/tests/testthat/_snaps/plm.md deleted file mode 100644 index 8490ec38b..000000000 --- a/tests/testthat/_snaps/plm.md +++ /dev/null @@ -1,34 +0,0 @@ -# vcov standard errors - - Code - print(model_parameters(ran)) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | df | p - ----------------------------------------------------------------------------- - (Intercept) | 817.10 | 188.26 | [445.84, 1188.36] | 4.34 | 197 | < .001 - capital | -0.58 | 0.15 | [ -0.88, -0.29] | -3.95 | 197 | < .001 - inv | 2.92 | 0.30 | [ 2.33, 3.51] | 9.80 | 197 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(ran, vcov = "HC1")) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | df | p - ---------------------------------------------------------------------------- - (Intercept) | 817.10 | 274.75 | [275.28, 1358.92] | 2.97 | 197 | 0.003 - capital | -0.58 | 0.43 | [ -1.43, 0.26] | -1.37 | 197 | 0.173 - inv | 2.92 | 0.89 | [ 1.16, 4.67] | 3.28 | 197 | 0.001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/print_AER_labels.md b/tests/testthat/_snaps/print_AER_labels.md deleted file mode 100644 index 92b571b63..000000000 --- a/tests/testthat/_snaps/print_AER_labels.md +++ /dev/null @@ -1,19 +0,0 @@ -# templates - - Code - print(mp, pretty_names = "labels") - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | p - ----------------------------------------------------------------------------------------------- - (Intercept) | 8.72 | 3.45 | [ 1.95, 15.48] | 2.52 | 0.012 - elder's dependency [slightly dependent] | -1.00 | 3.61 | [-8.08, 6.08] | -0.28 | 0.782 - elder's dependency [moderately dependent] | 2.68 | 3.06 | [-3.32, 8.68] | 0.88 | 0.381 - elder's dependency [severely dependent] | 3.88 | 3.00 | [-2.01, 9.77] | 1.29 | 0.197 - carer's level of education | 1.14 | 0.90 | [-0.62, 2.90] | 1.27 | 0.204 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/printing-stan.new.md b/tests/testthat/_snaps/printing-stan.new.md new file mode 100644 index 000000000..db01c7075 --- /dev/null +++ b/tests/testthat/_snaps/printing-stan.new.md @@ -0,0 +1,256 @@ +# print brms + + Code + mp1 + Output + # Fixed Effects + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------ + (Intercept) | 39.68 | [36.12, 43.27] | 100% | 1.000 | 3255 + wt | -3.21 | [-4.79, -1.65] | 99.95% | 1.002 | 2003 + cyl | -1.50 | [-2.36, -0.64] | 99.95% | 1.002 | 2227 + + # sigma Parameters + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ----------------------------------------------------------- + sigma | 2.67 | [2.06, 3.51] | 100% | 1.001 | 2415 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +--- + + Code + mp2 + Output + # Fixed Effects + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ---------------------------------------------------------------- + (Intercept) | 33.55 | [24.17, 40.87] | 100% | 1.090 | 157 + wt | -4.49 | [-6.95, -1.68] | 100% | 1.168 | 81 + + # sigma Parameters + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ----------------------------------------------------------- + sigma | 2.56 | [1.95, 3.48] | 100% | 1.294 | 541 + + # Random Effects Variances + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------------------- + SD (Intercept: cyl) | 3.00 | [ 0.39, 9.19] | 100% | 1.109 | 575 + SD (Intercept: gear) | 3.88 | [ 0.21, 10.30] | 100% | 1.285 | 916 + SD (wt: gear) | 1.96 | [ 0.06, 5.06] | 100% | 1.219 | 186 + Cor (Intercept~wt: gear) | -0.25 | [-0.99, 0.83] | 62.48% | 1.077 | 85 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +--- + + Code + mp3 + Output + # Fixed Effects + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------- + (Intercept) | 251.32 | [237.00, 265.98] | 100% | 1.001 | 2415 + Days | 10.44 | [ 6.84, 13.91] | 100% | 1.004 | 1641 + + # sigma Parameters + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + -------------------------------------------------------------- + sigma | 25.94 | [23.05, 29.38] | 100% | 1.002 | 2781 + + # Random Effects Variances + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------------------------ + SD (Intercept: Subject) | 26.63 | [15.46, 42.36] | 100% | 1.002 | 2683 + SD (Days: Subject) | 6.58 | [ 4.12, 10.16] | 100% | 1.001 | 1961 + Cor (Intercept~Days: Subject) | 0.09 | [-0.47, 0.67] | 60.42% | 1.003 | 1625 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +--- + + Code + mp4 + Output + # Fixed Effects + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------- + (Intercept) | 250.84 | [228.76, 272.54] | 100% | 1.002 | 1607 + Days | 10.37 | [ 8.77, 11.96] | 100% | 0.999 | 2848 + + # sigma Parameters + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + -------------------------------------------------------------- + sigma | 30.03 | [26.27, 34.03] | 100% | 1.000 | 2289 + + # Random Effects Variances + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------------------- + SD (Intercept: grp) | 8.22 | [ 0.44, 25.69] | 100% | 1.001 | 1788 + SD (Intercept: grp:subgrp) | 7.41 | [ 0.44, 16.87] | 100% | 1.003 | 1480 + SD (Intercept: Subject) | 38.51 | [26.89, 55.98] | 100% | 1.002 | 1893 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +--- + + Code + mp5 + Output + # Fixed Effects + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + --------------------------------------------------------------- + (Intercept) | 2.57 | [0.70, 4.84] | 99.42% | 1.009 | 197 + Petal.Width | 1.05 | [0.73, 1.37] | 100% | 1.004 | 2213 + + # sigma Parameters + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ----------------------------------------------------------- + sigma | 0.38 | [0.34, 0.43] | 100% | 1.002 | 2011 + + # Random Effects Variances + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------------- + SD (Intercept: Species) | 1.68 | [0.64, 3.64] | 100% | 1.007 | 774 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +--- + + Code + mp6 + Output + # Fixed Effects + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------ + (Intercept) | 33.06 | [24.70, 40.47] | 100% | 1.021 | 666 + wt | -4.39 | [-6.94, -1.76] | 99.72% | 1.024 | 102 + + # sigma Parameters + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ----------------------------------------------------------- + sigma | 2.59 | [1.96, 3.48] | 100% | 1.009 | 902 + + # Random Effects Variances + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------------------- + SD (Intercept: cyl) | 3.19 | [ 0.49, 9.00] | 100% | 1.003 | 350 + SD (Intercept: gear) | 3.76 | [ 0.14, 10.13] | 100% | 1.015 | 1264 + SD (wt: gear) | 1.47 | [ 0.06, 3.96] | 100% | 1.034 | 660 + Cor (Intercept~wt: gear) | -0.38 | [-0.99, 0.82] | 76.85% | 1.022 | 893 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +--- + + Code + mp7 + Output + # Fixed Effects + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ---------------------------------------------------------------- + (Intercept) | -1.07 | [-1.42, -0.73] | 100% | 1.001 | 2806 + persons | 0.90 | [ 0.81, 0.99] | 100% | 1.001 | 3057 + child | -1.17 | [-1.37, -0.99] | 100% | 1.002 | 2560 + camper | 0.74 | [ 0.56, 0.94] | 100% | 1.000 | 2879 + + # Zero-Inflation Parameters + + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + ----------------------------------------------------------------- + (Intercept) | -0.58 | [-1.27, 0.08] | 95.97% | 1.001 | 2969 + child | 1.24 | [ 0.71, 1.82] | 100% | 1.001 | 2872 + camper | -0.62 | [-1.38, 0.11] | 94.73% | 1.000 | 3040 + +--- + + Code + mp9 + Output + Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) + -------------------------------------------------------------------- + Intercept[1] | -38.42 | [-67.76, -19.66] | 100% | 1.001 | 1121 + Intercept[2] | -33.26 | [-59.09, -16.53] | 100% | 1.001 | 1111 + mpg | -1.80 | [ -3.20, -0.90] | 100% | 1.002 | 1172 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +# print-information + + Code + out + Output + # Fixed Effects + + Parameter | Median | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------- + (Intercept) | 39.68 | [36.12, 43.27] | 100% | 1.000 | 3255 + wt | -3.20 | [-4.79, -1.65] | 99.95% | 1.002 | 2003 + cyl | -1.49 | [-2.36, -0.64] | 99.95% | 1.002 | 2227 + + # Sigma + + Parameter | Median | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------- + sigma | 2.63 | [2.06, 3.51] | 100% | 1.001 | 2415 + Message + + Uncertainty intervals (equal-tailed) computed using a MCMC distribution + approximation. + +--- + + Code + out + Output + # Fixed Effects + + Parameter | Median | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------------- + (Intercept) | 39.68 | [36.27, 43.34] | 100% | 1.000 | 3255 + wt | -3.20 | [-4.70, -1.57] | 99.95% | 1.002 | 2003 + cyl | -1.49 | [-2.38, -0.68] | 99.95% | 1.002 | 2227 + + # Sigma + + Parameter | Median | 95% CI | pd | Rhat | ESS (tail) + ------------------------------------------------------------- + sigma | 2.63 | [1.99, 3.39] | 100% | 1.001 | 2415 + Message + + Uncertainty intervals (highest-density) computed using a MCMC + distribution approximation. + diff --git a/tests/testthat/_snaps/sampleSelection.md b/tests/testthat/_snaps/sampleSelection.md deleted file mode 100644 index d2eef03be..000000000 --- a/tests/testthat/_snaps/sampleSelection.md +++ /dev/null @@ -1,71 +0,0 @@ -# model_parameters - - Code - print(model_parameters(m1), zap_small = TRUE, table_width = Inf) - Output - # selection - - Parameter | Coefficient | SE | 95% CI | t(490) | p - ------------------------------------------------------------------ - (Intercept) | -0.15 | 0.11 | [-0.36, 0.05] | -1.47 | 0.141 - xs | 1.14 | 0.18 | [ 0.79, 1.49] | 6.39 | < .001 - - # outcome - - Parameter | Coefficient | SE | 95% CI | t(490) | p - ------------------------------------------------------------------ - (Intercept) | 0.03 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 - xo1 | 0.84 | 0.15 | [ 0.55, 1.13] | 5.61 | < .001 - (Intercept) | 0.16 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 - xo2 | 0.84 | 0.17 | [ 0.50, 1.17] | 4.91 | < .001 - - # Auxiliary - - Parameter | Coefficient | SE | 95% CI | t(490) | p - ---------------------------------------------------------------- - sigma1 | 0.93 | 0.09 | [ 0.75, 1.11] | 10.12 | < .001 - rho1 | 0.89 | 0.05 | [ 0.78, 1.00] | 16.62 | < .001 - sigma2 | 0.91 | 0.04 | [ 0.82, 0.99] | 20.45 | < .001 - rho2 | 0.18 | 0.33 | [-0.47, 0.83] | 0.53 | 0.594 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(model_parameters(m2), zap_small = TRUE, table_width = Inf) - Output - # selection - - Parameter | Coefficient | SE | 95% CI | t(740) | p - ------------------------------------------------------------------- - (Intercept) | -4.12 | 1.40 | [-6.87, -1.37] | -2.94 | 0.003 - age | 0.18 | 0.07 | [ 0.05, 0.31] | 2.79 | 0.005 - age^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -3.12 | 0.002 - faminc | 0.00 | 0.00 | [ 0.00, 0.00] | 1.29 | 0.199 - kidsTRUE | -0.45 | 0.13 | [-0.71, -0.20] | -3.46 | < .001 - educ | 0.10 | 0.02 | [ 0.05, 0.14] | 4.12 | < .001 - - # outcome - - Parameter | Coefficient | SE | 95% CI | t(740) | p - ------------------------------------------------------------------ - (Intercept) | -1.96 | 1.20 | [-4.32, 0.39] | -1.64 | 0.102 - exper | 0.03 | 0.06 | [-0.09, 0.15] | 0.45 | 0.651 - exper^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -0.06 | 0.955 - educ | 0.46 | 0.07 | [ 0.31, 0.60] | 6.24 | < .001 - city | 0.45 | 0.32 | [-0.17, 1.07] | 1.41 | 0.158 - - # Auxiliary - - Parameter | Coefficient | SE | 95% CI | t(740) | p - ---------------------------------------------------------------- - sigma | 3.11 | 0.11 | [ 2.88, 3.33] | 27.31 | < .001 - rho | -0.13 | 0.17 | [-0.46, 0.19] | -0.80 | 0.424 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - diff --git a/tests/testthat/_snaps/serp.md b/tests/testthat/_snaps/serp.md deleted file mode 100644 index e92edd9bf..000000000 --- a/tests/testthat/_snaps/serp.md +++ /dev/null @@ -1,24 +0,0 @@ -# model_parameters.serp - - Code - suppressMessages(print(mp)) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - ------------------------------------------------------------------------------ - (Intercept):1 | 1.40 | 0.54 | [ 0.33, 2.46] | 2.57 | 0.010 - (Intercept):2 | -1.13 | 0.51 | [-2.13, -0.12] | -2.19 | 0.028 - (Intercept):3 | -3.44 | 0.71 | [-4.84, -2.04] | -4.82 | < .001 - (Intercept):4 | -4.98 | 0.95 | [-6.85, -3.11] | -5.23 | < .001 - tempwarm:1 | 2.38 | 0.81 | [ 0.79, 3.97] | 2.93 | 0.003 - tempwarm:2 | 2.26 | 0.71 | [ 0.87, 3.66] | 3.18 | 0.001 - tempwarm:3 | 2.41 | 0.77 | [ 0.89, 3.92] | 3.11 | 0.002 - tempwarm:4 | 2.51 | 0.88 | [ 0.79, 4.23] | 2.85 | 0.004 - contactyes:1 | 1.38 | 0.74 | [-0.08, 2.84] | 1.85 | 0.064 - contactyes:2 | 1.35 | 0.67 | [ 0.03, 2.66] | 2.01 | 0.044 - contactyes:3 | 1.35 | 0.76 | [-0.13, 2.83] | 1.78 | 0.075 - contactyes:4 | 1.22 | 0.86 | [-0.46, 2.89] | 1.42 | 0.156 - temp [warm] * contactyes:1 | 0.37 | 1.12 | [-1.82, 2.56] | 0.33 | 0.741 - temp [warm] * contactyes:2 | 0.35 | 1.03 | [-1.66, 2.37] | 0.34 | 0.730 - temp [warm] * contactyes:3 | 0.36 | 0.97 | [-1.55, 2.26] | 0.37 | 0.713 - temp [warm] * contactyes:4 | 0.32 | 1.02 | [-1.68, 2.33] | 0.32 | 0.751 - diff --git a/tests/testthat/_snaps/svylme.md b/tests/testthat/_snaps/svylme.md deleted file mode 100644 index b00a05ce8..000000000 --- a/tests/testthat/_snaps/svylme.md +++ /dev/null @@ -1,26 +0,0 @@ -# model_parameters svylme - - Code - print(mp) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | t | p - -------------------------------------------------------------------- - (Intercept) | -60.98 | 34.48 | [-128.57, 6.61] | -1.77 | 0.077 - ell | 0.92 | 0.26 | [ 0.41, 1.42] | 3.56 | < .001 - mobility | -0.38 | 0.24 | [ -0.85, 0.08] | -1.60 | 0.109 - api99 | 1.10 | 0.03 | [ 1.03, 1.17] | 31.44 | < .001 - - # Random Effects - - Parameter | Coefficient - ----------------------------------- - SD (Intercept: dnum1) | 1.19 - SD (api99: dnum2) | 1.39e-03 - SD (Residual) | 20.00 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg deleted file mode 100644 index c8cbe8996..000000000 --- a/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - -Coefficient -Parameter - - - - - - - -0 -10 -20 -30 -40 -50 - - - - - -gear -cyl -wt -(Intercept) - - - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg deleted file mode 100644 index 82b6c824b..000000000 --- a/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - -Coefficient -Parameter - - - - - - - -0 -10 -20 -30 -40 -50 - - - - - -wt -cyl -gear -(Intercept) - - - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg deleted file mode 100644 index d394670ba..000000000 --- a/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - -Odds Ratio -Parameter - - - - - - -0e+00 -1e+17 -2e+17 -3e+17 -4e+17 - - - - -hp -wt -(Intercept) - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/weightit.md b/tests/testthat/_snaps/weightit.md deleted file mode 100644 index b5964c1f6..000000000 --- a/tests/testthat/_snaps/weightit.md +++ /dev/null @@ -1,51 +0,0 @@ -# weightit, multinom - - Code - print(model_parameters(fit4, exponentiate = TRUE), zap_small = TRUE) - Output - # Response level: 2 - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------- - (Intercept) | 1.00 | 0.62 | [0.30, 3.39] | 0.00 | 0.998 - treat | 1.08 | 0.25 | [0.68, 1.71] | 0.31 | 0.755 - age | 0.97 | 0.01 | [0.95, 0.99] | -2.38 | 0.018 - educ | 0.98 | 0.05 | [0.89, 1.08] | -0.33 | 0.738 - - # Response level: 3 - - Parameter | Odds Ratio | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | 0.05 | 0.04 | [0.01, 0.20] | -4.23 | < .001 - treat | 1.18 | 0.29 | [0.73, 1.91] | 0.67 | 0.502 - age | 1.00 | 0.01 | [0.98, 1.02] | -0.01 | 0.989 - educ | 1.20 | 0.06 | [1.08, 1.33] | 3.51 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# weightit, ordinal - - Code - print(model_parameters(fit5, exponentiate = TRUE), zap_small = TRUE) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - ------------------------------------------------------------ - treat | 1.12 | 0.21 | [0.78, 1.61] | 0.60 | 0.549 - age | 0.99 | 0.01 | [0.97, 1.01] | -0.78 | 0.436 - educ | 1.11 | 0.04 | [1.03, 1.20] | 2.70 | 0.007 - - # Intercept - - Parameter | Odds Ratio | SE | 95% CI | z | p - ------------------------------------------------------------- - 1|2 | 3.28 | 1.70 | [1.19, 9.04] | 2.30 | 0.022 - 2|3 | 9.84 | 5.03 | [3.61, 26.82] | 4.47 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/wrs2.md b/tests/testthat/_snaps/wrs2.md deleted file mode 100644 index c57bd2a96..000000000 --- a/tests/testthat/_snaps/wrs2.md +++ /dev/null @@ -1,11 +0,0 @@ -# model_parameters.mcp and robtab - - Code - print(df_b, table_width = Inf) - Output - Group1 | Group2 | Psihat | 95% CI | p - ------------------------------------------------- - placebo | low | -1 | [-5.32, 3.32] | 0.435 - placebo | high | -3 | [-7.32, 1.32] | 0.181 - low | high | -2 | [-6.32, 2.32] | 0.317 - From 17534e759e0d9c81a9d9902a792e82b65b0aa98c Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 15 Oct 2026 11:03:43 +0200 Subject: [PATCH 13/33] update snaps --- .../equivalence_test/equivalence-test-1.svg | 70 +++++ .../equivalence_test/equivalence-test-2.svg | 73 +++++ .../equivalence_test/equivalence-test-3.svg | 93 ++++++ .../equivalence_test/equivalence-test-4.svg | 93 ++++++ .../equivalence_test/equivalence-test-5.svg | 93 ++++++ tests/testthat/_snaps/glmmTMB.new.md | 279 ------------------ tests/testthat/_snaps/include_reference.md | 245 +++++++++++++++ tests/testthat/_snaps/ivreg.md | 20 ++ tests/testthat/_snaps/lcmm.md | 257 ++++++++++++++++ tests/testthat/_snaps/mipo.md | 42 +++ .../testthat/_snaps/model_parameters.anova.md | 30 ++ .../_snaps/model_parameters.fixest.md | 25 ++ .../_snaps/model_parameters.fixest_multi.md | 160 ++++++++++ .../_snaps/model_parameters.mclogit.md | 80 +++++ tests/testthat/_snaps/plm.md | 34 +++ tests/testthat/_snaps/print_AER_labels.md | 19 ++ tests/testthat/_snaps/printing-stan.md | 14 +- tests/testthat/_snaps/printing-stan.new.md | 256 ---------------- tests/testthat/_snaps/sampleSelection.md | 71 +++++ tests/testthat/_snaps/serp.md | 24 ++ tests/testthat/_snaps/svylme.md | 26 ++ .../_snaps/tinyplot/tinyplot-forest-1.svg | 63 ++++ .../_snaps/tinyplot/tinyplot-forest-2.svg | 63 ++++ .../tinyplot-forest-exponentiated.svg | 57 ++++ tests/testthat/_snaps/weightit.md | 51 ++++ tests/testthat/_snaps/wrs2.md | 11 + 26 files changed, 1707 insertions(+), 542 deletions(-) create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg delete mode 100644 tests/testthat/_snaps/glmmTMB.new.md create mode 100644 tests/testthat/_snaps/include_reference.md create mode 100644 tests/testthat/_snaps/ivreg.md create mode 100644 tests/testthat/_snaps/lcmm.md create mode 100644 tests/testthat/_snaps/mipo.md create mode 100644 tests/testthat/_snaps/model_parameters.fixest_multi.md create mode 100644 tests/testthat/_snaps/model_parameters.mclogit.md create mode 100644 tests/testthat/_snaps/plm.md create mode 100644 tests/testthat/_snaps/print_AER_labels.md delete mode 100644 tests/testthat/_snaps/printing-stan.new.md create mode 100644 tests/testthat/_snaps/sampleSelection.md create mode 100644 tests/testthat/_snaps/serp.md create mode 100644 tests/testthat/_snaps/svylme.md create mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg create mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg create mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg create mode 100644 tests/testthat/_snaps/weightit.md create mode 100644 tests/testthat/_snaps/wrs2.md diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg new file mode 100644 index 000000000..533976c27 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Speciesvirginica +Speciesversicolor + + + + + + +0.0 +0.5 +1.0 +1.5 + +Equivalence + + + +Rejected +Equivalence-Test 1 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg new file mode 100644 index 000000000..a987aae10 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Speciesvirginica +Speciesversicolor + + + + + + + +-100 +-75 +-50 +-25 +0 + +Equivalence + + + +Rejected +Equivalence-Test 2 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg new file mode 100644 index 000000000..f6d783bb3 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +cyl8 +cyl6 +gear5 +gear4 +hp + + + + + + + + + +-5 +0 +5 +10 + +Equivalence + + + + + + + + + +Accepted +Rejected +Undecided +Equivalence-Test 3 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg new file mode 100644 index 000000000..6f6c286e7 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +cyl8 +cyl6 +gear5 +gear4 +hp + + + + + + + + + +-5 +0 +5 +10 + +Equivalence + + + + + + + + + +Accepted +Rejected +Undecided +Equivalence-Test 4 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg new file mode 100644 index 000000000..5a9d29a42 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +cyl8 +cyl6 +gear5 +gear4 +hp + + + + + + + + + +-5 +0 +5 +10 + +Equivalence + + + + + + + + + +Accepted +Rejected +Undecided +Equivalence-Test 5 + + diff --git a/tests/testthat/_snaps/glmmTMB.new.md b/tests/testthat/_snaps/glmmTMB.new.md deleted file mode 100644 index 32cb6690f..000000000 --- a/tests/testthat/_snaps/glmmTMB.new.md +++ /dev/null @@ -1,279 +0,0 @@ -# print-model_parameters glmmTMB - - Code - out[-5] - Output - [1] "# Fixed Effects" - [2] "" - [3] "Parameter | Log-Mean | SE | 95% CI | z | p" - [4] "----------------------------------------------------------------" - [5] "child | -1.04 | 0.09 | [-1.22, -0.87] | -11.60 | < .001" - [6] "camper [1] | 0.27 | 0.09 | [ 0.09, 0.44] | 2.98 | 0.003 " - -# print-model_parameters glmmTMB digits - - Code - out[-c(5, 14)] - Output - [1] "# Fixed Effects (Count Model)" - [2] "" - [3] "Parameter | Log-Mean | SE | 95% CI | z | p" - [4] "--------------------------------------------------------------------------" - [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" - [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " - [7] "" - [8] "# Fixed Effects (Zero-Inflation Component)" - [9] "" - [10] "Parameter | Log-Odds | SE | 95% CI | z | p" - [11] "--------------------------------------------------------------------------" - [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" - [13] "camper [1] | -4.8291 | | | | " - [14] "" - [15] "# Random Effects Variances" - [16] "" - [17] "Parameter | Coefficient | 95% CI" - [18] "----------------------------------------------------------------" - [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" - [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" - [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" - [22] "" - [23] "# Random Effects (Zero-Inflation Component)" - [24] "" - [25] "Parameter | Coefficient | 95% CI" - [26] "----------------------------------------------------------------" - [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" - [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" - [29] "Cor (Intercept~zg: persons) | 0.9790 | " - ---- - - Code - out[-c(5, 14)] - Output - [1] "# Fixed Effects (Count Model)" - [2] "" - [3] "Parameter | Log-Mean | SE | 95% CI | z | p" - [4] "--------------------------------------------------------------------------" - [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" - [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " - [7] "" - [8] "# Fixed Effects (Zero-Inflation Component)" - [9] "" - [10] "Parameter | Log-Odds | SE | 95% CI | z | p" - [11] "--------------------------------------------------------------------------" - [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" - [13] "camper [1] | -4.8291 | | | | " - [14] "" - [15] "# Random Effects Variances" - [16] "" - [17] "Parameter | Coefficient | 95% CI" - [18] "----------------------------------------------------------------" - [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" - [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" - [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" - [22] "" - [23] "# Random Effects (Zero-Inflation Component)" - [24] "" - [25] "Parameter | Coefficient | 95% CI" - [26] "----------------------------------------------------------------" - [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" - [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" - [29] "Cor (Intercept~zg: persons) | 0.9790 | " - -# print-model_parameters glmmTMB CI alignment - - Code - print(mp) - Output - # Random Effects: conditional - - Parameter | Coefficient | 95% CI - ---------------------------------------------------------------- - SD (Intercept: Session:Participant) | 0.27 | [0.08, 0.87] - SD (Intercept: Participant) | 0.38 | [0.16, 0.92] - - # Random Effects: zero_inflated - - Parameter | Coefficient | 95% CI - ---------------------------------------------------------------- - SD (Intercept: Session:Participant) | 0.69 | [0.40, 1.19] - SD (Intercept: Participant) | 2.39 | [1.25, 4.57] - Message - - Uncertainty intervals for random effect variances computed using a - Wald z-distribution approximation. - ---- - - Code - print(mp) - Output - # Fixed Effects - - Parameter | Log-Mean | SE | 95% CI | z | p - --------------------------------------------------------------------- - (Intercept) | 2.12 | 0.30 | [ 1.53, 2.71] | 7.05 | < .001 - Surface [Lingual] | 0.01 | 0.29 | [-0.56, 0.58] | 0.04 | 0.971 - Surface [Occlusal] | 0.54 | 0.22 | [ 0.10, 0.98] | 2.43 | 0.015 - Side [Anterior] | 0.04 | 0.32 | [-0.58, 0.66] | 0.14 | 0.889 - Side [Left] | -0.04 | 0.20 | [-0.44, 0.37] | -0.17 | 0.862 - Jaw [Maxillar] | -0.10 | 0.21 | [-0.51, 0.30] | -0.51 | 0.612 - - # Zero-Inflation - - Parameter | Log-Odds | SE | 95% CI | z | p - ---------------------------------------------------------------------- - (Intercept) | 4.87 | 0.93 | [ 3.04, 6.69] | 5.23 | < .001 - Surface [Lingual] | 0.93 | 0.34 | [ 0.27, 1.60] | 2.75 | 0.006 - Surface [Occlusal] | -1.01 | 0.29 | [-1.59, -0.44] | -3.45 | < .001 - Side [Anterior] | -0.20 | 0.37 | [-0.93, 0.52] | -0.55 | 0.583 - Side [Left] | -0.38 | 0.27 | [-0.91, 0.14] | -1.44 | 0.151 - Jaw [Maxillar] | 0.59 | 0.24 | [ 0.11, 1.07] | 2.42 | 0.016 - - # Dispersion - - Parameter | Coefficient | 95% CI - ---------------------------------------- - (Intercept) | 2.06 | [1.30, 3.27] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# print-model_parameters - - Code - mp - Output - # Fixed Effects - - Parameter | Log-Mean | SE | 95% CI | z | p - ---------------------------------------------------------------- - (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 - child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 - camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 - - # Zero-Inflation - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 - child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 - camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 - ---- - - Code - mp - Output - # Fixed Effects - - Parameter | IRR | SE | 95% CI | z | p - ---------------------------------------------------------- - (Intercept) | 3.54 | 1.68 | [1.39, 8.98] | 2.66 | 0.008 - child | 0.32 | 0.03 | [0.27, 0.38] | -12.27 | < .001 - camper [1] | 2.08 | 0.19 | [1.73, 2.50] | 7.85 | < .001 - - # Zero-Inflation - - Parameter | Odds Ratio | SE | 95% CI | z | p - ---------------------------------------------------------------- - (Intercept) | 0.68 | 0.44 | [0.19, 2.43] | -0.60 | 0.551 - child | 7.80 | 2.42 | [4.25, 14.32] | 6.63 | < .001 - camper [1] | 0.36 | 0.12 | [0.19, 0.69] | -3.12 | 0.002 - ---- - - Code - mp - Output - # Fixed Effects (Count Model) - - Parameter | Log-Mean | SE | 95% CI | z | p - ---------------------------------------------------------------- - (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 - child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 - camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 - - # Fixed Effects (Zero-Inflation Component) - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 - child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 - camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 - - # Random Effects Variances - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 0.93 | [0.46, 1.89] - - # Random Effects (Zero-Inflation Component) - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 1.17 | [0.54, 2.57] - -# robust SE/VCOV - - Code - print(out, table_width = Inf) - Output - # Fixed Effects (Count Model) - - Parameter | Log-Mean | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | 1.26 | 0.46 | [ 0.36, 2.17] | 2.74 | 0.006 - child | -1.14 | 0.30 | [-1.73, -0.55] | -3.80 | < .001 - camper [1] | 0.73 | 0.41 | [-0.06, 1.53] | 1.80 | 0.072 - - # Fixed Effects (Zero-Inflation Component) - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -0.39 | 0.58 | [-1.52, 0.75] | -0.67 | 0.501 - child | 2.05 | 0.39 | [ 1.30, 2.81] | 5.33 | < .001 - camper [1] | -1.01 | 0.39 | [-1.77, -0.24] | -2.59 | 0.010 - - # Random Effects Variances - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 0.93 | [0.46, 1.89] - - # Random Effects (Zero-Inflation Component) - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 1.17 | [0.54, 2.57] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(out, table_width = Inf) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | p - -------------------------------------------------------------------- - (Intercept) | 251.40 | 6.28 | [239.09, 263.72] | 40.02 | < .001 - Days | 10.47 | 1.45 | [ 7.63, 13.31] | 7.23 | < .001 - - # Random Effects - - Parameter | Coefficient | 95% CI - ------------------------------------------------------------ - SD (Intercept: Subject) | 23.78 | [15.02, 37.66] - SD (Days: Subject) | 5.72 | [ 3.81, 8.59] - Cor (Intercept~Days: Subject) | 0.08 | [-0.49, 0.59] - SD (Residual) | 25.59 | [22.80, 28.72] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/include_reference.md b/tests/testthat/_snaps/include_reference.md new file mode 100644 index 000000000..aa2d2b4b9 --- /dev/null +++ b/tests/testthat/_snaps/include_reference.md @@ -0,0 +1,245 @@ +# include_reference, on-the-fly factors + + Code + print(out1) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 + gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 + am [0] | 0.00 | | | | + am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 + hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out2) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 + gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 + am [0] | 0.00 | | | | + am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 + hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print_md(out) + Output + + + |Parameter | m1 | m2 | + |:------------|:--------------------|:--------------------| + |(Intercept) |27.48 (23.43, 31.53) |27.48 (23.43, 31.53) | + |gear (3) | 0.00 | 0.00 | + |gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | + |gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | + |am (0) | 0.00 | 0.00 | + |am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | + |hp |-0.06 (-0.09, -0.04) |-0.06 (-0.09, -0.04) | + | | | | + |Observations | 32 | 32 | + +--- + + Code + display(out, format = "tt") + Output + + +--------------+----------------------+----------------------+ + | Parameter | m1 | m2 | + +==============+======================+======================+ + | (Intercept) | 27.48 (23.43, 31.53) | 27.48 (23.43, 31.53) | + +--------------+----------------------+----------------------+ + | gear (3) | 0.00 | 0.00 | + +--------------+----------------------+----------------------+ + | gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | + +--------------+----------------------+----------------------+ + | gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | + +--------------+----------------------+----------------------+ + | am (0) | 0.00 | 0.00 | + +--------------+----------------------+----------------------+ + | am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | + +--------------+----------------------+----------------------+ + | hp | -0.06 (-0.09, -0.04) | -0.06 (-0.09, -0.04) | + +--------------+----------------------+----------------------+ + | | | | + +--------------+----------------------+----------------------+ + | Observations | 32 | 32 | + +--------------+----------------------+----------------------+ + +# include_reference, different contrasts + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------- + (Intercept) | 19.70 | 1.18 | [ 17.28, 22.11] | 16.71 | < .001 + cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 + cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 + gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------- + (Intercept) | 25.43 | 1.88 | [ 21.57, 29.29] | 13.52 | < .001 + cyl [4] | 0.00 | | | | + cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 + cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 + gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------- + (Intercept) | 20.64 | 0.67 | [ 19.26, 22.01] | 30.76 | < .001 + cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 + cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 + gear [1] | -0.94 | 1.09 | [ -3.18, 1.30] | -0.86 | 0.396 + gear [2] | 0.38 | 1.11 | [ -1.90, 2.67] | 0.34 | 0.734 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 15.83 | 1.24 | [13.28, 18.37] | 12.75 | < .001 + cyl [8] | 0.00 | | | | + cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 + cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 + gear [1] | -0.94 | 1.09 | [-3.18, 1.30] | -0.86 | 0.396 + gear [2] | 0.38 | 1.11 | [-1.90, 2.67] | 0.34 | 0.734 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 14.89 | 0.92 | [13.00, 16.77] | 16.19 | < .001 + cyl [8] | 0.00 | | | | + cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 + cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 + gear [3] | 0.00 | | | | + gear [4] | 1.32 | 1.93 | [-2.63, 5.28] | 0.69 | 0.498 + gear [5] | 1.50 | 1.85 | [-2.31, 5.31] | 0.81 | 0.426 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +# include_reference, random effects models + + Code + print(out) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------------------- + (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 + flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 + island [Biscoe] | 1.00 | | | | + island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 + island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 + + # Random Effects + + Parameter | Coefficient | 95% CI + ------------------------------------------------ + SD (Intercept: year) | 3.05e-05 | [0.00, Inf] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(out, include_reference = TRUE) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------------------- + (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 + flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 + island [Biscoe] | 1.00 | | | | + island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 + island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 + + # Random Effects + + Parameter | Coefficient | 95% CI + ------------------------------------------------ + SD (Intercept: year) | 3.05e-05 | [0.00, Inf] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(out) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------------------- + (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 + flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 + island [Biscoe] | 1.00 | | | | + island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 + island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/ivreg.md b/tests/testthat/_snaps/ivreg.md new file mode 100644 index 000000000..9d4941d5e --- /dev/null +++ b/tests/testthat/_snaps/ivreg.md @@ -0,0 +1,20 @@ +# print-model_parameters + + Code + tmp + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | t(45) | p + -------------------------------------------------------------------- + (Intercept) | 9.89 | 1.06 | [ 7.76, 12.03] | 9.35 | < .001 + rprice [log] | -1.28 | 0.26 | [-1.81, -0.75] | -4.85 | < .001 + rincome [log] | 0.28 | 0.24 | [-0.20, 0.76] | 1.18 | 0.246 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + + The model has a log-transformed response variable. Consider using + `exponentiate = TRUE` to interpret coefficients as ratios. + diff --git a/tests/testthat/_snaps/lcmm.md b/tests/testthat/_snaps/lcmm.md new file mode 100644 index 000000000..d74cb291d --- /dev/null +++ b/tests/testthat/_snaps/lcmm.md @@ -0,0 +1,257 @@ +# model_parameters lcmm + + Code + print(model_parameters(out$mx_linear), zap_small = TRUE) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------------------- + intercept class1 | 1.12 | 0.90 | [ -0.64, 2.89] | 1.25 | 0.211 + intercept class2 | 1.19 | 0.74 | [ -0.26, 2.65] | 1.61 | 0.107 + X1 class1 | 1.85 | 13.74 | [ -25.08, 28.77] | 0.13 | 0.893 + X1 class2 | 4.12 | 12.32 | [ -20.03, 28.26] | 0.33 | 0.738 + X2 class1 | 10.50 | 2079.25 | [-4064.75, 4085.74] | 0.01 | 0.996 + X2 class2 | 9.64 | 2078.80 | [-4064.73, 4084.02] | 0.00 | 0.996 + X3 class1 | -0.60 | 0.90 | [ -2.36, 1.17] | -0.66 | 0.508 + X3 class2 | 0.12 | 0.55 | [ -0.95, 1.19] | 0.23 | 0.822 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + + The model has a log- or logit-link. Consider using `exponentiate = + TRUE` to interpret coefficients as ratios. + + Some coefficients are very large, which may indicate issues with + complete separation. + +--- + + Code + print(model_parameters(out$mx_beta), zap_small = TRUE) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + ----------------------------------------------------------------------- + intercept class1 | 0.12 | 67.86 | [-132.89, 133.13] | 0.00 | 0.999 + intercept class2 | 1.55 | 35.86 | [ -68.73, 71.83] | 0.04 | 0.966 + X1 class1 | 0.51 | 24.20 | [ -46.92, 47.94] | 0.02 | 0.983 + X1 class2 | -1.02 | 26.22 | [ -52.41, 50.36] | -0.04 | 0.969 + X2 class1 | 15.95 | 14.97 | [ -13.39, 45.28] | 1.07 | 0.287 + X2 class2 | 15.44 | 9.01 | [ -2.22, 33.09] | 1.71 | 0.087 + X3 class1 | 0.44 | 14.56 | [ -28.09, 28.97] | 0.03 | 0.976 + X3 class2 | -0.35 | 18.61 | [ -36.81, 36.12] | -0.02 | 0.985 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$mx_splines), zap_small = TRUE) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------------------- + intercept class1 | -1.46 | 0.83 | [ -3.09, 0.17] | -1.75 | 0.080 + intercept class2 | -1.53 | 0.83 | [ -3.16, 0.11] | -1.83 | 0.067 + X1 class1 | 1.58 | 0.71 | [ 0.18, 2.97] | 2.22 | 0.027 + X1 class2 | 0.86 | 1.83 | [ -2.73, 4.45] | 0.47 | 0.639 + X2 class1 | 0.47 | 0.98 | [ -1.44, 2.38] | 0.48 | 0.631 + X2 class2 | -21.31 | 1194.95 | [-2363.38, 2320.75] | -0.02 | 0.986 + X3 class1 | 0.80 | 0.38 | [ 0.05, 1.54] | 2.10 | 0.036 + X3 class2 | 0.30 | 0.63 | [ -0.95, 1.54] | 0.47 | 0.638 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m1_linear), zap_small = TRUE) + Output + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Time | -0.78 | 0.19 | [-1.15, -0.40] | -4.09 | < .001 + I(Time^2) | -0.18 | 0.08 | [-0.33, -0.04] | -2.44 | 0.015 + + # linear + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------------------- + Linear 1 (intercept) | 25.40 | 0.23 | [24.96, 25.85] | 112.34 | < .001 + Linear 2 (std err) | 2.24 | 0.04 | [ 2.15, 2.33] | 50.37 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m1_beta), zap_small = TRUE) + Output + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Time | -0.88 | 0.19 | [-1.25, -0.51] | -4.62 | < .001 + I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.34 | 0.180 + + # beta + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Beta1 | 0.54 | 0.07 | [ 0.41, 0.68] | 7.97 | < .001 + Beta2 | -0.76 | 0.09 | [-0.94, -0.58] | -8.36 | < .001 + Beta3 | 0.70 | 0.02 | [ 0.67, 0.74] | 42.20 | < .001 + Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 20.53 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m1_splines), zap_small = TRUE) + Output + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Time | -0.89 | 0.19 | [-1.26, -0.52] | -4.68 | < .001 + I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.28 | 0.200 + + # splines + + Parameter | Coefficient | SE | 95% CI | z | p + ------------------------------------------------------------------ + I-splines1 | -7.76 | 0.59 | [-8.92, -6.59] | -13.04 | < .001 + I-splines2 | 0.76 | 0.28 | [ 0.21, 1.31] | 2.71 | 0.007 + I-splines3 | 0.81 | 0.41 | [ 0.00, 1.63] | 1.96 | 0.049 + I-splines4 | 1.44 | 0.13 | [ 1.18, 1.70] | 10.85 | < .001 + I-splines5 | -1.67 | 0.06 | [-1.80, -1.54] | -25.86 | < .001 + I-splines6 | 1.62 | 0.05 | [ 1.52, 1.72] | 32.56 | < .001 + I-splines7 | 1.30 | 0.05 | [ 1.20, 1.40] | 25.33 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m2_linear), zap_small = TRUE) + Output + # membership + + Parameter | Coefficient | SE | 95% CI | z | p + -------------------------------------------------------------------- + intercept class1 | 1.69 | 0.95 | [-0.18, 3.56] | 1.77 | 0.076 + intercept class2 | 2.47 | 0.79 | [ 0.91, 4.02] | 3.11 | 0.002 + + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------------- + intercept class2 | 0.68 | 0.33 | [ 0.03, 1.32] | 2.06 | 0.039 + intercept class3 | -0.63 | 0.68 | [-1.97, 0.70] | -0.93 | 0.353 + Time class1 | -1.12 | 0.56 | [-2.21, -0.03] | -2.01 | 0.045 + Time class2 | -0.37 | 0.25 | [-0.86, 0.13] | -1.44 | 0.151 + Time class3 | -2.90 | 1.48 | [-5.80, 0.00] | -1.96 | 0.050 + I(Time^2) class1 | -0.52 | 0.24 | [-0.98, -0.06] | -2.21 | 0.027 + I(Time^2) class2 | -0.15 | 0.09 | [-0.34, 0.03] | -1.67 | 0.094 + I(Time^2) class3 | 0.79 | 0.70 | [-0.59, 2.18] | 1.13 | 0.260 + + # linear + + Parameter | Coefficient | SE | 95% CI | z | p + --------------------------------------------------------------------------- + Linear 1 (intercept) | 24.46 | 0.60 | [23.28, 25.64] | 40.56 | < .001 + Linear 2 (std err) | 2.23 | 0.04 | [ 2.14, 2.32] | 50.22 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m2_beta), zap_small = TRUE) + Output + # membership + + Parameter | Coefficient | SE | 95% CI | z | p + -------------------------------------------------------------------- + intercept class1 | 0.93 | 1.48 | [-1.97, 3.83] | 0.63 | 0.531 + intercept class2 | 1.36 | 1.10 | [-0.79, 3.51] | 1.24 | 0.214 + + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------- + intercept class2 | -0.54 | 0.44 | [-1.41, 0.33] | -1.22 | 0.221 + intercept class3 | -0.99 | 0.64 | [-2.25, 0.27] | -1.54 | 0.123 + Time class1 | -0.52 | 0.67 | [-1.83, 0.79] | -0.77 | 0.438 + Time class2 | -1.68 | 0.33 | [-2.32, -1.04] | -5.14 | < .001 + Time class3 | 1.61 | 1.09 | [-0.52, 3.74] | 1.48 | 0.138 + I(Time^2) class1 | 0.02 | 0.23 | [-0.43, 0.47] | 0.07 | 0.943 + I(Time^2) class2 | -0.07 | 0.13 | [-0.33, 0.20] | -0.50 | 0.618 + I(Time^2) class3 | -0.69 | 0.39 | [-1.46, 0.09] | -1.74 | 0.082 + + # beta + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Beta1 | 0.60 | 0.06 | [ 0.48, 0.73] | 9.34 | < .001 + Beta2 | -0.83 | 0.09 | [-1.01, -0.66] | -9.39 | < .001 + Beta3 | 0.73 | 0.03 | [ 0.67, 0.80] | 22.27 | < .001 + Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 21.88 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m2_splines), zap_small = TRUE) + Output + # membership + + Parameter | Coefficient | SE | 95% CI | z | p + --------------------------------------------------------------------- + intercept class1 | -0.46 | 0.45 | [-1.33, 0.42] | -1.01 | 0.310 + intercept class2 | -1.40 | 1.06 | [-3.48, 0.68] | -1.32 | 0.186 + + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------- + intercept class2 | -1.03 | 0.67 | [-2.34, 0.27] | -1.55 | 0.121 + intercept class3 | -0.55 | 0.41 | [-1.36, 0.26] | -1.34 | 0.182 + Time class1 | -0.48 | 0.59 | [-1.63, 0.67] | -0.81 | 0.415 + Time class2 | 1.65 | 1.10 | [-0.50, 3.80] | 1.50 | 0.133 + Time class3 | -1.72 | 0.32 | [-2.35, -1.09] | -5.36 | < .001 + I(Time^2) class1 | 0.01 | 0.20 | [-0.38, 0.40] | 0.03 | 0.972 + I(Time^2) class2 | -0.70 | 0.40 | [-1.49, 0.08] | -1.76 | 0.078 + I(Time^2) class3 | -0.04 | 0.13 | [-0.30, 0.22] | -0.33 | 0.743 + + # splines + + Parameter | Coefficient | SE | 95% CI | z | p + ------------------------------------------------------------------ + I-splines1 | -7.87 | 0.62 | [-9.09, -6.66] | -12.67 | < .001 + I-splines2 | 0.72 | 0.27 | [ 0.20, 1.24] | 2.70 | 0.007 + I-splines3 | 0.77 | 0.41 | [-0.03, 1.57] | 1.88 | 0.060 + I-splines4 | 1.37 | 0.13 | [ 1.11, 1.63] | 10.35 | < .001 + I-splines5 | -1.66 | 0.06 | [-1.79, -1.54] | -25.77 | < .001 + I-splines6 | 1.64 | 0.05 | [ 1.54, 1.73] | 33.01 | < .001 + I-splines7 | 1.28 | 0.05 | [ 1.18, 1.39] | 24.94 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/mipo.md b/tests/testthat/_snaps/mipo.md new file mode 100644 index 000000000..ba22deb84 --- /dev/null +++ b/tests/testthat/_snaps/mipo.md @@ -0,0 +1,42 @@ +# param ordinal + + Code + print(mp) + Output + # 6 response + + Parameter | Coefficient | SE | 95% CI | Statistic | df | p + -------------------------------------------------------------------------------- + (Intercept) | -54.29 | 46.90 | [-151.05, 42.46] | -1.16 | 24.19 | 0.258 + disp | 0.22 | 0.39 | [ -0.58, 1.02] | 0.58 | 23.81 | 0.570 + hp | 0.20 | 0.57 | [ -0.97, 1.38] | 0.36 | 23.73 | 0.724 + + # 8 response + + Parameter | Coefficient | SE | 95% CI | Statistic | df | p + -------------------------------------------------------------------------------- + (Intercept) | -92.86 | 67.62 | [-232.47, 46.75] | -1.37 | 23.87 | 0.182 + disp | 0.26 | 0.40 | [ -0.57, 1.09] | 0.64 | 23.53 | 0.528 + hp | 0.43 | 0.63 | [ -0.88, 1.73] | 0.67 | 24.15 | 0.507 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald distribution approximation. + +# param normal + + Code + print(mp) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | Statistic | df | p + ---------------------------------------------------------------------------------- + (Intercept) | 30.65 | 1.43 | [27.72, 33.58] | 21.46 | 26.96 | < .001 + disp | -0.03 | 7.52e-03 | [-0.05, -0.02] | -4.40 | 25.57 | < .001 + hp | -0.02 | 0.01 | [-0.05, 0.01] | -1.37 | 24.82 | 0.182 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald distribution approximation. + diff --git a/tests/testthat/_snaps/model_parameters.anova.md b/tests/testthat/_snaps/model_parameters.anova.md index 5fad54b2d..da9f8cd8f 100644 --- a/tests/testthat/_snaps/model_parameters.anova.md +++ b/tests/testthat/_snaps/model_parameters.anova.md @@ -26,3 +26,33 @@ Anova Table (Type 3 tests) +# anova survey + + Code + print(model_parameters(out)) + Output + # Fixed Effects + + Parameter | DEff | Chi2(1) | df (error) | p + ----------------------------------------------- + ell | 0.77 | 1.13 | 38 | 0.236 + meals | 1.24 | 4.82 | 37 | 0.058 + ell:meals | 1.48 | 16.52 | 36 | 0.002 + + Anova Table (Type 1 tests) + +--- + + Code + print(model_parameters(out)) + Output + # Fixed Effects + + Parameter | df | df (error) | F | p + ------------------------------------------ + ell | 1 | 38 | 1.47 | 0.234 + meals | 1 | 37 | 3.54 | 0.068 + ell:meals | 1 | 36 | 9.10 | 0.005 + + Anova Table (Type 1 tests) + diff --git a/tests/testthat/_snaps/model_parameters.fixest.md b/tests/testthat/_snaps/model_parameters.fixest.md index 59cc0556c..e7c7c527b 100644 --- a/tests/testthat/_snaps/model_parameters.fixest.md +++ b/tests/testthat/_snaps/model_parameters.fixest.md @@ -15,3 +15,28 @@ RMSE : 10.069 r2: 0.743; ar2: 0.613; wr2: 0.180; war2: 0.175 +# model_parameters works for fixest-negbin + + Code + print(out) + Output + # Fixed Effects + + Parameter | Log-Mean | SE | 95% CI | t(636) | p + ---------------------------------------------------------------- + (Intercept) | -1.46 | 0.21 | [-1.86, -1.06] | -7.11 | < .001 + mined [no] | 2.04 | 0.15 | [ 1.75, 2.33] | 13.72 | < .001 + spp [PR] | -1.23 | 0.29 | [-1.80, -0.65] | -4.20 | < .001 + spp [DM] | 0.40 | 0.23 | [-0.05, 0.86] | 1.75 | 0.080 + spp [EC-A] | -0.67 | 0.26 | [-1.18, -0.16] | -2.60 | 0.010 + spp [EC-L] | 0.64 | 0.22 | [ 0.20, 1.07] | 2.89 | 0.004 + spp [DES-L] | 0.82 | 0.22 | [ 0.38, 1.26] | 3.69 | < .001 + spp [DF] | 0.36 | 0.24 | [-0.10, 0.82] | 1.52 | 0.128 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + + The model has a log- or logit-link. Consider using `exponentiate = + TRUE` to interpret coefficients as ratios. + diff --git a/tests/testthat/_snaps/model_parameters.fixest_multi.md b/tests/testthat/_snaps/model_parameters.fixest_multi.md new file mode 100644 index 000000000..82362a7f2 --- /dev/null +++ b/tests/testthat/_snaps/model_parameters.fixest_multi.md @@ -0,0 +1,160 @@ +# model_parameters.fixest_multi + + Code + print(model_parameters(mod)) + Output + # Petal.Width ~ x + + Parameter | Coefficient | SE | 95% CI | t(146) | p + --------------------------------------------------------------- + x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 + + # Sepal.Width ~ x + + Parameter | Coefficient | SE | 95% CI | t(146) | p + --------------------------------------------------------------- + x | 0.05 | 0.03 | [-0.01, 0.10] | 1.56 | 0.120 + + # Petal.Width ~ x + Petal.Length + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 + Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 + + # Sepal.Width ~ x + Petal.Length + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 + Petal.Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 + + # Petal.Width ~ x + Petal.Length + Sepal.Length + + Parameter | Coefficient | SE | 95% CI | t(144) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 + Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 + Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 + + # Sepal.Width ~ x + Petal.Length + Sepal.Length + + Parameter | Coefficient | SE | 95% CI | t(144) | p + ------------------------------------------------------------------- + x | 0.03 | 0.03 | [-0.02, 0.09] | 1.37 | 0.171 + Petal.Length | -0.04 | 0.08 | [-0.21, 0.13] | -0.45 | 0.651 + Sepal.Length | 0.37 | 0.07 | [ 0.23, 0.51] | 5.23 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(ci(mod)) + Output + Parameter CI CI_low CI_high Response + 1 x 0.95 -0.01929491 0.05165987 Petal.Width + 2 x 0.95 -0.01715341 0.04515343 Petal.Width + 3 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width + 4 x 0.95 -0.01722960 0.04542622 Petal.Width + 5 Petal.Length 0.95 0.12908917 0.33808245 Petal.Width + 6 Sepal.Length 0.95 -0.09172321 0.08324053 Petal.Width + 7 x 0.95 -0.01227870 0.10484812 Sepal.Width + 8 x 0.95 -0.01093910 0.09787861 Sepal.Width + 9 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width + 10 x 0.95 -0.01527889 0.08504860 Sepal.Width + 11 Petal.Length 0.95 -0.20565718 0.12899281 Sepal.Width + 12 Sepal.Length 0.95 0.23032902 0.51048930 Sepal.Width + Group + 1 x + 2 x + Petal.Length + 3 x + Petal.Length + 4 x + Petal.Length + Sepal.Length + 5 x + Petal.Length + Sepal.Length + 6 x + Petal.Length + Sepal.Length + 7 x + 8 x + Petal.Length + 9 x + Petal.Length + 10 x + Petal.Length + Sepal.Length + 11 x + Petal.Length + Sepal.Length + 12 x + Petal.Length + Sepal.Length + +--- + + Code + print(model_parameters(mod)) + Output + # Petal.Width response + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 + Petal Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 + + # Sepal.Width response + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 + Petal Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(ci(mod)) + Output + Parameter CI CI_low CI_high Response + 1 x 0.95 -0.01715341 0.04515343 Petal.Width + 2 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width + 3 x 0.95 -0.01093910 0.09787861 Sepal.Width + 4 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width + +--- + + Code + print(model_parameters(mod)) + Output + # x + + Parameter | Coefficient | SE | 95% CI | t(146) | p + --------------------------------------------------------------- + x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 + + # x + Petal.Length + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 + Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 + + # x + Petal.Length + Sepal.Length + + Parameter | Coefficient | SE | 95% CI | t(144) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 + Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 + Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(ci(mod)) + Output + Parameter CI CI_low CI_high Group + 1 x 0.95 -0.01929491 0.05165987 x + 2 x 0.95 -0.01715341 0.04515343 x + Petal.Length + 3 Petal.Length 0.95 0.16163902 0.29786840 x + Petal.Length + 4 x 0.95 -0.01722960 0.04542622 x + Petal.Length + Sepal.Length + 5 Petal.Length 0.95 0.12908917 0.33808245 x + Petal.Length + Sepal.Length + 6 Sepal.Length 0.95 -0.09172321 0.08324053 x + Petal.Length + Sepal.Length + diff --git a/tests/testthat/_snaps/model_parameters.mclogit.md b/tests/testthat/_snaps/model_parameters.mclogit.md new file mode 100644 index 000000000..5db8ac5a9 --- /dev/null +++ b/tests/testthat/_snaps/model_parameters.mclogit.md @@ -0,0 +1,80 @@ +# model_parameters.mclogit + + Code + params + Output + Parameter | Log-Odds | SE | 95% CI | z | p + -------------------------------------------------------------- + distance | -1.44 | 0.05 | [-1.54, -1.34] | -27.07 | < .001 + cost | -0.98 | 0.04 | [-1.06, -0.90] | -24.52 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# model_parameters.mblogit + + Code + params + Output + # Response level: medium + + Parameter | Log-Odds | SE | 95% CI | z | p + ----------------------------------------------------------------- + (Intercept) | -0.42 | 0.17 | [-0.76, -0.08] | -2.42 | 0.015 + InflMedium | 0.45 | 0.14 | [ 0.17, 0.72] | 3.15 | 0.002 + InflHigh | 0.66 | 0.19 | [ 0.30, 1.03] | 3.57 | < .001 + TypeApartment | -0.44 | 0.17 | [-0.77, -0.10] | -2.53 | 0.012 + TypeAtrium | 0.13 | 0.22 | [-0.31, 0.57] | 0.59 | 0.556 + TypeTerrace | -0.67 | 0.21 | [-1.07, -0.26] | -3.23 | 0.001 + ContHigh | 0.36 | 0.13 | [ 0.10, 0.62] | 2.73 | 0.006 + + # Response level: high + + Parameter | Log-Odds | SE | 95% CI | z | p + ----------------------------------------------------------------- + (Intercept) | -0.14 | 0.16 | [-0.45, 0.17] | -0.87 | 0.384 + InflMedium | 0.73 | 0.14 | [ 0.47, 1.00] | 5.37 | < .001 + InflHigh | 1.61 | 0.17 | [ 1.29, 1.94] | 9.65 | < .001 + TypeApartment | -0.74 | 0.16 | [-1.04, -0.43] | -4.74 | < .001 + TypeAtrium | -0.41 | 0.21 | [-0.82, 0.01] | -1.93 | 0.054 + TypeTerrace | -1.41 | 0.20 | [-1.80, -1.02] | -7.06 | < .001 + ContHigh | 0.48 | 0.12 | [ 0.24, 0.73] | 3.88 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# simulate_parameters.mblogit + + Code + params + Output + # Medium response + + Parameter | Coefficient | 95% CI | p + ----------------------------------------------------- + (Intercept) | -0.41 | [-0.75, -0.10] | 0.016 + InflMedium | 0.44 | [ 0.18, 0.71] | < .001 + InflHigh | 0.66 | [ 0.34, 1.03] | < .001 + TypeApartment | -0.44 | [-0.79, -0.10] | 0.008 + TypeAtrium | 0.12 | [-0.28, 0.58] | 0.582 + TypeTerrace | -0.66 | [-1.09, -0.28] | 0.004 + ContHigh | 0.36 | [ 0.11, 0.61] | < .001 + + # High response + + Parameter | Coefficient | 95% CI | p + ----------------------------------------------------- + (Intercept) | -0.13 | [-0.43, 0.16] | 0.378 + InflMedium | 0.73 | [ 0.45, 0.98] | < .001 + InflHigh | 1.61 | [ 1.29, 1.94] | < .001 + TypeApartment | -0.73 | [-1.05, -0.44] | < .001 + TypeAtrium | -0.41 | [-0.82, 0.01] | 0.054 + TypeTerrace | -1.42 | [-1.81, -1.03] | < .001 + ContHigh | 0.47 | [ 0.22, 0.73] | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a MCMC distribution approximation. + diff --git a/tests/testthat/_snaps/plm.md b/tests/testthat/_snaps/plm.md new file mode 100644 index 000000000..8490ec38b --- /dev/null +++ b/tests/testthat/_snaps/plm.md @@ -0,0 +1,34 @@ +# vcov standard errors + + Code + print(model_parameters(ran)) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | df | p + ----------------------------------------------------------------------------- + (Intercept) | 817.10 | 188.26 | [445.84, 1188.36] | 4.34 | 197 | < .001 + capital | -0.58 | 0.15 | [ -0.88, -0.29] | -3.95 | 197 | < .001 + inv | 2.92 | 0.30 | [ 2.33, 3.51] | 9.80 | 197 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(ran, vcov = "HC1")) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | df | p + ---------------------------------------------------------------------------- + (Intercept) | 817.10 | 274.75 | [275.28, 1358.92] | 2.97 | 197 | 0.003 + capital | -0.58 | 0.43 | [ -1.43, 0.26] | -1.37 | 197 | 0.173 + inv | 2.92 | 0.89 | [ 1.16, 4.67] | 3.28 | 197 | 0.001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/print_AER_labels.md b/tests/testthat/_snaps/print_AER_labels.md new file mode 100644 index 000000000..92b571b63 --- /dev/null +++ b/tests/testthat/_snaps/print_AER_labels.md @@ -0,0 +1,19 @@ +# templates + + Code + print(mp, pretty_names = "labels") + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------------------------------- + (Intercept) | 8.72 | 3.45 | [ 1.95, 15.48] | 2.52 | 0.012 + elder's dependency [slightly dependent] | -1.00 | 3.61 | [-8.08, 6.08] | -0.28 | 0.782 + elder's dependency [moderately dependent] | 2.68 | 3.06 | [-3.32, 8.68] | 0.88 | 0.381 + elder's dependency [severely dependent] | 3.88 | 3.00 | [-2.01, 9.77] | 1.29 | 0.197 + carer's level of education | 1.14 | 0.90 | [-0.62, 2.90] | 1.27 | 0.204 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/printing-stan.md b/tests/testthat/_snaps/printing-stan.md index 403d1f806..db01c7075 100644 --- a/tests/testthat/_snaps/printing-stan.md +++ b/tests/testthat/_snaps/printing-stan.md @@ -11,7 +11,7 @@ wt | -3.21 | [-4.79, -1.65] | 99.95% | 1.002 | 2003 cyl | -1.50 | [-2.36, -0.64] | 99.95% | 1.002 | 2227 - # Sigma + # sigma Parameters Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) ----------------------------------------------------------- @@ -33,7 +33,7 @@ (Intercept) | 33.55 | [24.17, 40.87] | 100% | 1.090 | 157 wt | -4.49 | [-6.95, -1.68] | 100% | 1.168 | 81 - # Sigma + # sigma Parameters Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) ----------------------------------------------------------- @@ -64,7 +64,7 @@ (Intercept) | 251.32 | [237.00, 265.98] | 100% | 1.001 | 2415 Days | 10.44 | [ 6.84, 13.91] | 100% | 1.004 | 1641 - # Sigma + # sigma Parameters Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) -------------------------------------------------------------- @@ -94,7 +94,7 @@ (Intercept) | 250.84 | [228.76, 272.54] | 100% | 1.002 | 1607 Days | 10.37 | [ 8.77, 11.96] | 100% | 0.999 | 2848 - # Sigma + # sigma Parameters Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) -------------------------------------------------------------- @@ -124,7 +124,7 @@ (Intercept) | 2.57 | [0.70, 4.84] | 99.42% | 1.009 | 197 Petal.Width | 1.05 | [0.73, 1.37] | 100% | 1.004 | 2213 - # Sigma + # sigma Parameters Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) ----------------------------------------------------------- @@ -152,7 +152,7 @@ (Intercept) | 33.06 | [24.70, 40.47] | 100% | 1.021 | 666 wt | -4.39 | [-6.94, -1.76] | 99.72% | 1.024 | 102 - # Sigma + # sigma Parameters Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) ----------------------------------------------------------- @@ -185,7 +185,7 @@ child | -1.17 | [-1.37, -0.99] | 100% | 1.002 | 2560 camper | 0.74 | [ 0.56, 0.94] | 100% | 1.000 | 2879 - # Zero-Inflation + # Zero-Inflation Parameters Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) ----------------------------------------------------------------- diff --git a/tests/testthat/_snaps/printing-stan.new.md b/tests/testthat/_snaps/printing-stan.new.md deleted file mode 100644 index db01c7075..000000000 --- a/tests/testthat/_snaps/printing-stan.new.md +++ /dev/null @@ -1,256 +0,0 @@ -# print brms - - Code - mp1 - Output - # Fixed Effects - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------ - (Intercept) | 39.68 | [36.12, 43.27] | 100% | 1.000 | 3255 - wt | -3.21 | [-4.79, -1.65] | 99.95% | 1.002 | 2003 - cyl | -1.50 | [-2.36, -0.64] | 99.95% | 1.002 | 2227 - - # sigma Parameters - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ----------------------------------------------------------- - sigma | 2.67 | [2.06, 3.51] | 100% | 1.001 | 2415 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - ---- - - Code - mp2 - Output - # Fixed Effects - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ---------------------------------------------------------------- - (Intercept) | 33.55 | [24.17, 40.87] | 100% | 1.090 | 157 - wt | -4.49 | [-6.95, -1.68] | 100% | 1.168 | 81 - - # sigma Parameters - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ----------------------------------------------------------- - sigma | 2.56 | [1.95, 3.48] | 100% | 1.294 | 541 - - # Random Effects Variances - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------------------- - SD (Intercept: cyl) | 3.00 | [ 0.39, 9.19] | 100% | 1.109 | 575 - SD (Intercept: gear) | 3.88 | [ 0.21, 10.30] | 100% | 1.285 | 916 - SD (wt: gear) | 1.96 | [ 0.06, 5.06] | 100% | 1.219 | 186 - Cor (Intercept~wt: gear) | -0.25 | [-0.99, 0.83] | 62.48% | 1.077 | 85 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - ---- - - Code - mp3 - Output - # Fixed Effects - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------- - (Intercept) | 251.32 | [237.00, 265.98] | 100% | 1.001 | 2415 - Days | 10.44 | [ 6.84, 13.91] | 100% | 1.004 | 1641 - - # sigma Parameters - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - -------------------------------------------------------------- - sigma | 25.94 | [23.05, 29.38] | 100% | 1.002 | 2781 - - # Random Effects Variances - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------------------------ - SD (Intercept: Subject) | 26.63 | [15.46, 42.36] | 100% | 1.002 | 2683 - SD (Days: Subject) | 6.58 | [ 4.12, 10.16] | 100% | 1.001 | 1961 - Cor (Intercept~Days: Subject) | 0.09 | [-0.47, 0.67] | 60.42% | 1.003 | 1625 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - ---- - - Code - mp4 - Output - # Fixed Effects - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------- - (Intercept) | 250.84 | [228.76, 272.54] | 100% | 1.002 | 1607 - Days | 10.37 | [ 8.77, 11.96] | 100% | 0.999 | 2848 - - # sigma Parameters - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - -------------------------------------------------------------- - sigma | 30.03 | [26.27, 34.03] | 100% | 1.000 | 2289 - - # Random Effects Variances - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------------------- - SD (Intercept: grp) | 8.22 | [ 0.44, 25.69] | 100% | 1.001 | 1788 - SD (Intercept: grp:subgrp) | 7.41 | [ 0.44, 16.87] | 100% | 1.003 | 1480 - SD (Intercept: Subject) | 38.51 | [26.89, 55.98] | 100% | 1.002 | 1893 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - ---- - - Code - mp5 - Output - # Fixed Effects - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - --------------------------------------------------------------- - (Intercept) | 2.57 | [0.70, 4.84] | 99.42% | 1.009 | 197 - Petal.Width | 1.05 | [0.73, 1.37] | 100% | 1.004 | 2213 - - # sigma Parameters - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ----------------------------------------------------------- - sigma | 0.38 | [0.34, 0.43] | 100% | 1.002 | 2011 - - # Random Effects Variances - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------------- - SD (Intercept: Species) | 1.68 | [0.64, 3.64] | 100% | 1.007 | 774 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - ---- - - Code - mp6 - Output - # Fixed Effects - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------ - (Intercept) | 33.06 | [24.70, 40.47] | 100% | 1.021 | 666 - wt | -4.39 | [-6.94, -1.76] | 99.72% | 1.024 | 102 - - # sigma Parameters - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ----------------------------------------------------------- - sigma | 2.59 | [1.96, 3.48] | 100% | 1.009 | 902 - - # Random Effects Variances - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------------------- - SD (Intercept: cyl) | 3.19 | [ 0.49, 9.00] | 100% | 1.003 | 350 - SD (Intercept: gear) | 3.76 | [ 0.14, 10.13] | 100% | 1.015 | 1264 - SD (wt: gear) | 1.47 | [ 0.06, 3.96] | 100% | 1.034 | 660 - Cor (Intercept~wt: gear) | -0.38 | [-0.99, 0.82] | 76.85% | 1.022 | 893 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - ---- - - Code - mp7 - Output - # Fixed Effects - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ---------------------------------------------------------------- - (Intercept) | -1.07 | [-1.42, -0.73] | 100% | 1.001 | 2806 - persons | 0.90 | [ 0.81, 0.99] | 100% | 1.001 | 3057 - child | -1.17 | [-1.37, -0.99] | 100% | 1.002 | 2560 - camper | 0.74 | [ 0.56, 0.94] | 100% | 1.000 | 2879 - - # Zero-Inflation Parameters - - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - ----------------------------------------------------------------- - (Intercept) | -0.58 | [-1.27, 0.08] | 95.97% | 1.001 | 2969 - child | 1.24 | [ 0.71, 1.82] | 100% | 1.001 | 2872 - camper | -0.62 | [-1.38, 0.11] | 94.73% | 1.000 | 3040 - ---- - - Code - mp9 - Output - Parameter | Mean | 95% CI | pd | Rhat | ESS (tail) - -------------------------------------------------------------------- - Intercept[1] | -38.42 | [-67.76, -19.66] | 100% | 1.001 | 1121 - Intercept[2] | -33.26 | [-59.09, -16.53] | 100% | 1.001 | 1111 - mpg | -1.80 | [ -3.20, -0.90] | 100% | 1.002 | 1172 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - -# print-information - - Code - out - Output - # Fixed Effects - - Parameter | Median | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------- - (Intercept) | 39.68 | [36.12, 43.27] | 100% | 1.000 | 3255 - wt | -3.20 | [-4.79, -1.65] | 99.95% | 1.002 | 2003 - cyl | -1.49 | [-2.36, -0.64] | 99.95% | 1.002 | 2227 - - # Sigma - - Parameter | Median | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------- - sigma | 2.63 | [2.06, 3.51] | 100% | 1.001 | 2415 - Message - - Uncertainty intervals (equal-tailed) computed using a MCMC distribution - approximation. - ---- - - Code - out - Output - # Fixed Effects - - Parameter | Median | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------------- - (Intercept) | 39.68 | [36.27, 43.34] | 100% | 1.000 | 3255 - wt | -3.20 | [-4.70, -1.57] | 99.95% | 1.002 | 2003 - cyl | -1.49 | [-2.38, -0.68] | 99.95% | 1.002 | 2227 - - # Sigma - - Parameter | Median | 95% CI | pd | Rhat | ESS (tail) - ------------------------------------------------------------- - sigma | 2.63 | [1.99, 3.39] | 100% | 1.001 | 2415 - Message - - Uncertainty intervals (highest-density) computed using a MCMC - distribution approximation. - diff --git a/tests/testthat/_snaps/sampleSelection.md b/tests/testthat/_snaps/sampleSelection.md new file mode 100644 index 000000000..d2eef03be --- /dev/null +++ b/tests/testthat/_snaps/sampleSelection.md @@ -0,0 +1,71 @@ +# model_parameters + + Code + print(model_parameters(m1), zap_small = TRUE, table_width = Inf) + Output + # selection + + Parameter | Coefficient | SE | 95% CI | t(490) | p + ------------------------------------------------------------------ + (Intercept) | -0.15 | 0.11 | [-0.36, 0.05] | -1.47 | 0.141 + xs | 1.14 | 0.18 | [ 0.79, 1.49] | 6.39 | < .001 + + # outcome + + Parameter | Coefficient | SE | 95% CI | t(490) | p + ------------------------------------------------------------------ + (Intercept) | 0.03 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 + xo1 | 0.84 | 0.15 | [ 0.55, 1.13] | 5.61 | < .001 + (Intercept) | 0.16 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 + xo2 | 0.84 | 0.17 | [ 0.50, 1.17] | 4.91 | < .001 + + # Auxiliary + + Parameter | Coefficient | SE | 95% CI | t(490) | p + ---------------------------------------------------------------- + sigma1 | 0.93 | 0.09 | [ 0.75, 1.11] | 10.12 | < .001 + rho1 | 0.89 | 0.05 | [ 0.78, 1.00] | 16.62 | < .001 + sigma2 | 0.91 | 0.04 | [ 0.82, 0.99] | 20.45 | < .001 + rho2 | 0.18 | 0.33 | [-0.47, 0.83] | 0.53 | 0.594 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(model_parameters(m2), zap_small = TRUE, table_width = Inf) + Output + # selection + + Parameter | Coefficient | SE | 95% CI | t(740) | p + ------------------------------------------------------------------- + (Intercept) | -4.12 | 1.40 | [-6.87, -1.37] | -2.94 | 0.003 + age | 0.18 | 0.07 | [ 0.05, 0.31] | 2.79 | 0.005 + age^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -3.12 | 0.002 + faminc | 0.00 | 0.00 | [ 0.00, 0.00] | 1.29 | 0.199 + kidsTRUE | -0.45 | 0.13 | [-0.71, -0.20] | -3.46 | < .001 + educ | 0.10 | 0.02 | [ 0.05, 0.14] | 4.12 | < .001 + + # outcome + + Parameter | Coefficient | SE | 95% CI | t(740) | p + ------------------------------------------------------------------ + (Intercept) | -1.96 | 1.20 | [-4.32, 0.39] | -1.64 | 0.102 + exper | 0.03 | 0.06 | [-0.09, 0.15] | 0.45 | 0.651 + exper^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -0.06 | 0.955 + educ | 0.46 | 0.07 | [ 0.31, 0.60] | 6.24 | < .001 + city | 0.45 | 0.32 | [-0.17, 1.07] | 1.41 | 0.158 + + # Auxiliary + + Parameter | Coefficient | SE | 95% CI | t(740) | p + ---------------------------------------------------------------- + sigma | 3.11 | 0.11 | [ 2.88, 3.33] | 27.31 | < .001 + rho | -0.13 | 0.17 | [-0.46, 0.19] | -0.80 | 0.424 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + diff --git a/tests/testthat/_snaps/serp.md b/tests/testthat/_snaps/serp.md new file mode 100644 index 000000000..e92edd9bf --- /dev/null +++ b/tests/testthat/_snaps/serp.md @@ -0,0 +1,24 @@ +# model_parameters.serp + + Code + suppressMessages(print(mp)) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + ------------------------------------------------------------------------------ + (Intercept):1 | 1.40 | 0.54 | [ 0.33, 2.46] | 2.57 | 0.010 + (Intercept):2 | -1.13 | 0.51 | [-2.13, -0.12] | -2.19 | 0.028 + (Intercept):3 | -3.44 | 0.71 | [-4.84, -2.04] | -4.82 | < .001 + (Intercept):4 | -4.98 | 0.95 | [-6.85, -3.11] | -5.23 | < .001 + tempwarm:1 | 2.38 | 0.81 | [ 0.79, 3.97] | 2.93 | 0.003 + tempwarm:2 | 2.26 | 0.71 | [ 0.87, 3.66] | 3.18 | 0.001 + tempwarm:3 | 2.41 | 0.77 | [ 0.89, 3.92] | 3.11 | 0.002 + tempwarm:4 | 2.51 | 0.88 | [ 0.79, 4.23] | 2.85 | 0.004 + contactyes:1 | 1.38 | 0.74 | [-0.08, 2.84] | 1.85 | 0.064 + contactyes:2 | 1.35 | 0.67 | [ 0.03, 2.66] | 2.01 | 0.044 + contactyes:3 | 1.35 | 0.76 | [-0.13, 2.83] | 1.78 | 0.075 + contactyes:4 | 1.22 | 0.86 | [-0.46, 2.89] | 1.42 | 0.156 + temp [warm] * contactyes:1 | 0.37 | 1.12 | [-1.82, 2.56] | 0.33 | 0.741 + temp [warm] * contactyes:2 | 0.35 | 1.03 | [-1.66, 2.37] | 0.34 | 0.730 + temp [warm] * contactyes:3 | 0.36 | 0.97 | [-1.55, 2.26] | 0.37 | 0.713 + temp [warm] * contactyes:4 | 0.32 | 1.02 | [-1.68, 2.33] | 0.32 | 0.751 + diff --git a/tests/testthat/_snaps/svylme.md b/tests/testthat/_snaps/svylme.md new file mode 100644 index 000000000..b00a05ce8 --- /dev/null +++ b/tests/testthat/_snaps/svylme.md @@ -0,0 +1,26 @@ +# model_parameters svylme + + Code + print(mp) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | t | p + -------------------------------------------------------------------- + (Intercept) | -60.98 | 34.48 | [-128.57, 6.61] | -1.77 | 0.077 + ell | 0.92 | 0.26 | [ 0.41, 1.42] | 3.56 | < .001 + mobility | -0.38 | 0.24 | [ -0.85, 0.08] | -1.60 | 0.109 + api99 | 1.10 | 0.03 | [ 1.03, 1.17] | 31.44 | < .001 + + # Random Effects + + Parameter | Coefficient + ----------------------------------- + SD (Intercept: dnum1) | 1.19 + SD (api99: dnum2) | 1.39e-03 + SD (Residual) | 20.00 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg new file mode 100644 index 000000000..c8cbe8996 --- /dev/null +++ b/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + +Coefficient +Parameter + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + +gear +cyl +wt +(Intercept) + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg new file mode 100644 index 000000000..82b6c824b --- /dev/null +++ b/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + +Coefficient +Parameter + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + +wt +cyl +gear +(Intercept) + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg new file mode 100644 index 000000000..d394670ba --- /dev/null +++ b/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + +Odds Ratio +Parameter + + + + + + +0e+00 +1e+17 +2e+17 +3e+17 +4e+17 + + + + +hp +wt +(Intercept) + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/weightit.md b/tests/testthat/_snaps/weightit.md new file mode 100644 index 000000000..b5964c1f6 --- /dev/null +++ b/tests/testthat/_snaps/weightit.md @@ -0,0 +1,51 @@ +# weightit, multinom + + Code + print(model_parameters(fit4, exponentiate = TRUE), zap_small = TRUE) + Output + # Response level: 2 + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------- + (Intercept) | 1.00 | 0.62 | [0.30, 3.39] | 0.00 | 0.998 + treat | 1.08 | 0.25 | [0.68, 1.71] | 0.31 | 0.755 + age | 0.97 | 0.01 | [0.95, 0.99] | -2.38 | 0.018 + educ | 0.98 | 0.05 | [0.89, 1.08] | -0.33 | 0.738 + + # Response level: 3 + + Parameter | Odds Ratio | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | 0.05 | 0.04 | [0.01, 0.20] | -4.23 | < .001 + treat | 1.18 | 0.29 | [0.73, 1.91] | 0.67 | 0.502 + age | 1.00 | 0.01 | [0.98, 1.02] | -0.01 | 0.989 + educ | 1.20 | 0.06 | [1.08, 1.33] | 3.51 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# weightit, ordinal + + Code + print(model_parameters(fit5, exponentiate = TRUE), zap_small = TRUE) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + ------------------------------------------------------------ + treat | 1.12 | 0.21 | [0.78, 1.61] | 0.60 | 0.549 + age | 0.99 | 0.01 | [0.97, 1.01] | -0.78 | 0.436 + educ | 1.11 | 0.04 | [1.03, 1.20] | 2.70 | 0.007 + + # Intercept + + Parameter | Odds Ratio | SE | 95% CI | z | p + ------------------------------------------------------------- + 1|2 | 3.28 | 1.70 | [1.19, 9.04] | 2.30 | 0.022 + 2|3 | 9.84 | 5.03 | [3.61, 26.82] | 4.47 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/wrs2.md b/tests/testthat/_snaps/wrs2.md new file mode 100644 index 000000000..c57bd2a96 --- /dev/null +++ b/tests/testthat/_snaps/wrs2.md @@ -0,0 +1,11 @@ +# model_parameters.mcp and robtab + + Code + print(df_b, table_width = Inf) + Output + Group1 | Group2 | Psihat | 95% CI | p + ------------------------------------------------- + placebo | low | -1 | [-5.32, 3.32] | 0.435 + placebo | high | -3 | [-7.32, 1.32] | 0.181 + low | high | -2 | [-6.32, 2.32] | 0.317 + From 06142237c6ce59fe5ab58615df35f7cab2e40443 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 15 Oct 2026 11:06:14 +0200 Subject: [PATCH 14/33] fix RD --- R/methods_aov.R | 187 ++++++++++++++++++++---------------- man/model_parameters.aov.Rd | 4 +- 2 files changed, 107 insertions(+), 84 deletions(-) diff --git a/R/methods_aov.R b/R/methods_aov.R index 18753716c..1bdc69585 100644 --- a/R/methods_aov.R +++ b/R/methods_aov.R @@ -4,8 +4,8 @@ #' Parameters from ANOVAs #' -#' @param model Object of class [aov()], [anova()], `aovlist`, `Gam`, -#' [manova()], `Anova.mlm`, `afex_aov` or `maov`. +#' @param model Object of class [`stats::aov()`], [`stats::anova()`], `aovlist`, +#' `Gam`, [manova()], `Anova.mlm`, `afex_aov` or `maov`. #' @param es_type The effect size of interest. Not that possibly not all #' effect sizes are applicable to the model object. See 'Details'. For Anova #' models, can also be a character vector with multiple effect size names. @@ -98,21 +98,23 @@ #' ) #' } #' @export -model_parameters.aov <- function(model, - type = NULL, - df_error = NULL, - ci = NULL, - alternative = NULL, - p_adjust = NULL, - test = NULL, - power = FALSE, - es_type = NULL, - keep = NULL, - drop = NULL, - include_intercept = FALSE, - table_wide = FALSE, - verbose = TRUE, - ...) { +model_parameters.aov <- function( + model, + type = NULL, + df_error = NULL, + ci = NULL, + alternative = NULL, + p_adjust = NULL, + test = NULL, + power = FALSE, + es_type = NULL, + keep = NULL, + drop = NULL, + include_intercept = FALSE, + table_wide = FALSE, + verbose = TRUE, + ... +) { # save model object, for later checks original_model <- model object_name <- insight::safe_deparse_symbol(substitute(model)) @@ -121,7 +123,9 @@ model_parameters.aov <- function(model, if (requireNamespace("car", quietly = TRUE)) { model <- car::Anova(model, type = type) } else { - insight::format_warning("Package {.pkg car} required for type-2 or type-3 Anova. Defaulting to type-1.") + insight::format_warning( + "Package {.pkg car} required for type-2 or type-3 Anova. Defaulting to type-1." + ) } } @@ -168,11 +172,7 @@ model_parameters.aov <- function(model, # filter parameters if (!is.null(keep) || !is.null(drop)) { - params <- .filter_parameters(params, - keep = keep, - drop = drop, - verbose = verbose - ) + params <- .filter_parameters(params, keep = keep, drop = drop, verbose = verbose) } # wide or long? @@ -181,7 +181,14 @@ model_parameters.aov <- function(model, } # add attributes - params <- .add_anova_attributes(params, model, ci, test = test, alternative = alternative, ...) + params <- .add_anova_attributes( + params, + model, + ci, + test = test, + alternative = alternative, + ... + ) class(params) <- c("parameters_model", "see_parameters_model", class(params)) attr(params, "object_name") <- object_name @@ -193,10 +200,7 @@ model_parameters.aov <- function(model, standard_error.aov <- function(model, ...) { params <- model_parameters(model) - .data_frame( - Parameter = params$Parameter, - SE = params$SE - ) + .data_frame(Parameter = params$Parameter, SE = params$SE) } @@ -220,10 +224,7 @@ p_value.aov <- function(model, ...) { return(NA) } - .data_frame( - Parameter = params$Parameter, - p = params$p - ) + .data_frame(Parameter = params$Parameter, p = params$p) } @@ -254,16 +255,18 @@ model_parameters.aovlist <- model_parameters.aov # .afex_aov ------ #' @export -model_parameters.afex_aov <- function(model, - es_type = NULL, - df_error = NULL, - type = NULL, - keep = NULL, - drop = NULL, - include_intercept = FALSE, - p_adjust = NULL, - verbose = TRUE, - ...) { +model_parameters.afex_aov <- function( + model, + es_type = NULL, + df_error = NULL, + type = NULL, + keep = NULL, + drop = NULL, + include_intercept = FALSE, + p_adjust = NULL, + verbose = TRUE, + ... +) { if (inherits(model$Anova, "Anova.mlm")) { params <- model$anova_table with_df_and_p <- summary(model$Anova)$univariate.tests @@ -310,11 +313,7 @@ model_parameters.afex_aov <- function(model, # filter parameters if (!is.null(keep) || !is.null(drop)) { - out <- .filter_parameters(out, - keep = keep, - drop = drop, - verbose = verbose - ) + out <- .filter_parameters(out, keep = keep, drop = drop, verbose = verbose) } if (!"Method" %in% names(out)) { @@ -353,15 +352,7 @@ model_parameters.seqanova.svyglm <- model_parameters.aov return(type) } # nolint start - switch(type, - `1` = , - `I` = 1, - `2` = , - `II` = 2, - `3` = , - `III` = 3, - 1 - ) + switch(type, `1` = , `I` = 1, `2` = , `II` = 2, `3` = , `III` = 3, 1) # nolint end } @@ -375,11 +366,23 @@ model_parameters.seqanova.svyglm <- model_parameters.aov } else if (!is.null(attr(model, "heading"))) { heading <- attr(model, "heading")[1] if (grepl("(.*)Type (.*) Wald(.*)", heading)) { - type <- type_to_numeric(insight::trim_ws(gsub("(.*)Type (.*) Wald(.*)", "\\2", heading))) + type <- type_to_numeric(insight::trim_ws(gsub( + "(.*)Type (.*) Wald(.*)", + "\\2", + heading + ))) } else if (grepl("Type (.*) Analysis(.*)", heading)) { - type <- type_to_numeric(insight::trim_ws(gsub("Type (.*) Analysis(.*)", "\\1", heading))) + type <- type_to_numeric(insight::trim_ws(gsub( + "Type (.*) Analysis(.*)", + "\\1", + heading + ))) } else if (grepl("(.*)Type (.*) tests(.*)", heading)) { - type <- type_to_numeric(insight::trim_ws(gsub("(.*)Type (.*) tests(.*)", "\\2", heading))) + type <- type_to_numeric(insight::trim_ws(gsub( + "(.*)Type (.*) tests(.*)", + "\\2", + heading + ))) } } else if ("type" %in% names(model) && !is.null(model$type)) { type <- type_to_numeric(model$type) @@ -401,12 +404,17 @@ model_parameters.seqanova.svyglm <- model_parameters.aov ci_low <- which(endsWith(colnames(params), "CI_low")) ci_high <- which(endsWith(colnames(params), "CI_high")) if (length(ci_low) && length(ci_high)) { - bound <- if (alternative == "less") params[[ci_low[1]]][1] else params[[ci_high[1]]][1] + bound <- if (alternative == "less") { + params[[ci_low[1]]][1] + } else { + params[[ci_high[1]]][1] + } bound <- insight::format_value(bound, digits = 2) side <- if (alternative == "less") "lower" else "upper" alternative_footer <- sprintf( "One-sided CIs: %s bound fixed at [%s].", - side, bound + side, + bound ) } } @@ -441,21 +449,28 @@ model_parameters.seqanova.svyglm <- model_parameters.aov if (is.null(predictors)) { treatment_contrasts_or_not_centered <- FALSE } else { - treatment_contrasts_or_not_centered <- vapply(predictors, function(i) { - if (is.factor(i)) { - cn <- stats::contrasts(i) - if (is.null(cn) || (all(cn %in% c(0, 1)))) { + treatment_contrasts_or_not_centered <- vapply( + predictors, + function(i) { + if (is.factor(i)) { + cn <- stats::contrasts(i) + if (is.null(cn) || (all(cn %in% c(0, 1)))) { + return(TRUE) + } + } else if (abs(mean(i, na.rm = TRUE)) > 1e-2) { return(TRUE) } - } else if (abs(mean(i, na.rm = TRUE)) > 1e-2) { - return(TRUE) - } - FALSE - }, TRUE) + FALSE + }, + TRUE + ) } # successfully checked predictors, or if not possible, at least found interactions? - if (!is.null(interaction_terms) && (any(treatment_contrasts_or_not_centered) || is.null(predictors))) { + if ( + !is.null(interaction_terms) && + (any(treatment_contrasts_or_not_centered) || is.null(predictors)) + ) { insight::format_alert( "Type 3 ANOVAs only give sensible and informative results when covariates are mean-centered and factors are coded with orthogonal contrasts (such as those produced by `contr.sum`, `contr.poly`, or `contr.helmert`, but *not* by the default `contr.treatment`)." # nolint ) @@ -464,14 +479,16 @@ model_parameters.seqanova.svyglm <- model_parameters.aov } -.effectsizes_for_aov <- function(model, - params, - es_type = NULL, - df_error = NULL, - ci = NULL, - alternative = NULL, - verbose = TRUE, - ...) { +.effectsizes_for_aov <- function( + model, + params, + es_type = NULL, + df_error = NULL, + ci = NULL, + alternative = NULL, + verbose = TRUE, + ... +) { # user actually does not want to compute effect sizes if (is.null(es_type)) { return(params) @@ -485,8 +502,11 @@ model_parameters.seqanova.svyglm <- model_parameters.aov insight::check_if_installed("effectsize") # set error-df, when provided. - if (!is.null(df_error) && is.data.frame(model) && - !any(c("DenDF", "den Df", "denDF", "df_error") %in% colnames(model))) { + if ( + !is.null(df_error) && + is.data.frame(model) && + !any(c("DenDF", "den Df", "denDF", "df_error") %in% colnames(model)) + ) { if (length(df_error) > nrow(model)) { insight::format_error( "Number of degrees of freedom in argument `df_error` is larger than number of parameters." @@ -544,7 +564,10 @@ model_parameters.seqanova.svyglm <- model_parameters.aov fx, all.x = TRUE, sort = FALSE, - by = intersect(c("Response", "Group", "Parameter"), intersect(colnames(params), colnames(fx))) + by = intersect( + c("Response", "Group", "Parameter"), + intersect(colnames(params), colnames(fx)) + ) ) params <- params[order(params$.id), ] params$.id <- NULL diff --git a/man/model_parameters.aov.Rd b/man/model_parameters.aov.Rd index 941a2688e..d63bf56af 100644 --- a/man/model_parameters.aov.Rd +++ b/man/model_parameters.aov.Rd @@ -23,8 +23,8 @@ ) } \arguments{ -\item{model}{Object of class \code{\link[=aov]{aov()}}, \code{\link[=anova]{anova()}}, \code{aovlist}, \code{Gam}, -\code{\link[=manova]{manova()}}, \code{Anova.mlm}, \code{afex_aov} or \code{maov}.} +\item{model}{Object of class \code{\link[stats:aov]{stats::aov()}}, \code{\link[stats:anova]{stats::anova()}}, \code{aovlist}, +\code{Gam}, \code{\link[=manova]{manova()}}, \code{Anova.mlm}, \code{afex_aov} or \code{maov}.} \item{type}{Numeric, type of sums of squares. May be 1, 2 or 3. If 2 or 3, ANOVA-tables using \code{car::Anova()} will be returned. (Ignored for From 6ce41b0e4d1503fa7c42545f663f28953b049c13 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 13:01:07 +0300 Subject: [PATCH 15/33] fix more tests --- man/dominance_analysis.Rd | 8 - tests/testthat/test-compare_parameters.R | 587 ++++++++++-------- tests/testthat/test-glmer.R | 1 + tests/testthat/test-model_parameters.anova.R | 56 +- .../test-model_parameters_std_mixed.R | 16 +- tests/testthat/test-p_adjust.R | 2 +- 6 files changed, 381 insertions(+), 289 deletions(-) diff --git a/man/dominance_analysis.Rd b/man/dominance_analysis.Rd index 048c1fe9f..dcb8c00a7 100644 --- a/man/dominance_analysis.Rd +++ b/man/dominance_analysis.Rd @@ -35,14 +35,6 @@ analysis and the R2 value associated with them is subtracted from the overall value. Predictors in \code{all} must be present in the model submitted to the \code{model} argument and cannot be in the \code{sets} argument.} -\item{conditional}{Logical. If \code{FALSE} then conditional dominance matrix is not computed. - -If conditional dominance is not desired as an importance criterion, avoiding computing the conditional dominance matrix can save computation time.} - -\item{complete}{Logical. If \code{FALSE} then complete dominance matrix is not computed. - -If complete dominance is not desired as an importance criterion, avoiding computing complete dominance designations can save computation time.} - \item{quote_args}{A character vector of arguments in the model submitted to \code{model} to \code{quote()} prior to submitting to the dominance analysis. This is necessary for data masked arguments (e.g., \code{weights}) to prevent them diff --git a/tests/testthat/test-compare_parameters.R b/tests/testthat/test-compare_parameters.R index 5ebe45e90..af951a9bd 100644 --- a/tests/testthat/test-compare_parameters.R +++ b/tests/testthat/test-compare_parameters.R @@ -1,268 +1,337 @@ skip_if_not_installed("withr") # make sure we have the correct interaction mark for tests -withr::with_options( - list(parameters_interaction = "*", easystats_table_width = Inf), - { - data(iris) - m1 <- lm(Sepal.Length ~ Species, data = iris) - m2 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris) - counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) - outcome <- gl(3, 1, 9) - treatment <- gl(3, 3) - m3 <- glm(counts ~ outcome + treatment, family = poisson()) - - x <- compare_parameters(m1, m2, m3) - test_that("compare_parameters, default", { - expect_identical( - colnames(x), - c( - "Parameter", "Component", "Effects", "Coefficient.m1", "SE.m1", "CI.m1", - "CI_low.m1", "CI_high.m1", "t.m1", "df_error.m1", "p.m1", "Coefficient.m2", - "SE.m2", "CI.m2", "CI_low.m2", "CI_high.m2", "t.m2", "df_error.m2", - "p.m2", "Log-Mean.m3", "SE.m3", "CI.m3", "CI_low.m3", "CI_high.m3", - "z.m3", "df_error.m3", "p.m3" - ) - ) - out <- capture.output(x) - expect_length(out, 14) - out <- format(x, select = "ci") - expect_identical(colnames(out), c("Parameter", "m1", "m2", "m3")) - expect_identical( - out$Parameter, - c( - "(Intercept)", "Species [versicolor]", "Species [virginica]", - "Petal Length", "Species [versicolor] * Petal Length", - "Species [virginica] * Petal Length", "outcome [2]", "outcome [3]", - "treatment [2]", "treatment [3]", NA, "Observations" - ) - ) - }) - - - x <- compare_parameters(m1, m2, m3, select = "se_p2") - test_that("compare_parameters, se_p2", { - expect_identical( - colnames(x), - c( - "Parameter", "Component", "Effects", "Coefficient.m1", "SE.m1", "CI.m1", - "CI_low.m1", "CI_high.m1", "t.m1", "df_error.m1", "p.m1", "Coefficient.m2", - "SE.m2", "CI.m2", "CI_low.m2", "CI_high.m2", "t.m2", "df_error.m2", - "p.m2", "Log-Mean.m3", "SE.m3", "CI.m3", "CI_low.m3", "CI_high.m3", - "z.m3", "df_error.m3", "p.m3" - ) +withr::with_options(list(parameters_interaction = "*", easystats_table_width = Inf), { + data(iris) + m1 <- lm(Sepal.Length ~ Species, data = iris) + m2 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris) + counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) + outcome <- gl(3, 1, 9) + treatment <- gl(3, 3) + m3 <- glm(counts ~ outcome + treatment, family = poisson()) + + x <- compare_parameters(m1, m2, m3) + test_that("compare_parameters, default", { + expect_identical( + colnames(x), + c( + "Parameter", + "Component", + "Effects", + "Coefficient.m1", + "SE.m1", + "CI.m1", + "CI_low.m1", + "CI_high.m1", + "t.m1", + "df_error.m1", + "p.m1", + "Coefficient.m2", + "SE.m2", + "CI.m2", + "CI_low.m2", + "CI_high.m2", + "t.m2", + "df_error.m2", + "p.m2", + "Log-Mean.m3", + "SE.m3", + "CI.m3", + "CI_low.m3", + "CI_high.m3", + "z.m3", + "df_error.m3", + "p.m3" ) - out <- capture.output(x) - expect_length(out, 14) - out <- format(x, select = "se_p2") - expect_identical( - colnames(out), - c( - "Parameter", "Coefficient (SE) (m1)", "p (m1)", "Coefficient (SE) (m2)", - "p (m2)", "Log-Mean (SE) (m3)", "p (m3)" - ) + ) + out <- capture.output(x) + expect_length(out, 14) + out <- format(x, select = "ci") + expect_identical(colnames(out), c("Parameter", "m1", "m2", "m3")) + expect_identical( + out$Parameter, + c( + "(Intercept)", + "Species [versicolor]", + "Species [virginica]", + "Petal Length", + "Species [versicolor] * Petal Length", + "Species [virginica] * Petal Length", + "outcome [2]", + "outcome [3]", + "treatment [2]", + "treatment [3]", + NA, + "Observations" ) - expect_identical( - out$Parameter, - c( - "(Intercept)", "Species [versicolor]", "Species [virginica]", - "Petal Length", "Species [versicolor] * Petal Length", - "Species [virginica] * Petal Length", "outcome [2]", "outcome [3]", - "treatment [2]", "treatment [3]", NA, "Observations" - ) + ) + }) + + x <- compare_parameters(m1, m2, m3, select = "se_p2") + test_that("compare_parameters, se_p2", { + expect_identical( + colnames(x), + c( + "Parameter", + "Component", + "Effects", + "Coefficient.m1", + "SE.m1", + "CI.m1", + "CI_low.m1", + "CI_high.m1", + "t.m1", + "df_error.m1", + "p.m1", + "Coefficient.m2", + "SE.m2", + "CI.m2", + "CI_low.m2", + "CI_high.m2", + "t.m2", + "df_error.m2", + "p.m2", + "Log-Mean.m3", + "SE.m3", + "CI.m3", + "CI_low.m3", + "CI_high.m3", + "z.m3", + "df_error.m3", + "p.m3" ) - }) - - - data(mtcars) - m1 <- lm(mpg ~ wt, data = mtcars) - m2 <- glm(vs ~ wt + cyl, data = mtcars, family = "binomial") - - test_that("compare_parameters, column name with escaping regex characters", { - out <- utils::capture.output(compare_parameters(m1, m2, column_names = c("linear model (m1)", "logistic reg. (m2)"))) - expect_identical(out[1], "Parameter | linear model (m1) | logistic reg. (m2)") - }) - - - data(mtcars) - m1 <- lm(mpg ~ hp, mtcars) - m2 <- lm(mpg ~ hp, mtcars) - test_that("compare_parameters, proper printing for CI=NULL #820", { - expect_snapshot(compare_parameters(m1, m2, ci = NULL)) - }) - - - skip_on_cran() - - - test_that("compare_parameters, correct random effects", { - suppressWarnings(skip_if_not_installed("glmmTMB")) - skip_if_not(getRversion() >= "4.0.0") - - data("fish") - m0 <- glm(count ~ child + camper, data = fish, family = poisson()) - - m1 <- glmmTMB::glmmTMB( - count ~ child + camper + (1 | persons) + (1 | ID), - data = fish, - family = poisson() + ) + out <- capture.output(x) + expect_length(out, 14) + out <- format(x, select = "se_p2") + expect_identical( + colnames(out), + c( + "Parameter", + "Coefficient (SE) (m1)", + "p (m1)", + "Coefficient (SE) (m2)", + "p (m2)", + "Log-Mean (SE) (m3)", + "p (m3)" ) - - m2 <- glmmTMB::glmmTMB( - count ~ child + camper + zg + (1 | ID), - ziformula = ~ child + (1 | persons), - data = fish, - family = glmmTMB::truncated_poisson() + ) + expect_identical( + out$Parameter, + c( + "(Intercept)", + "Species [versicolor]", + "Species [virginica]", + "Petal Length", + "Species [versicolor] * Petal Length", + "Species [virginica] * Petal Length", + "outcome [2]", + "outcome [3]", + "treatment [2]", + "treatment [3]", + NA, + "Observations" ) - - cp <- compare_parameters(m0, m1, m2, effects = "all", component = "all") - expect_snapshot(cp) - }) - - - test_that("compare_parameters, print_md-1", { - skip_if_not_installed("lme4") - skip_if_not_installed("knitr") - skip_if_not_installed("tinytable") - - data(sleepstudy, package = "lme4") - set.seed(1234) - sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) - lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) - lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) - - cp <- compare_parameters(lm1, lm2, select = "{estimate} ({ci})|{p}", drop = "^\\(Intercept") - out <- print_md(cp, groups = list( - Groups = c(2, 3), - Interactions = c(4, 5), - Controls = 1 - )) - expect_snapshot(print(out)) - }) - - test_that("compare_parameters, print_md-2", { - skip_if_not_installed("lme4") - skip_if_not_installed("knitr") - skip_if_not_installed("tinytable") - - data(sleepstudy, package = "lme4") - set.seed(1234) - sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) - lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) - lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) - - cp <- compare_parameters(lm1, lm2, select = "{estimate} ({ci})|{p}", drop = "^\\(Intercept") - out <- display(cp, groups = list( - Groups = c(2, 3), - Interactions = c(4, 5), - Controls = 1 - ), - format = "tt" - ) - expect_snapshot(print(out)) - }) - - test_that("compare_parameters, print_md-3", { - skip_if_not_installed("lme4") - skip_if_not_installed("knitr") - skip_if_not_installed("tinytable") - - data(sleepstudy, package = "lme4") - set.seed(1234) - sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) - lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) - lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) - - cp <- compare_parameters(lm1, lm2, select = "{estimate} ({ci})|{p}", drop = "^\\(Intercept", effects = "all") - expect_snapshot(print_md(cp)) - expect_snapshot(display(cp, format = "tt")) - }) - - test_that("compare_parameters, print_md-4", { - skip_if_not_installed("lme4") - skip_if_not_installed("knitr") - skip_if_not_installed("tinytable") - - data(sleepstudy, package = "lme4") - set.seed(1234) - sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) - lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) - lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) - - - # with reference level - cp <- compare_parameters(lm1, lm2, select = "{estimate} ({ci})|{p}", drop = "^\\(Intercept", include_reference = TRUE) - out <- print_md(cp, groups = list( - Groups = 2:4, - Interactions = 5:6, - Controls = 1 - )) - expect_snapshot(print(out)) - - }) - - test_that("compare_parameters, print_md-5", { - skip_if_not_installed("lme4") - skip_if_not_installed("knitr") - skip_if_not_installed("tinytable") - - data(sleepstudy, package = "lme4") - set.seed(1234) - sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) - lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) - lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) - - # with reference level - cp <- compare_parameters(lm1, lm2, drop = "^\\(Intercept", include_reference = TRUE) - out <- print_md(cp, groups = list( - Groups = 2:4, - Interactions = 5:6, - Controls = 1 - )) - expect_snapshot(print(out)) - - # error - cp <- compare_parameters(lm1, lm2, select = "{estimate} ({ci})|{p}", drop = "^\\(Intercept") - expect_error( - print_md(cp, groups = list( - Groups = c(2, 3), - Interactions = c(4, 5), - Controls = "XDays" - )), - regex = "Some group indices" - ) - expect_error( - print_md(cp, groups = list( - Groups = 1:2, - Interactions = 4:5, - Controls = 10 - )), - regex = "Some group indices" - ) - - # output identical for both calls - cp1 <- compare_parameters(lm1, lm2, select = "{estimate} ({ci})|{p}", drop = "^\\(Intercept") - out1 <- capture.output(print_md(cp1, groups = list( - Groups = 2:3, - Interactions = 4:5, - Controls = 1 - ))) - cp2 <- compare_parameters( - lm1, - lm2, - select = "{estimate} ({ci})|{p}", - drop = "^\\(Intercept", - groups = list( - Groups = c(2, 3), - Interactions = c(4, 5), - Controls = 1 - ) - ) - out2 <- capture.output(print_md(cp2)) - expect_identical(out1, out2) - }) - } -) + ) + }) + + data(mtcars) + m1 <- lm(mpg ~ wt, data = mtcars) + m2 <- glm(vs ~ wt + cyl, data = mtcars, family = "binomial") + + test_that("compare_parameters, column name with escaping regex characters", { + out <- utils::capture.output(compare_parameters( + m1, + m2, + column_names = c("linear model (m1)", "logistic reg. (m2)") + )) + expect_identical(out[1], "Parameter | linear model (m1) | logistic reg. (m2)") + }) + + data(mtcars) + m1 <- lm(mpg ~ hp, mtcars) + m2 <- lm(mpg ~ hp, mtcars) + test_that("compare_parameters, proper printing for CI=NULL #820", { + expect_snapshot(compare_parameters(m1, m2, ci = NULL)) + }) + + skip_on_cran() + + test_that("compare_parameters, correct random effects", { + suppressWarnings(skip_if_not_installed("glmmTMB")) + skip_if_not(getRversion() >= "4.0.0") + + data("fish") + m0 <- glm(count ~ child + camper, data = fish, family = poisson()) + + m1 <- glmmTMB::glmmTMB( + count ~ child + camper + (1 | persons) + (1 | ID), + data = fish, + family = poisson() + ) + + m2 <- glmmTMB::glmmTMB( + count ~ child + camper + zg + (1 | ID), + ziformula = ~ child + (1 | persons), + data = fish, + family = glmmTMB::truncated_poisson() + ) + + cp <- compare_parameters(m0, m1, m2, effects = "all", component = "all") + expect_snapshot(cp) + }) + + test_that("compare_parameters, print_md-1", { + skip_if_not_installed("lme4") + skip_if_not_installed("knitr") + skip_if_not_installed("tinytable") + + data(sleepstudy, package = "lme4") + set.seed(1234) + sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) + lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) + lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) + + cp <- compare_parameters( + lm1, + lm2, + select = "{estimate} ({ci})|{p}", + drop = "^\\(Intercept" + ) + out <- print_md( + cp, + groups = list(Groups = c(2, 3), Interactions = c(4, 5), Controls = 1) + ) + expect_snapshot(print(out)) + }) + + test_that("compare_parameters, print_md-2", { + skip_if_not_installed("lme4") + skip_if_not_installed("knitr") + skip_if_not_installed("tinytable") + + data(sleepstudy, package = "lme4") + set.seed(1234) + sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) + lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) + lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) + + cp <- compare_parameters( + lm1, + lm2, + select = "{estimate} ({ci})|{p}", + drop = "^\\(Intercept" + ) + out <- display( + cp, + groups = list(Groups = c(2, 3), Interactions = c(4, 5), Controls = 1), + format = "tt" + ) + expect_snapshot(print(out)) + }) + + test_that("compare_parameters, print_md-3", { + skip_if_not_installed("lme4") + skip_if_not_installed("knitr") + skip_if_not_installed("tinytable") + + data(sleepstudy, package = "lme4") + set.seed(1234) + sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) + lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) + lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) + + cp <- compare_parameters( + lm1, + lm2, + select = "{estimate} ({ci})|{p}", + drop = "^\\(Intercept", + effects = "all" + ) + expect_snapshot(print_md(cp)) + expect_snapshot(display(cp, format = "tt")) + }) + + test_that("compare_parameters, print_md-4", { + skip_if_not_installed("lme4") + skip_if_not_installed("knitr") + skip_if_not_installed("tinytable") + + data(sleepstudy, package = "lme4") + set.seed(1234) + sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) + lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) + lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) + + # with reference level + cp <- compare_parameters( + lm1, + lm2, + select = "{estimate} ({ci})|{p}", + drop = "^\\(Intercept", + include_reference = TRUE + ) + out <- print_md(cp, groups = list(Groups = 2:4, Interactions = 5:6, Controls = 1)) + expect_snapshot(print(out)) + }) + + test_that("compare_parameters, print_md-5", { + skip_if_not_installed("lme4") + skip_if_not_installed("knitr") + skip_if_not_installed("tinytable") + + data(sleepstudy, package = "lme4") + set.seed(1234) + sleepstudy$grp <- as.factor(sample.int(3, nrow(sleepstudy), replace = TRUE)) + lm1 <- lme4::lmer(Reaction ~ Days + grp + (1 | Subject), data = sleepstudy) + lm2 <- lme4::lmer(Reaction ~ Days * grp + (1 | Subject), data = sleepstudy) + + # with reference level + cp <- compare_parameters(lm1, lm2, drop = "^\\(Intercept", include_reference = TRUE) + out <- print_md(cp, groups = list(Groups = 2:4, Interactions = 5:6, Controls = 1)) + expect_snapshot(print(out)) + + # error + cp <- compare_parameters( + lm1, + lm2, + select = "{estimate} ({ci})|{p}", + drop = "^\\(Intercept" + ) + expect_error( + print_md( + cp, + groups = list(Groups = c(2, 3), Interactions = c(4, 5), Controls = "XDays") + ), + regex = "Some group indices" + ) + expect_error( + print_md(cp, groups = list(Groups = 1:2, Interactions = 4:5, Controls = 10)), + regex = "Some group indices" + ) + + # output identical for both calls + cp1 <- compare_parameters( + lm1, + lm2, + select = "{estimate} ({ci})|{p}", + drop = "^\\(Intercept" + ) + out1 <- capture.output(print_md( + cp1, + groups = list(Groups = 2:3, Interactions = 4:5, Controls = 1) + )) + cp2 <- compare_parameters( + lm1, + lm2, + select = "{estimate} ({ci})|{p}", + drop = "^\\(Intercept", + groups = list(Groups = c(2, 3), Interactions = c(4, 5), Controls = 1) + ) + out2 <- capture.output(print_md(cp2)) + expect_identical(out1, out2) + }) +}) skip_on_cran() skip_if_not_installed("blme") @@ -272,7 +341,9 @@ skip_if_not_installed("lme4") test_that("compare_parameters, works with blmer and glmmTMB", { data(sleepstudy, package = "lme4") control <- lme4::lmerControl(check.conv.grad = "ignore") - fm1 <- blme::blmer(Reaction ~ Days + (0 + Days | Subject), sleepstudy, + fm1 <- blme::blmer( + Reaction ~ Days + (0 + Days | Subject), + sleepstudy, control = control, cov.prior = gamma ) diff --git a/tests/testthat/test-glmer.R b/tests/testthat/test-glmer.R index 8bafd340d..b87622736 100644 --- a/tests/testthat/test-glmer.R +++ b/tests/testthat/test-glmer.R @@ -82,6 +82,7 @@ test_that("model_parameters.glmer betwithin", { test_that("robust SE/VCOV, using FPC", { skip_if(packageVersion("insight") <= "1.5.0") data(sleepstudy, package = "lme4") + data(sleepstudy, package = "lmerTest") model <- lme4::lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy) out <- standard_error(model, vcov = "fpc", vcov_args = list(population_size = 500)) expect_equal( diff --git a/tests/testthat/test-model_parameters.anova.R b/tests/testthat/test-model_parameters.anova.R index 5e3eee158..d9566a703 100644 --- a/tests/testthat/test-model_parameters.anova.R +++ b/tests/testthat/test-model_parameters.anova.R @@ -1,15 +1,17 @@ skip_on_cran() -m <- glm(am ~ mpg + hp + factor(cyl), - data = mtcars, family = binomial() -) +m <- glm(am ~ mpg + hp + factor(cyl), data = mtcars, family = binomial()) test_that("model_parameters.anova", { a <- anova(m, test = "Chisq") mp <- model_parameters(a) expect_named(mp, c("Parameter", "df", "Deviance", "df_error", "Deviance_error", "p")) - expect_equal(mp$Deviance_error, c(43.22973, 29.67517, 19.23255, 10.48692), tolerance = 1e-3) + expect_equal( + mp$Deviance_error, + c(43.22973, 29.67517, 19.23255, 10.48692), + tolerance = 1e-3 + ) expect_equal(mp$p, c(NA, 0.00023, 0.00123, 0.01262), tolerance = 1e-3) expect_snapshot(mp) }) @@ -27,7 +29,10 @@ test_that("model_parameters.anova for mixed models", { skip_if_not_installed("lmerTest") m <- lmerTest::lmer(mpg ~ wt + (1 | gear), data = mtcars) out <- parameters::model_parameters(anova(m)) - expect_named(out, c("Parameter", "Sum_Squares", "df", "df_error", "Mean_Square", "F", "p")) + expect_named( + out, + c("Parameter", "Sum_Squares", "df", "df_error", "Mean_Square", "F", "p") + ) expect_equal(out$df_error, 21.92272, tolerance = 1e-4) }) @@ -95,12 +100,16 @@ test_that("model_parameters_Anova.mlm-2", { test_that("model_parameters_Anova-effectsize", { skip_if_not_installed("lme4") + skip_if_not_installed("lmerTest") skip_if_not_installed("effectsize") df <- iris df$Sepal.Big <- ifelse(df$Sepal.Width >= 3, "Yes", "No") - mm <- suppressMessages(lme4::lmer(Sepal.Length ~ Sepal.Big + Petal.Width + (1 | Species), data = df)) + mm <- suppressMessages(lme4::lmer( + Sepal.Length ~ Sepal.Big + Petal.Width + (1 | Species), + data = df + )) model <- anova(mm) # parameters table including effect sizes @@ -114,8 +123,14 @@ test_that("model_parameters_Anova-effectsize", { expect_identical( colnames(mp), c( - "Parameter", "Sum_Squares", "df", "Mean_Square", "F", "Eta2_partial", - "Eta2_CI_low", "Eta2_CI_high" + "Parameter", + "Sum_Squares", + "df", + "Mean_Square", + "F", + "Eta2_partial", + "Eta2_CI_low", + "Eta2_CI_high" ) ) expect_equal(mp$Eta2_partial, c(0.03262, 0.6778), tolerance = 1e-3) @@ -146,15 +161,13 @@ test_that("anova type | lm", { m <- lm(mpg ~ factor(cyl) + hp + disp, mtcars) expect_warning(model_parameters(aov(m)), regexp = NA) # no need for warning, because no interactions - m <- lm(mpg ~ factor(cyl) * scale(disp, TRUE, FALSE) + scale(disp, TRUE, FALSE), + m <- lm( + mpg ~ factor(cyl) * scale(disp, TRUE, FALSE) + scale(disp, TRUE, FALSE), mtcars, contrasts = list("factor(cyl)" = contr.helmert) ) a3 <- car::Anova(m, type = 3) - expect_message( - model_parameters(a3), - "Type 3 ANOVAs only give" - ) + expect_message(model_parameters(a3), "Type 3 ANOVAs only give") }) test_that("anova type | mlm", { @@ -198,7 +211,9 @@ test_that("anova type | lme4", { m1 <- lme4::lmer(mpg ~ factor(cyl) * hp + disp + (1 | gear), mtcars) suppressMessages({ - m2 <- lme4::glmer(carb ~ factor(cyl) * hp + disp + (1 | gear), mtcars, + m2 <- lme4::glmer( + carb ~ factor(cyl) * hp + disp + (1 | gear), + mtcars, family = poisson() ) }) @@ -238,9 +253,13 @@ test_that("anova type | afex + Anova.mlm", { data(obk.long, package = "afex") suppressMessages({ - m <- afex::aov_ez("id", "value", obk.long, + m <- afex::aov_ez( + "id", + "value", + obk.long, between = c("treatment", "gender"), - within = c("phase", "hour"), observed = "gender" + within = c("phase", "hour"), + observed = "gender" ) }) @@ -256,7 +275,10 @@ test_that("anova rms", { expect_identical(attr(mp, "anova_type"), 2) expect_identical(mp$Parameter, c("cyl", "disp", "hp", "drat", "Total", "Residuals")) - expect_identical(colnames(mp), c("Parameter", "Sum_Squares_Partial", "df", "Mean_Square", "F", "p")) + expect_identical( + colnames(mp), + c("Parameter", "Sum_Squares_Partial", "df", "Mean_Square", "F", "p") + ) expect_equal(mp$Sum_Squares_Partial, data.frame(a)$Partial.SS, tolerance = 1e-3) }) diff --git a/tests/testthat/test-model_parameters_std_mixed.R b/tests/testthat/test-model_parameters_std_mixed.R index f4f043d57..2f882fc01 100644 --- a/tests/testthat/test-model_parameters_std_mixed.R +++ b/tests/testthat/test-model_parameters_std_mixed.R @@ -59,7 +59,8 @@ test_that("model_parameters, standardize-refit", { model, standardize = "refit", verbose = FALSE, - effects = "fixed" + effects = "fixed", + ci_method = "wald" ) expect_equal(c(nrow(params), ncol(params)), c(7, 10)) expect_equal( @@ -82,12 +83,14 @@ test_that("model_parameters, standardize-refit", { model, standardize = "refit", verbose = FALSE, - effects = "all" + effects = "all", + ci_method = "wald" ) paramsZ <- model_parameters( effectsize::standardize(model), effects = "all", - verbose = FALSE + verbose = FALSE, + ci_method = "wald" ) expect_equal(paramsZ, params, ignore_attr = TRUE) }) @@ -97,7 +100,8 @@ test_that("model_parameters, standardize-posthoc", { model, standardize = "posthoc", verbose = FALSE, - effects = "fixed" + effects = "fixed", + ci_method = "wald" ) expect_equal(c(nrow(params), ncol(params)), c(7, 10)) expect_equal( @@ -215,7 +219,8 @@ test_that("model_parameters, standardize-basic", { model, standardize = "basic", verbose = FALSE, - effects = "fixed" + effects = "fixed", + ci_method = "wald" ) expect_equal( params$CI_high, @@ -231,6 +236,7 @@ test_that("model_parameters, standardize-refit robust", { standardize = "refit", effects = "fixed", vcov = "CR", + ci_method = "wald", vcov_args = list(type = "CR1", cluster = iris$grp), verbose = FALSE ) diff --git a/tests/testthat/test-p_adjust.R b/tests/testthat/test-p_adjust.R index 96b5089a7..6a79b6154 100644 --- a/tests/testthat/test-p_adjust.R +++ b/tests/testthat/test-p_adjust.R @@ -118,7 +118,7 @@ test_that("model_parameters, simultaenous confidence intervals", { data = qol_cancer ) set.seed(123) - mp <- model_parameters(model, p_adjust = "sup-t") + mp <- model_parameters(model, p_adjust = "sup-t", ci_method = "wald") expect_equal(mp$p, c(0, 0.27904, 0, 0, NA, NA), tolerance = 1e-3) expect_equal( mp$CI_low, From b76c21e1328791e35a9242cd74070abf8845a47b Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 13:03:36 +0300 Subject: [PATCH 16/33] double check for lmerMod class --- R/methods_lme4.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index cdfe869c1..c27db9b28 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -261,7 +261,9 @@ se_mixed_default <- function(model) { fallback = "wald", bootstrap = FALSE ) { - if (effects == "random" || !is.null(method) || bootstrap) { + if ( + !is.null(method) || !inherits(model, "lmerMod") || effects == "random" || bootstrap + ) { return(method) } From 520b90e2a36faa0059529f0202710d6cfe58f98f Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 13:07:26 +0300 Subject: [PATCH 17/33] oops --- R/methods_lme4.R | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index c27db9b28..a589666e5 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -118,7 +118,12 @@ model_parameters.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- model_parameters.merMod - cl$ci_method <- .attempt_satterthwaite_method(ci_method, effects, bootstrap = bootstrap) + cl$ci_method <- .attempt_satterthwaite_method( + ci_method, + model, + effects, + bootstrap = bootstrap + ) eval.parent(cl) } @@ -137,7 +142,7 @@ ci.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- ci.merMod - cl$method <- .attempt_satterthwaite_method(method, effects) + cl$method <- .attempt_satterthwaite_method(method, model, effects) eval.parent(cl) } @@ -152,7 +157,7 @@ standard_error.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- standard_error.merMod - cl$method <- .attempt_satterthwaite_method(method, effects) + cl$method <- .attempt_satterthwaite_method(method, model, effects) eval.parent(cl) } @@ -169,7 +174,7 @@ p_value.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- p_value.merMod - cl$method <- .attempt_satterthwaite_method(method, effects) + cl$method <- .attempt_satterthwaite_method(method, model, effects) eval.parent(cl) } @@ -257,13 +262,12 @@ se_mixed_default <- function(model) { .attempt_satterthwaite_method <- function( method, + model, effects, fallback = "wald", bootstrap = FALSE ) { - if ( - !is.null(method) || !inherits(model, "lmerMod") || effects == "random" || bootstrap - ) { + if (!is.null(method) || !inherits(x, "lmerMod") || effects == "random" || bootstrap) { return(method) } From f2b1d0d1421a3557b82201c472354eea06a95967 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 13:13:05 +0300 Subject: [PATCH 18/33] double oops --- R/methods_lme4.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index a589666e5..d7a76e9c7 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -267,7 +267,9 @@ se_mixed_default <- function(model) { fallback = "wald", bootstrap = FALSE ) { - if (!is.null(method) || !inherits(x, "lmerMod") || effects == "random" || bootstrap) { + if ( + !is.null(method) || !inherits(model, "lmerMod") || effects == "random" || bootstrap + ) { return(method) } From d38d3d08aa1ee10f704ca769b920bebd4a7d6d75 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 13:16:33 +0300 Subject: [PATCH 19/33] i hate this so much --- R/methods_lme4.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index d7a76e9c7..ce259e002 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -142,7 +142,7 @@ ci.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- ci.merMod - cl$method <- .attempt_satterthwaite_method(method, model, effects) + cl$method <- .attempt_satterthwaite_method(method, x, effects) eval.parent(cl) } From fcba851dab49821b5043c7fbf151ffbe88c4c43d Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 13:31:35 +0300 Subject: [PATCH 20/33] fix one last time (haha yeah right) --- R/methods_lme4.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index ce259e002..be660b087 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -267,9 +267,8 @@ se_mixed_default <- function(model) { fallback = "wald", bootstrap = FALSE ) { - if ( - !is.null(method) || !inherits(model, "lmerMod") || effects == "random" || bootstrap - ) { + is_right_class <- inherits(model, "lmerMod") && !inherits(model, c("blmerMod", "wblm")) + if (!is.null(method) || !is_right_class || effects == "random" || bootstrap) { return(method) } From 3dbb2f009839c1fde941d04642ed65a24172ab26 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 13:31:40 +0300 Subject: [PATCH 21/33] snaps --- .../equivalence_test/equivalence-test-1.svg | 70 ----- .../equivalence_test/equivalence-test-2.svg | 73 ----- .../equivalence_test/equivalence-test-3.svg | 93 ------ .../equivalence_test/equivalence-test-4.svg | 93 ------ .../equivalence_test/equivalence-test-5.svg | 93 ------ tests/testthat/_snaps/glmmTMB.new.md | 279 ++++++++++++++++++ tests/testthat/_snaps/include_reference.md | 245 --------------- tests/testthat/_snaps/ivreg.md | 20 -- tests/testthat/_snaps/lcmm.md | 257 ---------------- tests/testthat/_snaps/mipo.md | 42 --- .../testthat/_snaps/model_parameters.anova.md | 30 -- .../_snaps/model_parameters.fixest.md | 25 -- .../_snaps/model_parameters.fixest_multi.md | 160 ---------- .../_snaps/model_parameters.mclogit.md | 80 ----- tests/testthat/_snaps/plm.md | 34 --- tests/testthat/_snaps/print_AER_labels.md | 19 -- tests/testthat/_snaps/sampleSelection.md | 71 ----- tests/testthat/_snaps/serp.md | 24 -- tests/testthat/_snaps/svylme.md | 26 -- .../_snaps/tinyplot/tinyplot-forest-1.svg | 63 ---- .../_snaps/tinyplot/tinyplot-forest-2.svg | 63 ---- .../tinyplot-forest-exponentiated.svg | 57 ---- tests/testthat/_snaps/weightit.md | 51 ---- tests/testthat/_snaps/wrs2.md | 11 - 24 files changed, 279 insertions(+), 1700 deletions(-) delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg delete mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg create mode 100644 tests/testthat/_snaps/glmmTMB.new.md delete mode 100644 tests/testthat/_snaps/include_reference.md delete mode 100644 tests/testthat/_snaps/ivreg.md delete mode 100644 tests/testthat/_snaps/lcmm.md delete mode 100644 tests/testthat/_snaps/mipo.md delete mode 100644 tests/testthat/_snaps/model_parameters.fixest_multi.md delete mode 100644 tests/testthat/_snaps/model_parameters.mclogit.md delete mode 100644 tests/testthat/_snaps/plm.md delete mode 100644 tests/testthat/_snaps/print_AER_labels.md delete mode 100644 tests/testthat/_snaps/sampleSelection.md delete mode 100644 tests/testthat/_snaps/serp.md delete mode 100644 tests/testthat/_snaps/svylme.md delete mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg delete mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg delete mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg delete mode 100644 tests/testthat/_snaps/weightit.md delete mode 100644 tests/testthat/_snaps/wrs2.md diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg deleted file mode 100644 index 533976c27..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Speciesvirginica -Speciesversicolor - - - - - - -0.0 -0.5 -1.0 -1.5 - -Equivalence - - - -Rejected -Equivalence-Test 1 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg deleted file mode 100644 index a987aae10..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Speciesvirginica -Speciesversicolor - - - - - - - --100 --75 --50 --25 -0 - -Equivalence - - - -Rejected -Equivalence-Test 2 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg deleted file mode 100644 index f6d783bb3..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cyl8 -cyl6 -gear5 -gear4 -hp - - - - - - - - - --5 -0 -5 -10 - -Equivalence - - - - - - - - - -Accepted -Rejected -Undecided -Equivalence-Test 3 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg deleted file mode 100644 index 6f6c286e7..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cyl8 -cyl6 -gear5 -gear4 -hp - - - - - - - - - --5 -0 -5 -10 - -Equivalence - - - - - - - - - -Accepted -Rejected -Undecided -Equivalence-Test 4 - - diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg deleted file mode 100644 index 5a9d29a42..000000000 --- a/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cyl8 -cyl6 -gear5 -gear4 -hp - - - - - - - - - --5 -0 -5 -10 - -Equivalence - - - - - - - - - -Accepted -Rejected -Undecided -Equivalence-Test 5 - - diff --git a/tests/testthat/_snaps/glmmTMB.new.md b/tests/testthat/_snaps/glmmTMB.new.md new file mode 100644 index 000000000..32cb6690f --- /dev/null +++ b/tests/testthat/_snaps/glmmTMB.new.md @@ -0,0 +1,279 @@ +# print-model_parameters glmmTMB + + Code + out[-5] + Output + [1] "# Fixed Effects" + [2] "" + [3] "Parameter | Log-Mean | SE | 95% CI | z | p" + [4] "----------------------------------------------------------------" + [5] "child | -1.04 | 0.09 | [-1.22, -0.87] | -11.60 | < .001" + [6] "camper [1] | 0.27 | 0.09 | [ 0.09, 0.44] | 2.98 | 0.003 " + +# print-model_parameters glmmTMB digits + + Code + out[-c(5, 14)] + Output + [1] "# Fixed Effects (Count Model)" + [2] "" + [3] "Parameter | Log-Mean | SE | 95% CI | z | p" + [4] "--------------------------------------------------------------------------" + [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" + [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " + [7] "" + [8] "# Fixed Effects (Zero-Inflation Component)" + [9] "" + [10] "Parameter | Log-Odds | SE | 95% CI | z | p" + [11] "--------------------------------------------------------------------------" + [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" + [13] "camper [1] | -4.8291 | | | | " + [14] "" + [15] "# Random Effects Variances" + [16] "" + [17] "Parameter | Coefficient | 95% CI" + [18] "----------------------------------------------------------------" + [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" + [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" + [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" + [22] "" + [23] "# Random Effects (Zero-Inflation Component)" + [24] "" + [25] "Parameter | Coefficient | 95% CI" + [26] "----------------------------------------------------------------" + [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" + [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" + [29] "Cor (Intercept~zg: persons) | 0.9790 | " + +--- + + Code + out[-c(5, 14)] + Output + [1] "# Fixed Effects (Count Model)" + [2] "" + [3] "Parameter | Log-Mean | SE | 95% CI | z | p" + [4] "--------------------------------------------------------------------------" + [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" + [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " + [7] "" + [8] "# Fixed Effects (Zero-Inflation Component)" + [9] "" + [10] "Parameter | Log-Odds | SE | 95% CI | z | p" + [11] "--------------------------------------------------------------------------" + [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" + [13] "camper [1] | -4.8291 | | | | " + [14] "" + [15] "# Random Effects Variances" + [16] "" + [17] "Parameter | Coefficient | 95% CI" + [18] "----------------------------------------------------------------" + [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" + [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" + [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" + [22] "" + [23] "# Random Effects (Zero-Inflation Component)" + [24] "" + [25] "Parameter | Coefficient | 95% CI" + [26] "----------------------------------------------------------------" + [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" + [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" + [29] "Cor (Intercept~zg: persons) | 0.9790 | " + +# print-model_parameters glmmTMB CI alignment + + Code + print(mp) + Output + # Random Effects: conditional + + Parameter | Coefficient | 95% CI + ---------------------------------------------------------------- + SD (Intercept: Session:Participant) | 0.27 | [0.08, 0.87] + SD (Intercept: Participant) | 0.38 | [0.16, 0.92] + + # Random Effects: zero_inflated + + Parameter | Coefficient | 95% CI + ---------------------------------------------------------------- + SD (Intercept: Session:Participant) | 0.69 | [0.40, 1.19] + SD (Intercept: Participant) | 2.39 | [1.25, 4.57] + Message + + Uncertainty intervals for random effect variances computed using a + Wald z-distribution approximation. + +--- + + Code + print(mp) + Output + # Fixed Effects + + Parameter | Log-Mean | SE | 95% CI | z | p + --------------------------------------------------------------------- + (Intercept) | 2.12 | 0.30 | [ 1.53, 2.71] | 7.05 | < .001 + Surface [Lingual] | 0.01 | 0.29 | [-0.56, 0.58] | 0.04 | 0.971 + Surface [Occlusal] | 0.54 | 0.22 | [ 0.10, 0.98] | 2.43 | 0.015 + Side [Anterior] | 0.04 | 0.32 | [-0.58, 0.66] | 0.14 | 0.889 + Side [Left] | -0.04 | 0.20 | [-0.44, 0.37] | -0.17 | 0.862 + Jaw [Maxillar] | -0.10 | 0.21 | [-0.51, 0.30] | -0.51 | 0.612 + + # Zero-Inflation + + Parameter | Log-Odds | SE | 95% CI | z | p + ---------------------------------------------------------------------- + (Intercept) | 4.87 | 0.93 | [ 3.04, 6.69] | 5.23 | < .001 + Surface [Lingual] | 0.93 | 0.34 | [ 0.27, 1.60] | 2.75 | 0.006 + Surface [Occlusal] | -1.01 | 0.29 | [-1.59, -0.44] | -3.45 | < .001 + Side [Anterior] | -0.20 | 0.37 | [-0.93, 0.52] | -0.55 | 0.583 + Side [Left] | -0.38 | 0.27 | [-0.91, 0.14] | -1.44 | 0.151 + Jaw [Maxillar] | 0.59 | 0.24 | [ 0.11, 1.07] | 2.42 | 0.016 + + # Dispersion + + Parameter | Coefficient | 95% CI + ---------------------------------------- + (Intercept) | 2.06 | [1.30, 3.27] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# print-model_parameters + + Code + mp + Output + # Fixed Effects + + Parameter | Log-Mean | SE | 95% CI | z | p + ---------------------------------------------------------------- + (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 + child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 + camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 + + # Zero-Inflation + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 + child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 + camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 + +--- + + Code + mp + Output + # Fixed Effects + + Parameter | IRR | SE | 95% CI | z | p + ---------------------------------------------------------- + (Intercept) | 3.54 | 1.68 | [1.39, 8.98] | 2.66 | 0.008 + child | 0.32 | 0.03 | [0.27, 0.38] | -12.27 | < .001 + camper [1] | 2.08 | 0.19 | [1.73, 2.50] | 7.85 | < .001 + + # Zero-Inflation + + Parameter | Odds Ratio | SE | 95% CI | z | p + ---------------------------------------------------------------- + (Intercept) | 0.68 | 0.44 | [0.19, 2.43] | -0.60 | 0.551 + child | 7.80 | 2.42 | [4.25, 14.32] | 6.63 | < .001 + camper [1] | 0.36 | 0.12 | [0.19, 0.69] | -3.12 | 0.002 + +--- + + Code + mp + Output + # Fixed Effects (Count Model) + + Parameter | Log-Mean | SE | 95% CI | z | p + ---------------------------------------------------------------- + (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 + child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 + camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 + + # Fixed Effects (Zero-Inflation Component) + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 + child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 + camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 + + # Random Effects Variances + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 0.93 | [0.46, 1.89] + + # Random Effects (Zero-Inflation Component) + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 1.17 | [0.54, 2.57] + +# robust SE/VCOV + + Code + print(out, table_width = Inf) + Output + # Fixed Effects (Count Model) + + Parameter | Log-Mean | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | 1.26 | 0.46 | [ 0.36, 2.17] | 2.74 | 0.006 + child | -1.14 | 0.30 | [-1.73, -0.55] | -3.80 | < .001 + camper [1] | 0.73 | 0.41 | [-0.06, 1.53] | 1.80 | 0.072 + + # Fixed Effects (Zero-Inflation Component) + + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | -0.39 | 0.58 | [-1.52, 0.75] | -0.67 | 0.501 + child | 2.05 | 0.39 | [ 1.30, 2.81] | 5.33 | < .001 + camper [1] | -1.01 | 0.39 | [-1.77, -0.24] | -2.59 | 0.010 + + # Random Effects Variances + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 0.93 | [0.46, 1.89] + + # Random Effects (Zero-Inflation Component) + + Parameter | Coefficient | 95% CI + ---------------------------------------------------- + SD (Intercept: persons) | 1.17 | [0.54, 2.57] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(out, table_width = Inf) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | p + -------------------------------------------------------------------- + (Intercept) | 251.40 | 6.28 | [239.09, 263.72] | 40.02 | < .001 + Days | 10.47 | 1.45 | [ 7.63, 13.31] | 7.23 | < .001 + + # Random Effects + + Parameter | Coefficient | 95% CI + ------------------------------------------------------------ + SD (Intercept: Subject) | 23.78 | [15.02, 37.66] + SD (Days: Subject) | 5.72 | [ 3.81, 8.59] + Cor (Intercept~Days: Subject) | 0.08 | [-0.49, 0.59] + SD (Residual) | 25.59 | [22.80, 28.72] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/include_reference.md b/tests/testthat/_snaps/include_reference.md deleted file mode 100644 index aa2d2b4b9..000000000 --- a/tests/testthat/_snaps/include_reference.md +++ /dev/null @@ -1,245 +0,0 @@ -# include_reference, on-the-fly factors - - Code - print(out1) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 - gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 - am [0] | 0.00 | | | | - am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 - hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out2) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 - gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 - am [0] | 0.00 | | | | - am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 - hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print_md(out) - Output - - - |Parameter | m1 | m2 | - |:------------|:--------------------|:--------------------| - |(Intercept) |27.48 (23.43, 31.53) |27.48 (23.43, 31.53) | - |gear (3) | 0.00 | 0.00 | - |gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | - |gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | - |am (0) | 0.00 | 0.00 | - |am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | - |hp |-0.06 (-0.09, -0.04) |-0.06 (-0.09, -0.04) | - | | | | - |Observations | 32 | 32 | - ---- - - Code - display(out, format = "tt") - Output - - +--------------+----------------------+----------------------+ - | Parameter | m1 | m2 | - +==============+======================+======================+ - | (Intercept) | 27.48 (23.43, 31.53) | 27.48 (23.43, 31.53) | - +--------------+----------------------+----------------------+ - | gear (3) | 0.00 | 0.00 | - +--------------+----------------------+----------------------+ - | gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | - +--------------+----------------------+----------------------+ - | gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | - +--------------+----------------------+----------------------+ - | am (0) | 0.00 | 0.00 | - +--------------+----------------------+----------------------+ - | am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | - +--------------+----------------------+----------------------+ - | hp | -0.06 (-0.09, -0.04) | -0.06 (-0.09, -0.04) | - +--------------+----------------------+----------------------+ - | | | | - +--------------+----------------------+----------------------+ - | Observations | 32 | 32 | - +--------------+----------------------+----------------------+ - -# include_reference, different contrasts - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------- - (Intercept) | 19.70 | 1.18 | [ 17.28, 22.11] | 16.71 | < .001 - cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 - cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 - gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------- - (Intercept) | 25.43 | 1.88 | [ 21.57, 29.29] | 13.52 | < .001 - cyl [4] | 0.00 | | | | - cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 - cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 - gear [3] | 0.00 | | | | - gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 - gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------- - (Intercept) | 20.64 | 0.67 | [ 19.26, 22.01] | 30.76 | < .001 - cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 - cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 - gear [1] | -0.94 | 1.09 | [ -3.18, 1.30] | -0.86 | 0.396 - gear [2] | 0.38 | 1.11 | [ -1.90, 2.67] | 0.34 | 0.734 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 15.83 | 1.24 | [13.28, 18.37] | 12.75 | < .001 - cyl [8] | 0.00 | | | | - cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 - cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 - gear [1] | -0.94 | 1.09 | [-3.18, 1.30] | -0.86 | 0.396 - gear [2] | 0.38 | 1.11 | [-1.90, 2.67] | 0.34 | 0.734 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(out) - Output - Parameter | Coefficient | SE | 95% CI | t(27) | p - ------------------------------------------------------------------ - (Intercept) | 14.89 | 0.92 | [13.00, 16.77] | 16.19 | < .001 - cyl [8] | 0.00 | | | | - cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 - cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 - gear [3] | 0.00 | | | | - gear [4] | 1.32 | 1.93 | [-2.63, 5.28] | 0.69 | 0.498 - gear [5] | 1.50 | 1.85 | [-2.31, 5.31] | 0.81 | 0.426 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - -# include_reference, random effects models - - Code - print(out) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------------------- - (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 - flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 - island [Biscoe] | 1.00 | | | | - island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 - island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 - - # Random Effects - - Parameter | Coefficient | 95% CI - ------------------------------------------------ - SD (Intercept: year) | 3.05e-05 | [0.00, Inf] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(out, include_reference = TRUE) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------------------- - (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 - flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 - island [Biscoe] | 1.00 | | | | - island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 - island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 - - # Random Effects - - Parameter | Coefficient | 95% CI - ------------------------------------------------ - SD (Intercept: year) | 3.05e-05 | [0.00, Inf] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(out) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------------------- - (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 - flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 - island [Biscoe] | 1.00 | | | | - island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 - island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/ivreg.md b/tests/testthat/_snaps/ivreg.md deleted file mode 100644 index 9d4941d5e..000000000 --- a/tests/testthat/_snaps/ivreg.md +++ /dev/null @@ -1,20 +0,0 @@ -# print-model_parameters - - Code - tmp - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | t(45) | p - -------------------------------------------------------------------- - (Intercept) | 9.89 | 1.06 | [ 7.76, 12.03] | 9.35 | < .001 - rprice [log] | -1.28 | 0.26 | [-1.81, -0.75] | -4.85 | < .001 - rincome [log] | 0.28 | 0.24 | [-0.20, 0.76] | 1.18 | 0.246 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - - The model has a log-transformed response variable. Consider using - `exponentiate = TRUE` to interpret coefficients as ratios. - diff --git a/tests/testthat/_snaps/lcmm.md b/tests/testthat/_snaps/lcmm.md deleted file mode 100644 index d74cb291d..000000000 --- a/tests/testthat/_snaps/lcmm.md +++ /dev/null @@ -1,257 +0,0 @@ -# model_parameters lcmm - - Code - print(model_parameters(out$mx_linear), zap_small = TRUE) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------------------- - intercept class1 | 1.12 | 0.90 | [ -0.64, 2.89] | 1.25 | 0.211 - intercept class2 | 1.19 | 0.74 | [ -0.26, 2.65] | 1.61 | 0.107 - X1 class1 | 1.85 | 13.74 | [ -25.08, 28.77] | 0.13 | 0.893 - X1 class2 | 4.12 | 12.32 | [ -20.03, 28.26] | 0.33 | 0.738 - X2 class1 | 10.50 | 2079.25 | [-4064.75, 4085.74] | 0.01 | 0.996 - X2 class2 | 9.64 | 2078.80 | [-4064.73, 4084.02] | 0.00 | 0.996 - X3 class1 | -0.60 | 0.90 | [ -2.36, 1.17] | -0.66 | 0.508 - X3 class2 | 0.12 | 0.55 | [ -0.95, 1.19] | 0.23 | 0.822 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - - The model has a log- or logit-link. Consider using `exponentiate = - TRUE` to interpret coefficients as ratios. - - Some coefficients are very large, which may indicate issues with - complete separation. - ---- - - Code - print(model_parameters(out$mx_beta), zap_small = TRUE) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - ----------------------------------------------------------------------- - intercept class1 | 0.12 | 67.86 | [-132.89, 133.13] | 0.00 | 0.999 - intercept class2 | 1.55 | 35.86 | [ -68.73, 71.83] | 0.04 | 0.966 - X1 class1 | 0.51 | 24.20 | [ -46.92, 47.94] | 0.02 | 0.983 - X1 class2 | -1.02 | 26.22 | [ -52.41, 50.36] | -0.04 | 0.969 - X2 class1 | 15.95 | 14.97 | [ -13.39, 45.28] | 1.07 | 0.287 - X2 class2 | 15.44 | 9.01 | [ -2.22, 33.09] | 1.71 | 0.087 - X3 class1 | 0.44 | 14.56 | [ -28.09, 28.97] | 0.03 | 0.976 - X3 class2 | -0.35 | 18.61 | [ -36.81, 36.12] | -0.02 | 0.985 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$mx_splines), zap_small = TRUE) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------------------- - intercept class1 | -1.46 | 0.83 | [ -3.09, 0.17] | -1.75 | 0.080 - intercept class2 | -1.53 | 0.83 | [ -3.16, 0.11] | -1.83 | 0.067 - X1 class1 | 1.58 | 0.71 | [ 0.18, 2.97] | 2.22 | 0.027 - X1 class2 | 0.86 | 1.83 | [ -2.73, 4.45] | 0.47 | 0.639 - X2 class1 | 0.47 | 0.98 | [ -1.44, 2.38] | 0.48 | 0.631 - X2 class2 | -21.31 | 1194.95 | [-2363.38, 2320.75] | -0.02 | 0.986 - X3 class1 | 0.80 | 0.38 | [ 0.05, 1.54] | 2.10 | 0.036 - X3 class2 | 0.30 | 0.63 | [ -0.95, 1.54] | 0.47 | 0.638 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m1_linear), zap_small = TRUE) - Output - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Time | -0.78 | 0.19 | [-1.15, -0.40] | -4.09 | < .001 - I(Time^2) | -0.18 | 0.08 | [-0.33, -0.04] | -2.44 | 0.015 - - # linear - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------------------- - Linear 1 (intercept) | 25.40 | 0.23 | [24.96, 25.85] | 112.34 | < .001 - Linear 2 (std err) | 2.24 | 0.04 | [ 2.15, 2.33] | 50.37 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m1_beta), zap_small = TRUE) - Output - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Time | -0.88 | 0.19 | [-1.25, -0.51] | -4.62 | < .001 - I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.34 | 0.180 - - # beta - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Beta1 | 0.54 | 0.07 | [ 0.41, 0.68] | 7.97 | < .001 - Beta2 | -0.76 | 0.09 | [-0.94, -0.58] | -8.36 | < .001 - Beta3 | 0.70 | 0.02 | [ 0.67, 0.74] | 42.20 | < .001 - Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 20.53 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m1_splines), zap_small = TRUE) - Output - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Time | -0.89 | 0.19 | [-1.26, -0.52] | -4.68 | < .001 - I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.28 | 0.200 - - # splines - - Parameter | Coefficient | SE | 95% CI | z | p - ------------------------------------------------------------------ - I-splines1 | -7.76 | 0.59 | [-8.92, -6.59] | -13.04 | < .001 - I-splines2 | 0.76 | 0.28 | [ 0.21, 1.31] | 2.71 | 0.007 - I-splines3 | 0.81 | 0.41 | [ 0.00, 1.63] | 1.96 | 0.049 - I-splines4 | 1.44 | 0.13 | [ 1.18, 1.70] | 10.85 | < .001 - I-splines5 | -1.67 | 0.06 | [-1.80, -1.54] | -25.86 | < .001 - I-splines6 | 1.62 | 0.05 | [ 1.52, 1.72] | 32.56 | < .001 - I-splines7 | 1.30 | 0.05 | [ 1.20, 1.40] | 25.33 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m2_linear), zap_small = TRUE) - Output - # membership - - Parameter | Coefficient | SE | 95% CI | z | p - -------------------------------------------------------------------- - intercept class1 | 1.69 | 0.95 | [-0.18, 3.56] | 1.77 | 0.076 - intercept class2 | 2.47 | 0.79 | [ 0.91, 4.02] | 3.11 | 0.002 - - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------------- - intercept class2 | 0.68 | 0.33 | [ 0.03, 1.32] | 2.06 | 0.039 - intercept class3 | -0.63 | 0.68 | [-1.97, 0.70] | -0.93 | 0.353 - Time class1 | -1.12 | 0.56 | [-2.21, -0.03] | -2.01 | 0.045 - Time class2 | -0.37 | 0.25 | [-0.86, 0.13] | -1.44 | 0.151 - Time class3 | -2.90 | 1.48 | [-5.80, 0.00] | -1.96 | 0.050 - I(Time^2) class1 | -0.52 | 0.24 | [-0.98, -0.06] | -2.21 | 0.027 - I(Time^2) class2 | -0.15 | 0.09 | [-0.34, 0.03] | -1.67 | 0.094 - I(Time^2) class3 | 0.79 | 0.70 | [-0.59, 2.18] | 1.13 | 0.260 - - # linear - - Parameter | Coefficient | SE | 95% CI | z | p - --------------------------------------------------------------------------- - Linear 1 (intercept) | 24.46 | 0.60 | [23.28, 25.64] | 40.56 | < .001 - Linear 2 (std err) | 2.23 | 0.04 | [ 2.14, 2.32] | 50.22 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m2_beta), zap_small = TRUE) - Output - # membership - - Parameter | Coefficient | SE | 95% CI | z | p - -------------------------------------------------------------------- - intercept class1 | 0.93 | 1.48 | [-1.97, 3.83] | 0.63 | 0.531 - intercept class2 | 1.36 | 1.10 | [-0.79, 3.51] | 1.24 | 0.214 - - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ----------------------------------------------------------------------- - intercept class2 | -0.54 | 0.44 | [-1.41, 0.33] | -1.22 | 0.221 - intercept class3 | -0.99 | 0.64 | [-2.25, 0.27] | -1.54 | 0.123 - Time class1 | -0.52 | 0.67 | [-1.83, 0.79] | -0.77 | 0.438 - Time class2 | -1.68 | 0.33 | [-2.32, -1.04] | -5.14 | < .001 - Time class3 | 1.61 | 1.09 | [-0.52, 3.74] | 1.48 | 0.138 - I(Time^2) class1 | 0.02 | 0.23 | [-0.43, 0.47] | 0.07 | 0.943 - I(Time^2) class2 | -0.07 | 0.13 | [-0.33, 0.20] | -0.50 | 0.618 - I(Time^2) class3 | -0.69 | 0.39 | [-1.46, 0.09] | -1.74 | 0.082 - - # beta - - Parameter | Coefficient | SE | 95% CI | z | p - ---------------------------------------------------------------- - Beta1 | 0.60 | 0.06 | [ 0.48, 0.73] | 9.34 | < .001 - Beta2 | -0.83 | 0.09 | [-1.01, -0.66] | -9.39 | < .001 - Beta3 | 0.73 | 0.03 | [ 0.67, 0.80] | 22.27 | < .001 - Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 21.88 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(out$m2_splines), zap_small = TRUE) - Output - # membership - - Parameter | Coefficient | SE | 95% CI | z | p - --------------------------------------------------------------------- - intercept class1 | -0.46 | 0.45 | [-1.33, 0.42] | -1.01 | 0.310 - intercept class2 | -1.40 | 1.06 | [-3.48, 0.68] | -1.32 | 0.186 - - # longitudinal - - Parameter | Coefficient | SE | 95% CI | z | p - ----------------------------------------------------------------------- - intercept class2 | -1.03 | 0.67 | [-2.34, 0.27] | -1.55 | 0.121 - intercept class3 | -0.55 | 0.41 | [-1.36, 0.26] | -1.34 | 0.182 - Time class1 | -0.48 | 0.59 | [-1.63, 0.67] | -0.81 | 0.415 - Time class2 | 1.65 | 1.10 | [-0.50, 3.80] | 1.50 | 0.133 - Time class3 | -1.72 | 0.32 | [-2.35, -1.09] | -5.36 | < .001 - I(Time^2) class1 | 0.01 | 0.20 | [-0.38, 0.40] | 0.03 | 0.972 - I(Time^2) class2 | -0.70 | 0.40 | [-1.49, 0.08] | -1.76 | 0.078 - I(Time^2) class3 | -0.04 | 0.13 | [-0.30, 0.22] | -0.33 | 0.743 - - # splines - - Parameter | Coefficient | SE | 95% CI | z | p - ------------------------------------------------------------------ - I-splines1 | -7.87 | 0.62 | [-9.09, -6.66] | -12.67 | < .001 - I-splines2 | 0.72 | 0.27 | [ 0.20, 1.24] | 2.70 | 0.007 - I-splines3 | 0.77 | 0.41 | [-0.03, 1.57] | 1.88 | 0.060 - I-splines4 | 1.37 | 0.13 | [ 1.11, 1.63] | 10.35 | < .001 - I-splines5 | -1.66 | 0.06 | [-1.79, -1.54] | -25.77 | < .001 - I-splines6 | 1.64 | 0.05 | [ 1.54, 1.73] | 33.01 | < .001 - I-splines7 | 1.28 | 0.05 | [ 1.18, 1.39] | 24.94 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/mipo.md b/tests/testthat/_snaps/mipo.md deleted file mode 100644 index ba22deb84..000000000 --- a/tests/testthat/_snaps/mipo.md +++ /dev/null @@ -1,42 +0,0 @@ -# param ordinal - - Code - print(mp) - Output - # 6 response - - Parameter | Coefficient | SE | 95% CI | Statistic | df | p - -------------------------------------------------------------------------------- - (Intercept) | -54.29 | 46.90 | [-151.05, 42.46] | -1.16 | 24.19 | 0.258 - disp | 0.22 | 0.39 | [ -0.58, 1.02] | 0.58 | 23.81 | 0.570 - hp | 0.20 | 0.57 | [ -0.97, 1.38] | 0.36 | 23.73 | 0.724 - - # 8 response - - Parameter | Coefficient | SE | 95% CI | Statistic | df | p - -------------------------------------------------------------------------------- - (Intercept) | -92.86 | 67.62 | [-232.47, 46.75] | -1.37 | 23.87 | 0.182 - disp | 0.26 | 0.40 | [ -0.57, 1.09] | 0.64 | 23.53 | 0.528 - hp | 0.43 | 0.63 | [ -0.88, 1.73] | 0.67 | 24.15 | 0.507 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald distribution approximation. - -# param normal - - Code - print(mp) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | Statistic | df | p - ---------------------------------------------------------------------------------- - (Intercept) | 30.65 | 1.43 | [27.72, 33.58] | 21.46 | 26.96 | < .001 - disp | -0.03 | 7.52e-03 | [-0.05, -0.02] | -4.40 | 25.57 | < .001 - hp | -0.02 | 0.01 | [-0.05, 0.01] | -1.37 | 24.82 | 0.182 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald distribution approximation. - diff --git a/tests/testthat/_snaps/model_parameters.anova.md b/tests/testthat/_snaps/model_parameters.anova.md index da9f8cd8f..5fad54b2d 100644 --- a/tests/testthat/_snaps/model_parameters.anova.md +++ b/tests/testthat/_snaps/model_parameters.anova.md @@ -26,33 +26,3 @@ Anova Table (Type 3 tests) -# anova survey - - Code - print(model_parameters(out)) - Output - # Fixed Effects - - Parameter | DEff | Chi2(1) | df (error) | p - ----------------------------------------------- - ell | 0.77 | 1.13 | 38 | 0.236 - meals | 1.24 | 4.82 | 37 | 0.058 - ell:meals | 1.48 | 16.52 | 36 | 0.002 - - Anova Table (Type 1 tests) - ---- - - Code - print(model_parameters(out)) - Output - # Fixed Effects - - Parameter | df | df (error) | F | p - ------------------------------------------ - ell | 1 | 38 | 1.47 | 0.234 - meals | 1 | 37 | 3.54 | 0.068 - ell:meals | 1 | 36 | 9.10 | 0.005 - - Anova Table (Type 1 tests) - diff --git a/tests/testthat/_snaps/model_parameters.fixest.md b/tests/testthat/_snaps/model_parameters.fixest.md index e7c7c527b..59cc0556c 100644 --- a/tests/testthat/_snaps/model_parameters.fixest.md +++ b/tests/testthat/_snaps/model_parameters.fixest.md @@ -15,28 +15,3 @@ RMSE : 10.069 r2: 0.743; ar2: 0.613; wr2: 0.180; war2: 0.175 -# model_parameters works for fixest-negbin - - Code - print(out) - Output - # Fixed Effects - - Parameter | Log-Mean | SE | 95% CI | t(636) | p - ---------------------------------------------------------------- - (Intercept) | -1.46 | 0.21 | [-1.86, -1.06] | -7.11 | < .001 - mined [no] | 2.04 | 0.15 | [ 1.75, 2.33] | 13.72 | < .001 - spp [PR] | -1.23 | 0.29 | [-1.80, -0.65] | -4.20 | < .001 - spp [DM] | 0.40 | 0.23 | [-0.05, 0.86] | 1.75 | 0.080 - spp [EC-A] | -0.67 | 0.26 | [-1.18, -0.16] | -2.60 | 0.010 - spp [EC-L] | 0.64 | 0.22 | [ 0.20, 1.07] | 2.89 | 0.004 - spp [DES-L] | 0.82 | 0.22 | [ 0.38, 1.26] | 3.69 | < .001 - spp [DF] | 0.36 | 0.24 | [-0.10, 0.82] | 1.52 | 0.128 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - - The model has a log- or logit-link. Consider using `exponentiate = - TRUE` to interpret coefficients as ratios. - diff --git a/tests/testthat/_snaps/model_parameters.fixest_multi.md b/tests/testthat/_snaps/model_parameters.fixest_multi.md deleted file mode 100644 index 82362a7f2..000000000 --- a/tests/testthat/_snaps/model_parameters.fixest_multi.md +++ /dev/null @@ -1,160 +0,0 @@ -# model_parameters.fixest_multi - - Code - print(model_parameters(mod)) - Output - # Petal.Width ~ x - - Parameter | Coefficient | SE | 95% CI | t(146) | p - --------------------------------------------------------------- - x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 - - # Sepal.Width ~ x - - Parameter | Coefficient | SE | 95% CI | t(146) | p - --------------------------------------------------------------- - x | 0.05 | 0.03 | [-0.01, 0.10] | 1.56 | 0.120 - - # Petal.Width ~ x + Petal.Length - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 - Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 - - # Sepal.Width ~ x + Petal.Length - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 - Petal.Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 - - # Petal.Width ~ x + Petal.Length + Sepal.Length - - Parameter | Coefficient | SE | 95% CI | t(144) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 - Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 - Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 - - # Sepal.Width ~ x + Petal.Length + Sepal.Length - - Parameter | Coefficient | SE | 95% CI | t(144) | p - ------------------------------------------------------------------- - x | 0.03 | 0.03 | [-0.02, 0.09] | 1.37 | 0.171 - Petal.Length | -0.04 | 0.08 | [-0.21, 0.13] | -0.45 | 0.651 - Sepal.Length | 0.37 | 0.07 | [ 0.23, 0.51] | 5.23 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(ci(mod)) - Output - Parameter CI CI_low CI_high Response - 1 x 0.95 -0.01929491 0.05165987 Petal.Width - 2 x 0.95 -0.01715341 0.04515343 Petal.Width - 3 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width - 4 x 0.95 -0.01722960 0.04542622 Petal.Width - 5 Petal.Length 0.95 0.12908917 0.33808245 Petal.Width - 6 Sepal.Length 0.95 -0.09172321 0.08324053 Petal.Width - 7 x 0.95 -0.01227870 0.10484812 Sepal.Width - 8 x 0.95 -0.01093910 0.09787861 Sepal.Width - 9 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width - 10 x 0.95 -0.01527889 0.08504860 Sepal.Width - 11 Petal.Length 0.95 -0.20565718 0.12899281 Sepal.Width - 12 Sepal.Length 0.95 0.23032902 0.51048930 Sepal.Width - Group - 1 x - 2 x + Petal.Length - 3 x + Petal.Length - 4 x + Petal.Length + Sepal.Length - 5 x + Petal.Length + Sepal.Length - 6 x + Petal.Length + Sepal.Length - 7 x - 8 x + Petal.Length - 9 x + Petal.Length - 10 x + Petal.Length + Sepal.Length - 11 x + Petal.Length + Sepal.Length - 12 x + Petal.Length + Sepal.Length - ---- - - Code - print(model_parameters(mod)) - Output - # Petal.Width response - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 - Petal Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 - - # Sepal.Width response - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 - Petal Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(ci(mod)) - Output - Parameter CI CI_low CI_high Response - 1 x 0.95 -0.01715341 0.04515343 Petal.Width - 2 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width - 3 x 0.95 -0.01093910 0.09787861 Sepal.Width - 4 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width - ---- - - Code - print(model_parameters(mod)) - Output - # x - - Parameter | Coefficient | SE | 95% CI | t(146) | p - --------------------------------------------------------------- - x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 - - # x + Petal.Length - - Parameter | Coefficient | SE | 95% CI | t(145) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 - Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 - - # x + Petal.Length + Sepal.Length - - Parameter | Coefficient | SE | 95% CI | t(144) | p - ------------------------------------------------------------------- - x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 - Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 - Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(ci(mod)) - Output - Parameter CI CI_low CI_high Group - 1 x 0.95 -0.01929491 0.05165987 x - 2 x 0.95 -0.01715341 0.04515343 x + Petal.Length - 3 Petal.Length 0.95 0.16163902 0.29786840 x + Petal.Length - 4 x 0.95 -0.01722960 0.04542622 x + Petal.Length + Sepal.Length - 5 Petal.Length 0.95 0.12908917 0.33808245 x + Petal.Length + Sepal.Length - 6 Sepal.Length 0.95 -0.09172321 0.08324053 x + Petal.Length + Sepal.Length - diff --git a/tests/testthat/_snaps/model_parameters.mclogit.md b/tests/testthat/_snaps/model_parameters.mclogit.md deleted file mode 100644 index 5db8ac5a9..000000000 --- a/tests/testthat/_snaps/model_parameters.mclogit.md +++ /dev/null @@ -1,80 +0,0 @@ -# model_parameters.mclogit - - Code - params - Output - Parameter | Log-Odds | SE | 95% CI | z | p - -------------------------------------------------------------- - distance | -1.44 | 0.05 | [-1.54, -1.34] | -27.07 | < .001 - cost | -0.98 | 0.04 | [-1.06, -0.90] | -24.52 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# model_parameters.mblogit - - Code - params - Output - # Response level: medium - - Parameter | Log-Odds | SE | 95% CI | z | p - ----------------------------------------------------------------- - (Intercept) | -0.42 | 0.17 | [-0.76, -0.08] | -2.42 | 0.015 - InflMedium | 0.45 | 0.14 | [ 0.17, 0.72] | 3.15 | 0.002 - InflHigh | 0.66 | 0.19 | [ 0.30, 1.03] | 3.57 | < .001 - TypeApartment | -0.44 | 0.17 | [-0.77, -0.10] | -2.53 | 0.012 - TypeAtrium | 0.13 | 0.22 | [-0.31, 0.57] | 0.59 | 0.556 - TypeTerrace | -0.67 | 0.21 | [-1.07, -0.26] | -3.23 | 0.001 - ContHigh | 0.36 | 0.13 | [ 0.10, 0.62] | 2.73 | 0.006 - - # Response level: high - - Parameter | Log-Odds | SE | 95% CI | z | p - ----------------------------------------------------------------- - (Intercept) | -0.14 | 0.16 | [-0.45, 0.17] | -0.87 | 0.384 - InflMedium | 0.73 | 0.14 | [ 0.47, 1.00] | 5.37 | < .001 - InflHigh | 1.61 | 0.17 | [ 1.29, 1.94] | 9.65 | < .001 - TypeApartment | -0.74 | 0.16 | [-1.04, -0.43] | -4.74 | < .001 - TypeAtrium | -0.41 | 0.21 | [-0.82, 0.01] | -1.93 | 0.054 - TypeTerrace | -1.41 | 0.20 | [-1.80, -1.02] | -7.06 | < .001 - ContHigh | 0.48 | 0.12 | [ 0.24, 0.73] | 3.88 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# simulate_parameters.mblogit - - Code - params - Output - # Medium response - - Parameter | Coefficient | 95% CI | p - ----------------------------------------------------- - (Intercept) | -0.41 | [-0.75, -0.10] | 0.016 - InflMedium | 0.44 | [ 0.18, 0.71] | < .001 - InflHigh | 0.66 | [ 0.34, 1.03] | < .001 - TypeApartment | -0.44 | [-0.79, -0.10] | 0.008 - TypeAtrium | 0.12 | [-0.28, 0.58] | 0.582 - TypeTerrace | -0.66 | [-1.09, -0.28] | 0.004 - ContHigh | 0.36 | [ 0.11, 0.61] | < .001 - - # High response - - Parameter | Coefficient | 95% CI | p - ----------------------------------------------------- - (Intercept) | -0.13 | [-0.43, 0.16] | 0.378 - InflMedium | 0.73 | [ 0.45, 0.98] | < .001 - InflHigh | 1.61 | [ 1.29, 1.94] | < .001 - TypeApartment | -0.73 | [-1.05, -0.44] | < .001 - TypeAtrium | -0.41 | [-0.82, 0.01] | 0.054 - TypeTerrace | -1.42 | [-1.81, -1.03] | < .001 - ContHigh | 0.47 | [ 0.22, 0.73] | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a MCMC distribution approximation. - diff --git a/tests/testthat/_snaps/plm.md b/tests/testthat/_snaps/plm.md deleted file mode 100644 index 8490ec38b..000000000 --- a/tests/testthat/_snaps/plm.md +++ /dev/null @@ -1,34 +0,0 @@ -# vcov standard errors - - Code - print(model_parameters(ran)) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | df | p - ----------------------------------------------------------------------------- - (Intercept) | 817.10 | 188.26 | [445.84, 1188.36] | 4.34 | 197 | < .001 - capital | -0.58 | 0.15 | [ -0.88, -0.29] | -3.95 | 197 | < .001 - inv | 2.92 | 0.30 | [ 2.33, 3.51] | 9.80 | 197 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(model_parameters(ran, vcov = "HC1")) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | df | p - ---------------------------------------------------------------------------- - (Intercept) | 817.10 | 274.75 | [275.28, 1358.92] | 2.97 | 197 | 0.003 - capital | -0.58 | 0.43 | [ -1.43, 0.26] | -1.37 | 197 | 0.173 - inv | 2.92 | 0.89 | [ 1.16, 4.67] | 3.28 | 197 | 0.001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/print_AER_labels.md b/tests/testthat/_snaps/print_AER_labels.md deleted file mode 100644 index 92b571b63..000000000 --- a/tests/testthat/_snaps/print_AER_labels.md +++ /dev/null @@ -1,19 +0,0 @@ -# templates - - Code - print(mp, pretty_names = "labels") - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | p - ----------------------------------------------------------------------------------------------- - (Intercept) | 8.72 | 3.45 | [ 1.95, 15.48] | 2.52 | 0.012 - elder's dependency [slightly dependent] | -1.00 | 3.61 | [-8.08, 6.08] | -0.28 | 0.782 - elder's dependency [moderately dependent] | 2.68 | 3.06 | [-3.32, 8.68] | 0.88 | 0.381 - elder's dependency [severely dependent] | 3.88 | 3.00 | [-2.01, 9.77] | 1.29 | 0.197 - carer's level of education | 1.14 | 0.90 | [-0.62, 2.90] | 1.27 | 0.204 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/sampleSelection.md b/tests/testthat/_snaps/sampleSelection.md deleted file mode 100644 index d2eef03be..000000000 --- a/tests/testthat/_snaps/sampleSelection.md +++ /dev/null @@ -1,71 +0,0 @@ -# model_parameters - - Code - print(model_parameters(m1), zap_small = TRUE, table_width = Inf) - Output - # selection - - Parameter | Coefficient | SE | 95% CI | t(490) | p - ------------------------------------------------------------------ - (Intercept) | -0.15 | 0.11 | [-0.36, 0.05] | -1.47 | 0.141 - xs | 1.14 | 0.18 | [ 0.79, 1.49] | 6.39 | < .001 - - # outcome - - Parameter | Coefficient | SE | 95% CI | t(490) | p - ------------------------------------------------------------------ - (Intercept) | 0.03 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 - xo1 | 0.84 | 0.15 | [ 0.55, 1.13] | 5.61 | < .001 - (Intercept) | 0.16 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 - xo2 | 0.84 | 0.17 | [ 0.50, 1.17] | 4.91 | < .001 - - # Auxiliary - - Parameter | Coefficient | SE | 95% CI | t(490) | p - ---------------------------------------------------------------- - sigma1 | 0.93 | 0.09 | [ 0.75, 1.11] | 10.12 | < .001 - rho1 | 0.89 | 0.05 | [ 0.78, 1.00] | 16.62 | < .001 - sigma2 | 0.91 | 0.04 | [ 0.82, 0.99] | 20.45 | < .001 - rho2 | 0.18 | 0.33 | [-0.47, 0.83] | 0.53 | 0.594 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - ---- - - Code - print(model_parameters(m2), zap_small = TRUE, table_width = Inf) - Output - # selection - - Parameter | Coefficient | SE | 95% CI | t(740) | p - ------------------------------------------------------------------- - (Intercept) | -4.12 | 1.40 | [-6.87, -1.37] | -2.94 | 0.003 - age | 0.18 | 0.07 | [ 0.05, 0.31] | 2.79 | 0.005 - age^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -3.12 | 0.002 - faminc | 0.00 | 0.00 | [ 0.00, 0.00] | 1.29 | 0.199 - kidsTRUE | -0.45 | 0.13 | [-0.71, -0.20] | -3.46 | < .001 - educ | 0.10 | 0.02 | [ 0.05, 0.14] | 4.12 | < .001 - - # outcome - - Parameter | Coefficient | SE | 95% CI | t(740) | p - ------------------------------------------------------------------ - (Intercept) | -1.96 | 1.20 | [-4.32, 0.39] | -1.64 | 0.102 - exper | 0.03 | 0.06 | [-0.09, 0.15] | 0.45 | 0.651 - exper^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -0.06 | 0.955 - educ | 0.46 | 0.07 | [ 0.31, 0.60] | 6.24 | < .001 - city | 0.45 | 0.32 | [-0.17, 1.07] | 1.41 | 0.158 - - # Auxiliary - - Parameter | Coefficient | SE | 95% CI | t(740) | p - ---------------------------------------------------------------- - sigma | 3.11 | 0.11 | [ 2.88, 3.33] | 27.31 | < .001 - rho | -0.13 | 0.17 | [-0.46, 0.19] | -0.80 | 0.424 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - diff --git a/tests/testthat/_snaps/serp.md b/tests/testthat/_snaps/serp.md deleted file mode 100644 index e92edd9bf..000000000 --- a/tests/testthat/_snaps/serp.md +++ /dev/null @@ -1,24 +0,0 @@ -# model_parameters.serp - - Code - suppressMessages(print(mp)) - Output - Parameter | Log-Odds | SE | 95% CI | z | p - ------------------------------------------------------------------------------ - (Intercept):1 | 1.40 | 0.54 | [ 0.33, 2.46] | 2.57 | 0.010 - (Intercept):2 | -1.13 | 0.51 | [-2.13, -0.12] | -2.19 | 0.028 - (Intercept):3 | -3.44 | 0.71 | [-4.84, -2.04] | -4.82 | < .001 - (Intercept):4 | -4.98 | 0.95 | [-6.85, -3.11] | -5.23 | < .001 - tempwarm:1 | 2.38 | 0.81 | [ 0.79, 3.97] | 2.93 | 0.003 - tempwarm:2 | 2.26 | 0.71 | [ 0.87, 3.66] | 3.18 | 0.001 - tempwarm:3 | 2.41 | 0.77 | [ 0.89, 3.92] | 3.11 | 0.002 - tempwarm:4 | 2.51 | 0.88 | [ 0.79, 4.23] | 2.85 | 0.004 - contactyes:1 | 1.38 | 0.74 | [-0.08, 2.84] | 1.85 | 0.064 - contactyes:2 | 1.35 | 0.67 | [ 0.03, 2.66] | 2.01 | 0.044 - contactyes:3 | 1.35 | 0.76 | [-0.13, 2.83] | 1.78 | 0.075 - contactyes:4 | 1.22 | 0.86 | [-0.46, 2.89] | 1.42 | 0.156 - temp [warm] * contactyes:1 | 0.37 | 1.12 | [-1.82, 2.56] | 0.33 | 0.741 - temp [warm] * contactyes:2 | 0.35 | 1.03 | [-1.66, 2.37] | 0.34 | 0.730 - temp [warm] * contactyes:3 | 0.36 | 0.97 | [-1.55, 2.26] | 0.37 | 0.713 - temp [warm] * contactyes:4 | 0.32 | 1.02 | [-1.68, 2.33] | 0.32 | 0.751 - diff --git a/tests/testthat/_snaps/svylme.md b/tests/testthat/_snaps/svylme.md deleted file mode 100644 index b00a05ce8..000000000 --- a/tests/testthat/_snaps/svylme.md +++ /dev/null @@ -1,26 +0,0 @@ -# model_parameters svylme - - Code - print(mp) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | t | p - -------------------------------------------------------------------- - (Intercept) | -60.98 | 34.48 | [-128.57, 6.61] | -1.77 | 0.077 - ell | 0.92 | 0.26 | [ 0.41, 1.42] | 3.56 | < .001 - mobility | -0.38 | 0.24 | [ -0.85, 0.08] | -1.60 | 0.109 - api99 | 1.10 | 0.03 | [ 1.03, 1.17] | 31.44 | < .001 - - # Random Effects - - Parameter | Coefficient - ----------------------------------- - SD (Intercept: dnum1) | 1.19 - SD (api99: dnum2) | 1.39e-03 - SD (Residual) | 20.00 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution approximation. - diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg deleted file mode 100644 index c8cbe8996..000000000 --- a/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - -Coefficient -Parameter - - - - - - - -0 -10 -20 -30 -40 -50 - - - - - -gear -cyl -wt -(Intercept) - - - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg deleted file mode 100644 index 82b6c824b..000000000 --- a/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - -Coefficient -Parameter - - - - - - - -0 -10 -20 -30 -40 -50 - - - - - -wt -cyl -gear -(Intercept) - - - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg deleted file mode 100644 index d394670ba..000000000 --- a/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - -Odds Ratio -Parameter - - - - - - -0e+00 -1e+17 -2e+17 -3e+17 -4e+17 - - - - -hp -wt -(Intercept) - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/weightit.md b/tests/testthat/_snaps/weightit.md deleted file mode 100644 index b5964c1f6..000000000 --- a/tests/testthat/_snaps/weightit.md +++ /dev/null @@ -1,51 +0,0 @@ -# weightit, multinom - - Code - print(model_parameters(fit4, exponentiate = TRUE), zap_small = TRUE) - Output - # Response level: 2 - - Parameter | Odds Ratio | SE | 95% CI | z | p - -------------------------------------------------------------- - (Intercept) | 1.00 | 0.62 | [0.30, 3.39] | 0.00 | 0.998 - treat | 1.08 | 0.25 | [0.68, 1.71] | 0.31 | 0.755 - age | 0.97 | 0.01 | [0.95, 0.99] | -2.38 | 0.018 - educ | 0.98 | 0.05 | [0.89, 1.08] | -0.33 | 0.738 - - # Response level: 3 - - Parameter | Odds Ratio | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | 0.05 | 0.04 | [0.01, 0.20] | -4.23 | < .001 - treat | 1.18 | 0.29 | [0.73, 1.91] | 0.67 | 0.502 - age | 1.00 | 0.01 | [0.98, 1.02] | -0.01 | 0.989 - educ | 1.20 | 0.06 | [1.08, 1.33] | 3.51 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# weightit, ordinal - - Code - print(model_parameters(fit5, exponentiate = TRUE), zap_small = TRUE) - Output - # Fixed Effects - - Parameter | Odds Ratio | SE | 95% CI | z | p - ------------------------------------------------------------ - treat | 1.12 | 0.21 | [0.78, 1.61] | 0.60 | 0.549 - age | 0.99 | 0.01 | [0.97, 1.01] | -0.78 | 0.436 - educ | 1.11 | 0.04 | [1.03, 1.20] | 2.70 | 0.007 - - # Intercept - - Parameter | Odds Ratio | SE | 95% CI | z | p - ------------------------------------------------------------- - 1|2 | 3.28 | 1.70 | [1.19, 9.04] | 2.30 | 0.022 - 2|3 | 9.84 | 5.03 | [3.61, 26.82] | 4.47 | < .001 - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/wrs2.md b/tests/testthat/_snaps/wrs2.md deleted file mode 100644 index c57bd2a96..000000000 --- a/tests/testthat/_snaps/wrs2.md +++ /dev/null @@ -1,11 +0,0 @@ -# model_parameters.mcp and robtab - - Code - print(df_b, table_width = Inf) - Output - Group1 | Group2 | Psihat | 95% CI | p - ------------------------------------------------- - placebo | low | -1 | [-5.32, 3.32] | 0.435 - placebo | high | -3 | [-7.32, 1.32] | 0.181 - low | high | -2 | [-6.32, 2.32] | 0.317 - From cd0395c9b2ffce730a1843dfb3d32ffc205e078f Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 15 Oct 2026 16:00:29 +0200 Subject: [PATCH 22/33] updates --- R/methods_cplm.R | 102 +++---- R/methods_lme4.R | 4 +- man/dominance_analysis.Rd | 8 + .../equivalence_test/equivalence-test-1.svg | 70 +++++ .../equivalence_test/equivalence-test-2.svg | 73 +++++ .../equivalence_test/equivalence-test-3.svg | 93 ++++++ .../equivalence_test/equivalence-test-4.svg | 93 ++++++ .../equivalence_test/equivalence-test-5.svg | 93 ++++++ tests/testthat/_snaps/glmmTMB.new.md | 279 ------------------ tests/testthat/_snaps/include_reference.md | 245 +++++++++++++++ tests/testthat/_snaps/ivreg.md | 20 ++ tests/testthat/_snaps/lcmm.md | 257 ++++++++++++++++ tests/testthat/_snaps/mipo.md | 42 +++ .../testthat/_snaps/model_parameters.anova.md | 30 ++ .../_snaps/model_parameters.fixest.md | 25 ++ .../_snaps/model_parameters.fixest_multi.md | 160 ++++++++++ .../_snaps/model_parameters.mclogit.md | 80 +++++ tests/testthat/_snaps/plm.md | 34 +++ tests/testthat/_snaps/print_AER_labels.md | 19 ++ tests/testthat/_snaps/sampleSelection.md | 71 +++++ tests/testthat/_snaps/serp.md | 24 ++ tests/testthat/_snaps/svylme.md | 26 ++ .../_snaps/tinyplot/tinyplot-forest-1.svg | 63 ++++ .../_snaps/tinyplot/tinyplot-forest-2.svg | 63 ++++ .../tinyplot-forest-exponentiated.svg | 57 ++++ tests/testthat/_snaps/weightit.md | 51 ++++ tests/testthat/_snaps/wrs2.md | 11 + tests/testthat/test-glmer.R | 8 +- tests/testthat/test-lmerTest.R | 6 +- 29 files changed, 1768 insertions(+), 339 deletions(-) create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg create mode 100644 tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg delete mode 100644 tests/testthat/_snaps/glmmTMB.new.md create mode 100644 tests/testthat/_snaps/include_reference.md create mode 100644 tests/testthat/_snaps/ivreg.md create mode 100644 tests/testthat/_snaps/lcmm.md create mode 100644 tests/testthat/_snaps/mipo.md create mode 100644 tests/testthat/_snaps/model_parameters.fixest_multi.md create mode 100644 tests/testthat/_snaps/model_parameters.mclogit.md create mode 100644 tests/testthat/_snaps/plm.md create mode 100644 tests/testthat/_snaps/print_AER_labels.md create mode 100644 tests/testthat/_snaps/sampleSelection.md create mode 100644 tests/testthat/_snaps/serp.md create mode 100644 tests/testthat/_snaps/svylme.md create mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg create mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg create mode 100644 tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg create mode 100644 tests/testthat/_snaps/weightit.md create mode 100644 tests/testthat/_snaps/wrs2.md diff --git a/R/methods_cplm.R b/R/methods_cplm.R index 5e950a724..505334e35 100644 --- a/R/methods_cplm.R +++ b/R/methods_cplm.R @@ -1,9 +1,7 @@ # classes: .cpglm, .bcpglm, .zcpglm, .cpglmm - ########## .zcpglm --------------- - #' @title Parameters from Zero-Inflated Models #' @name model_parameters.zcpglm #' @@ -68,23 +66,31 @@ #' model_parameters(model) #' @return A data frame of indices related to the model's parameters. #' @export -model_parameters.zcpglm <- function(model, - ci = 0.95, - bootstrap = FALSE, - iterations = 1000, - component = "all", - standardize = NULL, - exponentiate = FALSE, - p_adjust = NULL, - include_info = getOption("parameters_info", FALSE), - keep = NULL, - drop = NULL, - verbose = TRUE, - ...) { - component <- insight::validate_argument(component, c("all", "conditional", "zi", "zero_inflated")) +model_parameters.zcpglm <- function( + model, + ci = 0.95, + bootstrap = FALSE, + iterations = 1000, + component = "all", + standardize = NULL, + exponentiate = FALSE, + p_adjust = NULL, + include_info = getOption("parameters_info", FALSE), + keep = NULL, + drop = NULL, + verbose = TRUE, + ... +) { + component <- insight::validate_argument( + component, + c("all", "conditional", "zi", "zero_inflated") + ) # fix argument, if model has no zi-part - if (!insight::model_info(model, verbose = FALSE)$is_zero_inflated && component != "conditional") { + if ( + !insight::model_info(model, verbose = FALSE)$is_zero_inflated && + component != "conditional" + ) { component <- "conditional" } @@ -200,10 +206,7 @@ p_value.cpglm <- function(model, ...) { junk <- utils::capture.output(stats <- cplm::summary(model)$coefficients) # nolint params <- insight::get_parameters(model) - .data_frame( - Parameter = params$Parameter, - p = as.vector(stats[, "Pr(>|t|)"]) - ) + .data_frame(Parameter = params$Parameter, p = as.vector(stats[, "Pr(>|t|)"])) } @@ -214,32 +217,31 @@ standard_error.cpglm <- function(model, ...) { junk <- utils::capture.output(stats <- cplm::summary(model)$coefficients) # nolint params <- insight::get_parameters(model) - .data_frame( - Parameter = params$Parameter, - SE = as.vector(stats[, "Std. Error"]) - ) + .data_frame(Parameter = params$Parameter, SE = as.vector(stats[, "Std. Error"])) } ########## .cpglmm --------------- #' @export -model_parameters.cpglmm <- function(model, - ci = 0.95, - ci_method = NULL, - ci_random = NULL, - bootstrap = FALSE, - iterations = 1000, - standardize = NULL, - effects = "all", - group_level = FALSE, - exponentiate = FALSE, - p_adjust = NULL, - include_sigma = FALSE, - keep = NULL, - drop = NULL, - verbose = TRUE, - ...) { +model_parameters.cpglmm <- function( + model, + ci = 0.95, + ci_method = NULL, + ci_random = NULL, + bootstrap = FALSE, + iterations = 1000, + standardize = NULL, + effects = "all", + group_level = FALSE, + exponentiate = FALSE, + p_adjust = NULL, + include_sigma = FALSE, + keep = NULL, + drop = NULL, + verbose = TRUE, + ... +) { # p-values, CI and se might be based on different df-methods ci_method <- .check_df_method(ci_method) effects <- insight::validate_argument(effects, c("fixed", "random", "all")) @@ -247,7 +249,9 @@ model_parameters.cpglmm <- function(model, # standardize only works for fixed effects... if (!is.null(standardize) && standardize != "refit") { if (!missing(effects) && effects != "fixed" && verbose) { - insight::format_alert("Standardizing coefficients only works for fixed effects of the mixed model.") + insight::format_alert( + "Standardizing coefficients only works for fixed effects of the mixed model." + ) } effects <- "fixed" } @@ -292,10 +296,7 @@ standard_error.cpglmm <- function(model, ...) { stats <- cplm::summary(model)$coefs params <- insight::get_parameters(model) - .data_frame( - Parameter = params$Parameter, - SE = as.vector(stats[, "Std. Error"]) - ) + .data_frame(Parameter = params$Parameter, SE = as.vector(stats[, "Std. Error"])) } @@ -305,15 +306,14 @@ standard_error.cpglmm <- function(model, ...) { if (!is.null(df_method)) { df_method <- tolower(df_method) if (df_method %in% c("satterthwaite", "kenward", "kr")) { - insight::format_alert("Satterthwaite or Kenward-Rogers approximation of degrees of freedom is only available for linear mixed models.") + insight::format_alert( + "Satterthwaite or Kenward-Rogers approximation of degrees of freedom is only available for linear mixed models." + ) df_method <- "wald" } df_method <- insight::validate_argument( df_method, - c( - "wald", "normal", "residual", "ml1", "betwithin", "profile", - "boot", "uniroot" - ) + c("wald", "normal", "residual", "ml1", "betwithin", "profile", "boot", "uniroot") ) } df_method diff --git a/R/methods_lme4.R b/R/methods_lme4.R index be660b087..48f62d919 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -267,7 +267,9 @@ se_mixed_default <- function(model) { fallback = "wald", bootstrap = FALSE ) { - is_right_class <- inherits(model, "lmerMod") && !inherits(model, c("blmerMod", "wblm")) + is_right_class <- inherits(model, "lmerMod") && + !inherits(model, c("blmerMod", "wblm", "rlmerMod")) + if (!is.null(method) || !is_right_class || effects == "random" || bootstrap) { return(method) } diff --git a/man/dominance_analysis.Rd b/man/dominance_analysis.Rd index dcb8c00a7..048c1fe9f 100644 --- a/man/dominance_analysis.Rd +++ b/man/dominance_analysis.Rd @@ -35,6 +35,14 @@ analysis and the R2 value associated with them is subtracted from the overall value. Predictors in \code{all} must be present in the model submitted to the \code{model} argument and cannot be in the \code{sets} argument.} +\item{conditional}{Logical. If \code{FALSE} then conditional dominance matrix is not computed. + +If conditional dominance is not desired as an importance criterion, avoiding computing the conditional dominance matrix can save computation time.} + +\item{complete}{Logical. If \code{FALSE} then complete dominance matrix is not computed. + +If complete dominance is not desired as an importance criterion, avoiding computing complete dominance designations can save computation time.} + \item{quote_args}{A character vector of arguments in the model submitted to \code{model} to \code{quote()} prior to submitting to the dominance analysis. This is necessary for data masked arguments (e.g., \code{weights}) to prevent them diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg new file mode 100644 index 000000000..533976c27 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-1.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Speciesvirginica +Speciesversicolor + + + + + + +0.0 +0.5 +1.0 +1.5 + +Equivalence + + + +Rejected +Equivalence-Test 1 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg new file mode 100644 index 000000000..a987aae10 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-2.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Speciesvirginica +Speciesversicolor + + + + + + + +-100 +-75 +-50 +-25 +0 + +Equivalence + + + +Rejected +Equivalence-Test 2 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg new file mode 100644 index 000000000..f6d783bb3 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-3.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +cyl8 +cyl6 +gear5 +gear4 +hp + + + + + + + + + +-5 +0 +5 +10 + +Equivalence + + + + + + + + + +Accepted +Rejected +Undecided +Equivalence-Test 3 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg new file mode 100644 index 000000000..6f6c286e7 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-4.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +cyl8 +cyl6 +gear5 +gear4 +hp + + + + + + + + + +-5 +0 +5 +10 + +Equivalence + + + + + + + + + +Accepted +Rejected +Undecided +Equivalence-Test 4 + + diff --git a/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg b/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg new file mode 100644 index 000000000..5a9d29a42 --- /dev/null +++ b/tests/testthat/_snaps/equivalence_test/equivalence-test-5.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +cyl8 +cyl6 +gear5 +gear4 +hp + + + + + + + + + +-5 +0 +5 +10 + +Equivalence + + + + + + + + + +Accepted +Rejected +Undecided +Equivalence-Test 5 + + diff --git a/tests/testthat/_snaps/glmmTMB.new.md b/tests/testthat/_snaps/glmmTMB.new.md deleted file mode 100644 index 32cb6690f..000000000 --- a/tests/testthat/_snaps/glmmTMB.new.md +++ /dev/null @@ -1,279 +0,0 @@ -# print-model_parameters glmmTMB - - Code - out[-5] - Output - [1] "# Fixed Effects" - [2] "" - [3] "Parameter | Log-Mean | SE | 95% CI | z | p" - [4] "----------------------------------------------------------------" - [5] "child | -1.04 | 0.09 | [-1.22, -0.87] | -11.60 | < .001" - [6] "camper [1] | 0.27 | 0.09 | [ 0.09, 0.44] | 2.98 | 0.003 " - -# print-model_parameters glmmTMB digits - - Code - out[-c(5, 14)] - Output - [1] "# Fixed Effects (Count Model)" - [2] "" - [3] "Parameter | Log-Mean | SE | 95% CI | z | p" - [4] "--------------------------------------------------------------------------" - [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" - [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " - [7] "" - [8] "# Fixed Effects (Zero-Inflation Component)" - [9] "" - [10] "Parameter | Log-Odds | SE | 95% CI | z | p" - [11] "--------------------------------------------------------------------------" - [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" - [13] "camper [1] | -4.8291 | | | | " - [14] "" - [15] "# Random Effects Variances" - [16] "" - [17] "Parameter | Coefficient | 95% CI" - [18] "----------------------------------------------------------------" - [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" - [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" - [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" - [22] "" - [23] "# Random Effects (Zero-Inflation Component)" - [24] "" - [25] "Parameter | Coefficient | 95% CI" - [26] "----------------------------------------------------------------" - [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" - [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" - [29] "Cor (Intercept~zg: persons) | 0.9790 | " - ---- - - Code - out[-c(5, 14)] - Output - [1] "# Fixed Effects (Count Model)" - [2] "" - [3] "Parameter | Log-Mean | SE | 95% CI | z | p" - [4] "--------------------------------------------------------------------------" - [5] "child | -1.0426 | 0.0899 | [-1.21880, -0.86643] | -11.5987 | < .001" - [6] "camper [1] | 0.2684 | 0.0901 | [ 0.09185, 0.44497] | 2.9796 | 0.003 " - [7] "" - [8] "# Fixed Effects (Zero-Inflation Component)" - [9] "" - [10] "Parameter | Log-Odds | SE | 95% CI | z | p" - [11] "--------------------------------------------------------------------------" - [12] "(Intercept) | -4.0420 | 0.1879 | [-4.41029, -3.67375] | -21.5121 | < .001" - [13] "camper [1] | -4.8291 | | | | " - [14] "" - [15] "# Random Effects Variances" - [16] "" - [17] "Parameter | Coefficient | 95% CI" - [18] "----------------------------------------------------------------" - [19] "SD (Intercept: persons) | 2.1800 | [ 1.13254, 4.19608]" - [20] "SD (xb: persons) | 1.0592 | [ 0.62152, 1.80504]" - [21] "Cor (Intercept~xb: persons) | -0.9883 | [-0.98931, -0.98711]" - [22] "" - [23] "# Random Effects (Zero-Inflation Component)" - [24] "" - [25] "Parameter | Coefficient | 95% CI" - [26] "----------------------------------------------------------------" - [27] "SD (Intercept: persons) | 5.8635 | [ 4.03715, 8.51616]" - [28] "SD (zg: persons) | 12.5180 | [11.43048, 13.70902]" - [29] "Cor (Intercept~zg: persons) | 0.9790 | " - -# print-model_parameters glmmTMB CI alignment - - Code - print(mp) - Output - # Random Effects: conditional - - Parameter | Coefficient | 95% CI - ---------------------------------------------------------------- - SD (Intercept: Session:Participant) | 0.27 | [0.08, 0.87] - SD (Intercept: Participant) | 0.38 | [0.16, 0.92] - - # Random Effects: zero_inflated - - Parameter | Coefficient | 95% CI - ---------------------------------------------------------------- - SD (Intercept: Session:Participant) | 0.69 | [0.40, 1.19] - SD (Intercept: Participant) | 2.39 | [1.25, 4.57] - Message - - Uncertainty intervals for random effect variances computed using a - Wald z-distribution approximation. - ---- - - Code - print(mp) - Output - # Fixed Effects - - Parameter | Log-Mean | SE | 95% CI | z | p - --------------------------------------------------------------------- - (Intercept) | 2.12 | 0.30 | [ 1.53, 2.71] | 7.05 | < .001 - Surface [Lingual] | 0.01 | 0.29 | [-0.56, 0.58] | 0.04 | 0.971 - Surface [Occlusal] | 0.54 | 0.22 | [ 0.10, 0.98] | 2.43 | 0.015 - Side [Anterior] | 0.04 | 0.32 | [-0.58, 0.66] | 0.14 | 0.889 - Side [Left] | -0.04 | 0.20 | [-0.44, 0.37] | -0.17 | 0.862 - Jaw [Maxillar] | -0.10 | 0.21 | [-0.51, 0.30] | -0.51 | 0.612 - - # Zero-Inflation - - Parameter | Log-Odds | SE | 95% CI | z | p - ---------------------------------------------------------------------- - (Intercept) | 4.87 | 0.93 | [ 3.04, 6.69] | 5.23 | < .001 - Surface [Lingual] | 0.93 | 0.34 | [ 0.27, 1.60] | 2.75 | 0.006 - Surface [Occlusal] | -1.01 | 0.29 | [-1.59, -0.44] | -3.45 | < .001 - Side [Anterior] | -0.20 | 0.37 | [-0.93, 0.52] | -0.55 | 0.583 - Side [Left] | -0.38 | 0.27 | [-0.91, 0.14] | -1.44 | 0.151 - Jaw [Maxillar] | 0.59 | 0.24 | [ 0.11, 1.07] | 2.42 | 0.016 - - # Dispersion - - Parameter | Coefficient | 95% CI - ---------------------------------------- - (Intercept) | 2.06 | [1.30, 3.27] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - -# print-model_parameters - - Code - mp - Output - # Fixed Effects - - Parameter | Log-Mean | SE | 95% CI | z | p - ---------------------------------------------------------------- - (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 - child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 - camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 - - # Zero-Inflation - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 - child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 - camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 - ---- - - Code - mp - Output - # Fixed Effects - - Parameter | IRR | SE | 95% CI | z | p - ---------------------------------------------------------- - (Intercept) | 3.54 | 1.68 | [1.39, 8.98] | 2.66 | 0.008 - child | 0.32 | 0.03 | [0.27, 0.38] | -12.27 | < .001 - camper [1] | 2.08 | 0.19 | [1.73, 2.50] | 7.85 | < .001 - - # Zero-Inflation - - Parameter | Odds Ratio | SE | 95% CI | z | p - ---------------------------------------------------------------- - (Intercept) | 0.68 | 0.44 | [0.19, 2.43] | -0.60 | 0.551 - child | 7.80 | 2.42 | [4.25, 14.32] | 6.63 | < .001 - camper [1] | 0.36 | 0.12 | [0.19, 0.69] | -3.12 | 0.002 - ---- - - Code - mp - Output - # Fixed Effects (Count Model) - - Parameter | Log-Mean | SE | 95% CI | z | p - ---------------------------------------------------------------- - (Intercept) | 1.26 | 0.48 | [ 0.33, 2.19] | 2.66 | 0.008 - child | -1.14 | 0.09 | [-1.32, -0.96] | -12.27 | < .001 - camper [1] | 0.73 | 0.09 | [ 0.55, 0.92] | 7.85 | < .001 - - # Fixed Effects (Zero-Inflation Component) - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -0.39 | 0.65 | [-1.67, 0.89] | -0.60 | 0.551 - child | 2.05 | 0.31 | [ 1.45, 2.66] | 6.63 | < .001 - camper [1] | -1.01 | 0.32 | [-1.64, -0.37] | -3.12 | 0.002 - - # Random Effects Variances - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 0.93 | [0.46, 1.89] - - # Random Effects (Zero-Inflation Component) - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 1.17 | [0.54, 2.57] - -# robust SE/VCOV - - Code - print(out, table_width = Inf) - Output - # Fixed Effects (Count Model) - - Parameter | Log-Mean | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | 1.26 | 0.46 | [ 0.36, 2.17] | 2.74 | 0.006 - child | -1.14 | 0.30 | [-1.73, -0.55] | -3.80 | < .001 - camper [1] | 0.73 | 0.41 | [-0.06, 1.53] | 1.80 | 0.072 - - # Fixed Effects (Zero-Inflation Component) - - Parameter | Log-Odds | SE | 95% CI | z | p - --------------------------------------------------------------- - (Intercept) | -0.39 | 0.58 | [-1.52, 0.75] | -0.67 | 0.501 - child | 2.05 | 0.39 | [ 1.30, 2.81] | 5.33 | < .001 - camper [1] | -1.01 | 0.39 | [-1.77, -0.24] | -2.59 | 0.010 - - # Random Effects Variances - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 0.93 | [0.46, 1.89] - - # Random Effects (Zero-Inflation Component) - - Parameter | Coefficient | 95% CI - ---------------------------------------------------- - SD (Intercept: persons) | 1.17 | [0.54, 2.57] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - ---- - - Code - print(out, table_width = Inf) - Output - # Fixed Effects - - Parameter | Coefficient | SE | 95% CI | z | p - -------------------------------------------------------------------- - (Intercept) | 251.40 | 6.28 | [239.09, 263.72] | 40.02 | < .001 - Days | 10.47 | 1.45 | [ 7.63, 13.31] | 7.23 | < .001 - - # Random Effects - - Parameter | Coefficient | 95% CI - ------------------------------------------------------------ - SD (Intercept: Subject) | 23.78 | [15.02, 37.66] - SD (Days: Subject) | 5.72 | [ 3.81, 8.59] - Cor (Intercept~Days: Subject) | 0.08 | [-0.49, 0.59] - SD (Residual) | 25.59 | [22.80, 28.72] - Message - - Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald z-distribution approximation. - diff --git a/tests/testthat/_snaps/include_reference.md b/tests/testthat/_snaps/include_reference.md new file mode 100644 index 000000000..aa2d2b4b9 --- /dev/null +++ b/tests/testthat/_snaps/include_reference.md @@ -0,0 +1,245 @@ +# include_reference, on-the-fly factors + + Code + print(out1) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 + gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 + am [0] | 0.00 | | | | + am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 + hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out2) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 27.48 | 1.97 | [23.43, 31.53] | 13.92 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 0.08 | 1.83 | [-3.68, 3.83] | 0.04 | 0.967 + gear [5] | 2.39 | 2.38 | [-2.50, 7.29] | 1.00 | 0.324 + am [0] | 0.00 | | | | + am [1] | 4.14 | 1.81 | [ 0.42, 7.85] | 2.29 | 0.030 + hp | -0.06 | 0.01 | [-0.09, -0.04] | -6.24 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print_md(out) + Output + + + |Parameter | m1 | m2 | + |:------------|:--------------------|:--------------------| + |(Intercept) |27.48 (23.43, 31.53) |27.48 (23.43, 31.53) | + |gear (3) | 0.00 | 0.00 | + |gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | + |gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | + |am (0) | 0.00 | 0.00 | + |am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | + |hp |-0.06 (-0.09, -0.04) |-0.06 (-0.09, -0.04) | + | | | | + |Observations | 32 | 32 | + +--- + + Code + display(out, format = "tt") + Output + + +--------------+----------------------+----------------------+ + | Parameter | m1 | m2 | + +==============+======================+======================+ + | (Intercept) | 27.48 (23.43, 31.53) | 27.48 (23.43, 31.53) | + +--------------+----------------------+----------------------+ + | gear (3) | 0.00 | 0.00 | + +--------------+----------------------+----------------------+ + | gear (4) | 0.08 (-3.68, 3.83) | 0.08 (-3.68, 3.83) | + +--------------+----------------------+----------------------+ + | gear (5) | 2.39 (-2.50, 7.29) | 2.39 (-2.50, 7.29) | + +--------------+----------------------+----------------------+ + | am (0) | 0.00 | 0.00 | + +--------------+----------------------+----------------------+ + | am (1) | 4.14 ( 0.42, 7.85) | 4.14 ( 0.42, 7.85) | + +--------------+----------------------+----------------------+ + | hp | -0.06 (-0.09, -0.04) | -0.06 (-0.09, -0.04) | + +--------------+----------------------+----------------------+ + | | | | + +--------------+----------------------+----------------------+ + | Observations | 32 | 32 | + +--------------+----------------------+----------------------+ + +# include_reference, different contrasts + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------- + (Intercept) | 19.70 | 1.18 | [ 17.28, 22.11] | 16.71 | < .001 + cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 + cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 + gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------- + (Intercept) | 25.43 | 1.88 | [ 21.57, 29.29] | 13.52 | < .001 + cyl [4] | 0.00 | | | | + cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 + cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 + gear [3] | 0.00 | | | | + gear [4] | 1.32 | 1.93 | [ -2.63, 5.28] | 0.69 | 0.498 + gear [5] | 1.50 | 1.85 | [ -2.31, 5.31] | 0.81 | 0.426 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------- + (Intercept) | 20.64 | 0.67 | [ 19.26, 22.01] | 30.76 | < .001 + cyl [6] | -6.66 | 1.63 | [-10.00, -3.31] | -4.09 | < .001 + cyl [8] | -10.54 | 1.96 | [-14.56, -6.52] | -5.38 | < .001 + gear [1] | -0.94 | 1.09 | [ -3.18, 1.30] | -0.86 | 0.396 + gear [2] | 0.38 | 1.11 | [ -1.90, 2.67] | 0.34 | 0.734 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 15.83 | 1.24 | [13.28, 18.37] | 12.75 | < .001 + cyl [8] | 0.00 | | | | + cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 + cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 + gear [1] | -0.94 | 1.09 | [-3.18, 1.30] | -0.86 | 0.396 + gear [2] | 0.38 | 1.11 | [-1.90, 2.67] | 0.34 | 0.734 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(out) + Output + Parameter | Coefficient | SE | 95% CI | t(27) | p + ------------------------------------------------------------------ + (Intercept) | 14.89 | 0.92 | [13.00, 16.77] | 16.19 | < .001 + cyl [8] | 0.00 | | | | + cyl [4] | 10.54 | 1.96 | [ 6.52, 14.56] | 5.38 | < .001 + cyl [6] | 3.89 | 1.88 | [ 0.03, 7.75] | 2.07 | 0.049 + gear [3] | 0.00 | | | | + gear [4] | 1.32 | 1.93 | [-2.63, 5.28] | 0.69 | 0.498 + gear [5] | 1.50 | 1.85 | [-2.31, 5.31] | 0.81 | 0.426 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +# include_reference, random effects models + + Code + print(out) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------------------- + (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 + flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 + island [Biscoe] | 1.00 | | | | + island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 + island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 + + # Random Effects + + Parameter | Coefficient | 95% CI + ------------------------------------------------ + SD (Intercept: year) | 3.05e-05 | [0.00, Inf] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(out, include_reference = TRUE) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------------------- + (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 + flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 + island [Biscoe] | 1.00 | | | | + island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 + island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 + + # Random Effects + + Parameter | Coefficient | 95% CI + ------------------------------------------------ + SD (Intercept: year) | 3.05e-05 | [0.00, Inf] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(out) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------------------- + (Intercept) | 1.81e-06 | 4.52e-06 | [0.00, 0.00] | -5.29 | < .001 + flipper len | 1.07 | 0.01 | [1.04, 1.09] | 5.33 | < .001 + island [Biscoe] | 1.00 | | | | + island [Dream] | 2.84 | 0.93 | [1.49, 5.41] | 3.18 | 0.001 + island [Torgersen] | 2.97 | 1.22 | [1.32, 6.65] | 2.64 | 0.008 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/ivreg.md b/tests/testthat/_snaps/ivreg.md new file mode 100644 index 000000000..9d4941d5e --- /dev/null +++ b/tests/testthat/_snaps/ivreg.md @@ -0,0 +1,20 @@ +# print-model_parameters + + Code + tmp + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | t(45) | p + -------------------------------------------------------------------- + (Intercept) | 9.89 | 1.06 | [ 7.76, 12.03] | 9.35 | < .001 + rprice [log] | -1.28 | 0.26 | [-1.81, -0.75] | -4.85 | < .001 + rincome [log] | 0.28 | 0.24 | [-0.20, 0.76] | 1.18 | 0.246 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + + The model has a log-transformed response variable. Consider using + `exponentiate = TRUE` to interpret coefficients as ratios. + diff --git a/tests/testthat/_snaps/lcmm.md b/tests/testthat/_snaps/lcmm.md new file mode 100644 index 000000000..d74cb291d --- /dev/null +++ b/tests/testthat/_snaps/lcmm.md @@ -0,0 +1,257 @@ +# model_parameters lcmm + + Code + print(model_parameters(out$mx_linear), zap_small = TRUE) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------------------- + intercept class1 | 1.12 | 0.90 | [ -0.64, 2.89] | 1.25 | 0.211 + intercept class2 | 1.19 | 0.74 | [ -0.26, 2.65] | 1.61 | 0.107 + X1 class1 | 1.85 | 13.74 | [ -25.08, 28.77] | 0.13 | 0.893 + X1 class2 | 4.12 | 12.32 | [ -20.03, 28.26] | 0.33 | 0.738 + X2 class1 | 10.50 | 2079.25 | [-4064.75, 4085.74] | 0.01 | 0.996 + X2 class2 | 9.64 | 2078.80 | [-4064.73, 4084.02] | 0.00 | 0.996 + X3 class1 | -0.60 | 0.90 | [ -2.36, 1.17] | -0.66 | 0.508 + X3 class2 | 0.12 | 0.55 | [ -0.95, 1.19] | 0.23 | 0.822 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + + The model has a log- or logit-link. Consider using `exponentiate = + TRUE` to interpret coefficients as ratios. + + Some coefficients are very large, which may indicate issues with + complete separation. + +--- + + Code + print(model_parameters(out$mx_beta), zap_small = TRUE) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + ----------------------------------------------------------------------- + intercept class1 | 0.12 | 67.86 | [-132.89, 133.13] | 0.00 | 0.999 + intercept class2 | 1.55 | 35.86 | [ -68.73, 71.83] | 0.04 | 0.966 + X1 class1 | 0.51 | 24.20 | [ -46.92, 47.94] | 0.02 | 0.983 + X1 class2 | -1.02 | 26.22 | [ -52.41, 50.36] | -0.04 | 0.969 + X2 class1 | 15.95 | 14.97 | [ -13.39, 45.28] | 1.07 | 0.287 + X2 class2 | 15.44 | 9.01 | [ -2.22, 33.09] | 1.71 | 0.087 + X3 class1 | 0.44 | 14.56 | [ -28.09, 28.97] | 0.03 | 0.976 + X3 class2 | -0.35 | 18.61 | [ -36.81, 36.12] | -0.02 | 0.985 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$mx_splines), zap_small = TRUE) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + --------------------------------------------------------------------------- + intercept class1 | -1.46 | 0.83 | [ -3.09, 0.17] | -1.75 | 0.080 + intercept class2 | -1.53 | 0.83 | [ -3.16, 0.11] | -1.83 | 0.067 + X1 class1 | 1.58 | 0.71 | [ 0.18, 2.97] | 2.22 | 0.027 + X1 class2 | 0.86 | 1.83 | [ -2.73, 4.45] | 0.47 | 0.639 + X2 class1 | 0.47 | 0.98 | [ -1.44, 2.38] | 0.48 | 0.631 + X2 class2 | -21.31 | 1194.95 | [-2363.38, 2320.75] | -0.02 | 0.986 + X3 class1 | 0.80 | 0.38 | [ 0.05, 1.54] | 2.10 | 0.036 + X3 class2 | 0.30 | 0.63 | [ -0.95, 1.54] | 0.47 | 0.638 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m1_linear), zap_small = TRUE) + Output + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Time | -0.78 | 0.19 | [-1.15, -0.40] | -4.09 | < .001 + I(Time^2) | -0.18 | 0.08 | [-0.33, -0.04] | -2.44 | 0.015 + + # linear + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------------------- + Linear 1 (intercept) | 25.40 | 0.23 | [24.96, 25.85] | 112.34 | < .001 + Linear 2 (std err) | 2.24 | 0.04 | [ 2.15, 2.33] | 50.37 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m1_beta), zap_small = TRUE) + Output + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Time | -0.88 | 0.19 | [-1.25, -0.51] | -4.62 | < .001 + I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.34 | 0.180 + + # beta + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Beta1 | 0.54 | 0.07 | [ 0.41, 0.68] | 7.97 | < .001 + Beta2 | -0.76 | 0.09 | [-0.94, -0.58] | -8.36 | < .001 + Beta3 | 0.70 | 0.02 | [ 0.67, 0.74] | 42.20 | < .001 + Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 20.53 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m1_splines), zap_small = TRUE) + Output + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Time | -0.89 | 0.19 | [-1.26, -0.52] | -4.68 | < .001 + I(Time^2) | -0.10 | 0.08 | [-0.25, 0.05] | -1.28 | 0.200 + + # splines + + Parameter | Coefficient | SE | 95% CI | z | p + ------------------------------------------------------------------ + I-splines1 | -7.76 | 0.59 | [-8.92, -6.59] | -13.04 | < .001 + I-splines2 | 0.76 | 0.28 | [ 0.21, 1.31] | 2.71 | 0.007 + I-splines3 | 0.81 | 0.41 | [ 0.00, 1.63] | 1.96 | 0.049 + I-splines4 | 1.44 | 0.13 | [ 1.18, 1.70] | 10.85 | < .001 + I-splines5 | -1.67 | 0.06 | [-1.80, -1.54] | -25.86 | < .001 + I-splines6 | 1.62 | 0.05 | [ 1.52, 1.72] | 32.56 | < .001 + I-splines7 | 1.30 | 0.05 | [ 1.20, 1.40] | 25.33 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m2_linear), zap_small = TRUE) + Output + # membership + + Parameter | Coefficient | SE | 95% CI | z | p + -------------------------------------------------------------------- + intercept class1 | 1.69 | 0.95 | [-0.18, 3.56] | 1.77 | 0.076 + intercept class2 | 2.47 | 0.79 | [ 0.91, 4.02] | 3.11 | 0.002 + + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------------- + intercept class2 | 0.68 | 0.33 | [ 0.03, 1.32] | 2.06 | 0.039 + intercept class3 | -0.63 | 0.68 | [-1.97, 0.70] | -0.93 | 0.353 + Time class1 | -1.12 | 0.56 | [-2.21, -0.03] | -2.01 | 0.045 + Time class2 | -0.37 | 0.25 | [-0.86, 0.13] | -1.44 | 0.151 + Time class3 | -2.90 | 1.48 | [-5.80, 0.00] | -1.96 | 0.050 + I(Time^2) class1 | -0.52 | 0.24 | [-0.98, -0.06] | -2.21 | 0.027 + I(Time^2) class2 | -0.15 | 0.09 | [-0.34, 0.03] | -1.67 | 0.094 + I(Time^2) class3 | 0.79 | 0.70 | [-0.59, 2.18] | 1.13 | 0.260 + + # linear + + Parameter | Coefficient | SE | 95% CI | z | p + --------------------------------------------------------------------------- + Linear 1 (intercept) | 24.46 | 0.60 | [23.28, 25.64] | 40.56 | < .001 + Linear 2 (std err) | 2.23 | 0.04 | [ 2.14, 2.32] | 50.22 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m2_beta), zap_small = TRUE) + Output + # membership + + Parameter | Coefficient | SE | 95% CI | z | p + -------------------------------------------------------------------- + intercept class1 | 0.93 | 1.48 | [-1.97, 3.83] | 0.63 | 0.531 + intercept class2 | 1.36 | 1.10 | [-0.79, 3.51] | 1.24 | 0.214 + + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------- + intercept class2 | -0.54 | 0.44 | [-1.41, 0.33] | -1.22 | 0.221 + intercept class3 | -0.99 | 0.64 | [-2.25, 0.27] | -1.54 | 0.123 + Time class1 | -0.52 | 0.67 | [-1.83, 0.79] | -0.77 | 0.438 + Time class2 | -1.68 | 0.33 | [-2.32, -1.04] | -5.14 | < .001 + Time class3 | 1.61 | 1.09 | [-0.52, 3.74] | 1.48 | 0.138 + I(Time^2) class1 | 0.02 | 0.23 | [-0.43, 0.47] | 0.07 | 0.943 + I(Time^2) class2 | -0.07 | 0.13 | [-0.33, 0.20] | -0.50 | 0.618 + I(Time^2) class3 | -0.69 | 0.39 | [-1.46, 0.09] | -1.74 | 0.082 + + # beta + + Parameter | Coefficient | SE | 95% CI | z | p + ---------------------------------------------------------------- + Beta1 | 0.60 | 0.06 | [ 0.48, 0.73] | 9.34 | < .001 + Beta2 | -0.83 | 0.09 | [-1.01, -0.66] | -9.39 | < .001 + Beta3 | 0.73 | 0.03 | [ 0.67, 0.80] | 22.27 | < .001 + Beta4 | 0.09 | 0.00 | [ 0.08, 0.10] | 21.88 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(out$m2_splines), zap_small = TRUE) + Output + # membership + + Parameter | Coefficient | SE | 95% CI | z | p + --------------------------------------------------------------------- + intercept class1 | -0.46 | 0.45 | [-1.33, 0.42] | -1.01 | 0.310 + intercept class2 | -1.40 | 1.06 | [-3.48, 0.68] | -1.32 | 0.186 + + # longitudinal + + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------- + intercept class2 | -1.03 | 0.67 | [-2.34, 0.27] | -1.55 | 0.121 + intercept class3 | -0.55 | 0.41 | [-1.36, 0.26] | -1.34 | 0.182 + Time class1 | -0.48 | 0.59 | [-1.63, 0.67] | -0.81 | 0.415 + Time class2 | 1.65 | 1.10 | [-0.50, 3.80] | 1.50 | 0.133 + Time class3 | -1.72 | 0.32 | [-2.35, -1.09] | -5.36 | < .001 + I(Time^2) class1 | 0.01 | 0.20 | [-0.38, 0.40] | 0.03 | 0.972 + I(Time^2) class2 | -0.70 | 0.40 | [-1.49, 0.08] | -1.76 | 0.078 + I(Time^2) class3 | -0.04 | 0.13 | [-0.30, 0.22] | -0.33 | 0.743 + + # splines + + Parameter | Coefficient | SE | 95% CI | z | p + ------------------------------------------------------------------ + I-splines1 | -7.87 | 0.62 | [-9.09, -6.66] | -12.67 | < .001 + I-splines2 | 0.72 | 0.27 | [ 0.20, 1.24] | 2.70 | 0.007 + I-splines3 | 0.77 | 0.41 | [-0.03, 1.57] | 1.88 | 0.060 + I-splines4 | 1.37 | 0.13 | [ 1.11, 1.63] | 10.35 | < .001 + I-splines5 | -1.66 | 0.06 | [-1.79, -1.54] | -25.77 | < .001 + I-splines6 | 1.64 | 0.05 | [ 1.54, 1.73] | 33.01 | < .001 + I-splines7 | 1.28 | 0.05 | [ 1.18, 1.39] | 24.94 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/mipo.md b/tests/testthat/_snaps/mipo.md new file mode 100644 index 000000000..ba22deb84 --- /dev/null +++ b/tests/testthat/_snaps/mipo.md @@ -0,0 +1,42 @@ +# param ordinal + + Code + print(mp) + Output + # 6 response + + Parameter | Coefficient | SE | 95% CI | Statistic | df | p + -------------------------------------------------------------------------------- + (Intercept) | -54.29 | 46.90 | [-151.05, 42.46] | -1.16 | 24.19 | 0.258 + disp | 0.22 | 0.39 | [ -0.58, 1.02] | 0.58 | 23.81 | 0.570 + hp | 0.20 | 0.57 | [ -0.97, 1.38] | 0.36 | 23.73 | 0.724 + + # 8 response + + Parameter | Coefficient | SE | 95% CI | Statistic | df | p + -------------------------------------------------------------------------------- + (Intercept) | -92.86 | 67.62 | [-232.47, 46.75] | -1.37 | 23.87 | 0.182 + disp | 0.26 | 0.40 | [ -0.57, 1.09] | 0.64 | 23.53 | 0.528 + hp | 0.43 | 0.63 | [ -0.88, 1.73] | 0.67 | 24.15 | 0.507 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald distribution approximation. + +# param normal + + Code + print(mp) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | Statistic | df | p + ---------------------------------------------------------------------------------- + (Intercept) | 30.65 | 1.43 | [27.72, 33.58] | 21.46 | 26.96 | < .001 + disp | -0.03 | 7.52e-03 | [-0.05, -0.02] | -4.40 | 25.57 | < .001 + hp | -0.02 | 0.01 | [-0.05, 0.01] | -1.37 | 24.82 | 0.182 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald distribution approximation. + diff --git a/tests/testthat/_snaps/model_parameters.anova.md b/tests/testthat/_snaps/model_parameters.anova.md index 5fad54b2d..da9f8cd8f 100644 --- a/tests/testthat/_snaps/model_parameters.anova.md +++ b/tests/testthat/_snaps/model_parameters.anova.md @@ -26,3 +26,33 @@ Anova Table (Type 3 tests) +# anova survey + + Code + print(model_parameters(out)) + Output + # Fixed Effects + + Parameter | DEff | Chi2(1) | df (error) | p + ----------------------------------------------- + ell | 0.77 | 1.13 | 38 | 0.236 + meals | 1.24 | 4.82 | 37 | 0.058 + ell:meals | 1.48 | 16.52 | 36 | 0.002 + + Anova Table (Type 1 tests) + +--- + + Code + print(model_parameters(out)) + Output + # Fixed Effects + + Parameter | df | df (error) | F | p + ------------------------------------------ + ell | 1 | 38 | 1.47 | 0.234 + meals | 1 | 37 | 3.54 | 0.068 + ell:meals | 1 | 36 | 9.10 | 0.005 + + Anova Table (Type 1 tests) + diff --git a/tests/testthat/_snaps/model_parameters.fixest.md b/tests/testthat/_snaps/model_parameters.fixest.md index 59cc0556c..e7c7c527b 100644 --- a/tests/testthat/_snaps/model_parameters.fixest.md +++ b/tests/testthat/_snaps/model_parameters.fixest.md @@ -15,3 +15,28 @@ RMSE : 10.069 r2: 0.743; ar2: 0.613; wr2: 0.180; war2: 0.175 +# model_parameters works for fixest-negbin + + Code + print(out) + Output + # Fixed Effects + + Parameter | Log-Mean | SE | 95% CI | t(636) | p + ---------------------------------------------------------------- + (Intercept) | -1.46 | 0.21 | [-1.86, -1.06] | -7.11 | < .001 + mined [no] | 2.04 | 0.15 | [ 1.75, 2.33] | 13.72 | < .001 + spp [PR] | -1.23 | 0.29 | [-1.80, -0.65] | -4.20 | < .001 + spp [DM] | 0.40 | 0.23 | [-0.05, 0.86] | 1.75 | 0.080 + spp [EC-A] | -0.67 | 0.26 | [-1.18, -0.16] | -2.60 | 0.010 + spp [EC-L] | 0.64 | 0.22 | [ 0.20, 1.07] | 2.89 | 0.004 + spp [DES-L] | 0.82 | 0.22 | [ 0.38, 1.26] | 3.69 | < .001 + spp [DF] | 0.36 | 0.24 | [-0.10, 0.82] | 1.52 | 0.128 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + + The model has a log- or logit-link. Consider using `exponentiate = + TRUE` to interpret coefficients as ratios. + diff --git a/tests/testthat/_snaps/model_parameters.fixest_multi.md b/tests/testthat/_snaps/model_parameters.fixest_multi.md new file mode 100644 index 000000000..82362a7f2 --- /dev/null +++ b/tests/testthat/_snaps/model_parameters.fixest_multi.md @@ -0,0 +1,160 @@ +# model_parameters.fixest_multi + + Code + print(model_parameters(mod)) + Output + # Petal.Width ~ x + + Parameter | Coefficient | SE | 95% CI | t(146) | p + --------------------------------------------------------------- + x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 + + # Sepal.Width ~ x + + Parameter | Coefficient | SE | 95% CI | t(146) | p + --------------------------------------------------------------- + x | 0.05 | 0.03 | [-0.01, 0.10] | 1.56 | 0.120 + + # Petal.Width ~ x + Petal.Length + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 + Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 + + # Sepal.Width ~ x + Petal.Length + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 + Petal.Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 + + # Petal.Width ~ x + Petal.Length + Sepal.Length + + Parameter | Coefficient | SE | 95% CI | t(144) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 + Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 + Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 + + # Sepal.Width ~ x + Petal.Length + Sepal.Length + + Parameter | Coefficient | SE | 95% CI | t(144) | p + ------------------------------------------------------------------- + x | 0.03 | 0.03 | [-0.02, 0.09] | 1.37 | 0.171 + Petal.Length | -0.04 | 0.08 | [-0.21, 0.13] | -0.45 | 0.651 + Sepal.Length | 0.37 | 0.07 | [ 0.23, 0.51] | 5.23 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(ci(mod)) + Output + Parameter CI CI_low CI_high Response + 1 x 0.95 -0.01929491 0.05165987 Petal.Width + 2 x 0.95 -0.01715341 0.04515343 Petal.Width + 3 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width + 4 x 0.95 -0.01722960 0.04542622 Petal.Width + 5 Petal.Length 0.95 0.12908917 0.33808245 Petal.Width + 6 Sepal.Length 0.95 -0.09172321 0.08324053 Petal.Width + 7 x 0.95 -0.01227870 0.10484812 Sepal.Width + 8 x 0.95 -0.01093910 0.09787861 Sepal.Width + 9 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width + 10 x 0.95 -0.01527889 0.08504860 Sepal.Width + 11 Petal.Length 0.95 -0.20565718 0.12899281 Sepal.Width + 12 Sepal.Length 0.95 0.23032902 0.51048930 Sepal.Width + Group + 1 x + 2 x + Petal.Length + 3 x + Petal.Length + 4 x + Petal.Length + Sepal.Length + 5 x + Petal.Length + Sepal.Length + 6 x + Petal.Length + Sepal.Length + 7 x + 8 x + Petal.Length + 9 x + Petal.Length + 10 x + Petal.Length + Sepal.Length + 11 x + Petal.Length + Sepal.Length + 12 x + Petal.Length + Sepal.Length + +--- + + Code + print(model_parameters(mod)) + Output + # Petal.Width response + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 + Petal Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 + + # Sepal.Width response + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.04 | 0.03 | [-0.01, 0.10] | 1.58 | 0.116 + Petal Length | 0.30 | 0.06 | [ 0.18, 0.42] | 4.92 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(ci(mod)) + Output + Parameter CI CI_low CI_high Response + 1 x 0.95 -0.01715341 0.04515343 Petal.Width + 2 Petal.Length 0.95 0.16163902 0.29786840 Petal.Width + 3 x 0.95 -0.01093910 0.09787861 Sepal.Width + 4 Petal.Length 0.95 0.17737594 0.41529802 Sepal.Width + +--- + + Code + print(model_parameters(mod)) + Output + # x + + Parameter | Coefficient | SE | 95% CI | t(146) | p + --------------------------------------------------------------- + x | 0.02 | 0.02 | [-0.02, 0.05] | 0.90 | 0.369 + + # x + Petal.Length + + Parameter | Coefficient | SE | 95% CI | t(145) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.376 + Petal.Length | 0.23 | 0.03 | [ 0.16, 0.30] | 6.67 | < .001 + + # x + Petal.Length + Sepal.Length + + Parameter | Coefficient | SE | 95% CI | t(144) | p + ------------------------------------------------------------------- + x | 0.01 | 0.02 | [-0.02, 0.05] | 0.89 | 0.375 + Petal.Length | 0.23 | 0.05 | [ 0.13, 0.34] | 4.42 | < .001 + Sepal.Length | -4.24e-03 | 0.04 | [-0.09, 0.08] | -0.10 | 0.924 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(ci(mod)) + Output + Parameter CI CI_low CI_high Group + 1 x 0.95 -0.01929491 0.05165987 x + 2 x 0.95 -0.01715341 0.04515343 x + Petal.Length + 3 Petal.Length 0.95 0.16163902 0.29786840 x + Petal.Length + 4 x 0.95 -0.01722960 0.04542622 x + Petal.Length + Sepal.Length + 5 Petal.Length 0.95 0.12908917 0.33808245 x + Petal.Length + Sepal.Length + 6 Sepal.Length 0.95 -0.09172321 0.08324053 x + Petal.Length + Sepal.Length + diff --git a/tests/testthat/_snaps/model_parameters.mclogit.md b/tests/testthat/_snaps/model_parameters.mclogit.md new file mode 100644 index 000000000..5db8ac5a9 --- /dev/null +++ b/tests/testthat/_snaps/model_parameters.mclogit.md @@ -0,0 +1,80 @@ +# model_parameters.mclogit + + Code + params + Output + Parameter | Log-Odds | SE | 95% CI | z | p + -------------------------------------------------------------- + distance | -1.44 | 0.05 | [-1.54, -1.34] | -27.07 | < .001 + cost | -0.98 | 0.04 | [-1.06, -0.90] | -24.52 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# model_parameters.mblogit + + Code + params + Output + # Response level: medium + + Parameter | Log-Odds | SE | 95% CI | z | p + ----------------------------------------------------------------- + (Intercept) | -0.42 | 0.17 | [-0.76, -0.08] | -2.42 | 0.015 + InflMedium | 0.45 | 0.14 | [ 0.17, 0.72] | 3.15 | 0.002 + InflHigh | 0.66 | 0.19 | [ 0.30, 1.03] | 3.57 | < .001 + TypeApartment | -0.44 | 0.17 | [-0.77, -0.10] | -2.53 | 0.012 + TypeAtrium | 0.13 | 0.22 | [-0.31, 0.57] | 0.59 | 0.556 + TypeTerrace | -0.67 | 0.21 | [-1.07, -0.26] | -3.23 | 0.001 + ContHigh | 0.36 | 0.13 | [ 0.10, 0.62] | 2.73 | 0.006 + + # Response level: high + + Parameter | Log-Odds | SE | 95% CI | z | p + ----------------------------------------------------------------- + (Intercept) | -0.14 | 0.16 | [-0.45, 0.17] | -0.87 | 0.384 + InflMedium | 0.73 | 0.14 | [ 0.47, 1.00] | 5.37 | < .001 + InflHigh | 1.61 | 0.17 | [ 1.29, 1.94] | 9.65 | < .001 + TypeApartment | -0.74 | 0.16 | [-1.04, -0.43] | -4.74 | < .001 + TypeAtrium | -0.41 | 0.21 | [-0.82, 0.01] | -1.93 | 0.054 + TypeTerrace | -1.41 | 0.20 | [-1.80, -1.02] | -7.06 | < .001 + ContHigh | 0.48 | 0.12 | [ 0.24, 0.73] | 3.88 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# simulate_parameters.mblogit + + Code + params + Output + # Medium response + + Parameter | Coefficient | 95% CI | p + ----------------------------------------------------- + (Intercept) | -0.41 | [-0.75, -0.10] | 0.016 + InflMedium | 0.44 | [ 0.18, 0.71] | < .001 + InflHigh | 0.66 | [ 0.34, 1.03] | < .001 + TypeApartment | -0.44 | [-0.79, -0.10] | 0.008 + TypeAtrium | 0.12 | [-0.28, 0.58] | 0.582 + TypeTerrace | -0.66 | [-1.09, -0.28] | 0.004 + ContHigh | 0.36 | [ 0.11, 0.61] | < .001 + + # High response + + Parameter | Coefficient | 95% CI | p + ----------------------------------------------------- + (Intercept) | -0.13 | [-0.43, 0.16] | 0.378 + InflMedium | 0.73 | [ 0.45, 0.98] | < .001 + InflHigh | 1.61 | [ 1.29, 1.94] | < .001 + TypeApartment | -0.73 | [-1.05, -0.44] | < .001 + TypeAtrium | -0.41 | [-0.82, 0.01] | 0.054 + TypeTerrace | -1.42 | [-1.81, -1.03] | < .001 + ContHigh | 0.47 | [ 0.22, 0.73] | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a MCMC distribution approximation. + diff --git a/tests/testthat/_snaps/plm.md b/tests/testthat/_snaps/plm.md new file mode 100644 index 000000000..8490ec38b --- /dev/null +++ b/tests/testthat/_snaps/plm.md @@ -0,0 +1,34 @@ +# vcov standard errors + + Code + print(model_parameters(ran)) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | df | p + ----------------------------------------------------------------------------- + (Intercept) | 817.10 | 188.26 | [445.84, 1188.36] | 4.34 | 197 | < .001 + capital | -0.58 | 0.15 | [ -0.88, -0.29] | -3.95 | 197 | < .001 + inv | 2.92 | 0.30 | [ 2.33, 3.51] | 9.80 | 197 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +--- + + Code + print(model_parameters(ran, vcov = "HC1")) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | df | p + ---------------------------------------------------------------------------- + (Intercept) | 817.10 | 274.75 | [275.28, 1358.92] | 2.97 | 197 | 0.003 + capital | -0.58 | 0.43 | [ -1.43, 0.26] | -1.37 | 197 | 0.173 + inv | 2.92 | 0.89 | [ 1.16, 4.67] | 3.28 | 197 | 0.001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/print_AER_labels.md b/tests/testthat/_snaps/print_AER_labels.md new file mode 100644 index 000000000..92b571b63 --- /dev/null +++ b/tests/testthat/_snaps/print_AER_labels.md @@ -0,0 +1,19 @@ +# templates + + Code + print(mp, pretty_names = "labels") + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------------------------------- + (Intercept) | 8.72 | 3.45 | [ 1.95, 15.48] | 2.52 | 0.012 + elder's dependency [slightly dependent] | -1.00 | 3.61 | [-8.08, 6.08] | -0.28 | 0.782 + elder's dependency [moderately dependent] | 2.68 | 3.06 | [-3.32, 8.68] | 0.88 | 0.381 + elder's dependency [severely dependent] | 3.88 | 3.00 | [-2.01, 9.77] | 1.29 | 0.197 + carer's level of education | 1.14 | 0.90 | [-0.62, 2.90] | 1.27 | 0.204 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/sampleSelection.md b/tests/testthat/_snaps/sampleSelection.md new file mode 100644 index 000000000..d2eef03be --- /dev/null +++ b/tests/testthat/_snaps/sampleSelection.md @@ -0,0 +1,71 @@ +# model_parameters + + Code + print(model_parameters(m1), zap_small = TRUE, table_width = Inf) + Output + # selection + + Parameter | Coefficient | SE | 95% CI | t(490) | p + ------------------------------------------------------------------ + (Intercept) | -0.15 | 0.11 | [-0.36, 0.05] | -1.47 | 0.141 + xs | 1.14 | 0.18 | [ 0.79, 1.49] | 6.39 | < .001 + + # outcome + + Parameter | Coefficient | SE | 95% CI | t(490) | p + ------------------------------------------------------------------ + (Intercept) | 0.03 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 + xo1 | 0.84 | 0.15 | [ 0.55, 1.13] | 5.61 | < .001 + (Intercept) | 0.16 | 0.16 | [-0.30, 0.35] | 0.17 | 0.869 + xo2 | 0.84 | 0.17 | [ 0.50, 1.17] | 4.91 | < .001 + + # Auxiliary + + Parameter | Coefficient | SE | 95% CI | t(490) | p + ---------------------------------------------------------------- + sigma1 | 0.93 | 0.09 | [ 0.75, 1.11] | 10.12 | < .001 + rho1 | 0.89 | 0.05 | [ 0.78, 1.00] | 16.62 | < .001 + sigma2 | 0.91 | 0.04 | [ 0.82, 0.99] | 20.45 | < .001 + rho2 | 0.18 | 0.33 | [-0.47, 0.83] | 0.53 | 0.594 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + +--- + + Code + print(model_parameters(m2), zap_small = TRUE, table_width = Inf) + Output + # selection + + Parameter | Coefficient | SE | 95% CI | t(740) | p + ------------------------------------------------------------------- + (Intercept) | -4.12 | 1.40 | [-6.87, -1.37] | -2.94 | 0.003 + age | 0.18 | 0.07 | [ 0.05, 0.31] | 2.79 | 0.005 + age^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -3.12 | 0.002 + faminc | 0.00 | 0.00 | [ 0.00, 0.00] | 1.29 | 0.199 + kidsTRUE | -0.45 | 0.13 | [-0.71, -0.20] | -3.46 | < .001 + educ | 0.10 | 0.02 | [ 0.05, 0.14] | 4.12 | < .001 + + # outcome + + Parameter | Coefficient | SE | 95% CI | t(740) | p + ------------------------------------------------------------------ + (Intercept) | -1.96 | 1.20 | [-4.32, 0.39] | -1.64 | 0.102 + exper | 0.03 | 0.06 | [-0.09, 0.15] | 0.45 | 0.651 + exper^2 | 0.00 | 0.00 | [ 0.00, 0.00] | -0.06 | 0.955 + educ | 0.46 | 0.07 | [ 0.31, 0.60] | 6.24 | < .001 + city | 0.45 | 0.32 | [-0.17, 1.07] | 1.41 | 0.158 + + # Auxiliary + + Parameter | Coefficient | SE | 95% CI | t(740) | p + ---------------------------------------------------------------- + sigma | 3.11 | 0.11 | [ 2.88, 3.33] | 27.31 | < .001 + rho | -0.13 | 0.17 | [-0.46, 0.19] | -0.80 | 0.424 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + diff --git a/tests/testthat/_snaps/serp.md b/tests/testthat/_snaps/serp.md new file mode 100644 index 000000000..e92edd9bf --- /dev/null +++ b/tests/testthat/_snaps/serp.md @@ -0,0 +1,24 @@ +# model_parameters.serp + + Code + suppressMessages(print(mp)) + Output + Parameter | Log-Odds | SE | 95% CI | z | p + ------------------------------------------------------------------------------ + (Intercept):1 | 1.40 | 0.54 | [ 0.33, 2.46] | 2.57 | 0.010 + (Intercept):2 | -1.13 | 0.51 | [-2.13, -0.12] | -2.19 | 0.028 + (Intercept):3 | -3.44 | 0.71 | [-4.84, -2.04] | -4.82 | < .001 + (Intercept):4 | -4.98 | 0.95 | [-6.85, -3.11] | -5.23 | < .001 + tempwarm:1 | 2.38 | 0.81 | [ 0.79, 3.97] | 2.93 | 0.003 + tempwarm:2 | 2.26 | 0.71 | [ 0.87, 3.66] | 3.18 | 0.001 + tempwarm:3 | 2.41 | 0.77 | [ 0.89, 3.92] | 3.11 | 0.002 + tempwarm:4 | 2.51 | 0.88 | [ 0.79, 4.23] | 2.85 | 0.004 + contactyes:1 | 1.38 | 0.74 | [-0.08, 2.84] | 1.85 | 0.064 + contactyes:2 | 1.35 | 0.67 | [ 0.03, 2.66] | 2.01 | 0.044 + contactyes:3 | 1.35 | 0.76 | [-0.13, 2.83] | 1.78 | 0.075 + contactyes:4 | 1.22 | 0.86 | [-0.46, 2.89] | 1.42 | 0.156 + temp [warm] * contactyes:1 | 0.37 | 1.12 | [-1.82, 2.56] | 0.33 | 0.741 + temp [warm] * contactyes:2 | 0.35 | 1.03 | [-1.66, 2.37] | 0.34 | 0.730 + temp [warm] * contactyes:3 | 0.36 | 0.97 | [-1.55, 2.26] | 0.37 | 0.713 + temp [warm] * contactyes:4 | 0.32 | 1.02 | [-1.68, 2.33] | 0.32 | 0.751 + diff --git a/tests/testthat/_snaps/svylme.md b/tests/testthat/_snaps/svylme.md new file mode 100644 index 000000000..b00a05ce8 --- /dev/null +++ b/tests/testthat/_snaps/svylme.md @@ -0,0 +1,26 @@ +# model_parameters svylme + + Code + print(mp) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | t | p + -------------------------------------------------------------------- + (Intercept) | -60.98 | 34.48 | [-128.57, 6.61] | -1.77 | 0.077 + ell | 0.92 | 0.26 | [ 0.41, 1.42] | 3.56 | < .001 + mobility | -0.38 | 0.24 | [ -0.85, 0.08] | -1.60 | 0.109 + api99 | 1.10 | 0.03 | [ 1.03, 1.17] | 31.44 | < .001 + + # Random Effects + + Parameter | Coefficient + ----------------------------------- + SD (Intercept: dnum1) | 1.19 + SD (api99: dnum2) | 1.39e-03 + SD (Residual) | 20.00 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg new file mode 100644 index 000000000..c8cbe8996 --- /dev/null +++ b/tests/testthat/_snaps/tinyplot/tinyplot-forest-1.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + +Coefficient +Parameter + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + +gear +cyl +wt +(Intercept) + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg new file mode 100644 index 000000000..82b6c824b --- /dev/null +++ b/tests/testthat/_snaps/tinyplot/tinyplot-forest-2.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + +Coefficient +Parameter + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + +wt +cyl +gear +(Intercept) + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg b/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg new file mode 100644 index 000000000..d394670ba --- /dev/null +++ b/tests/testthat/_snaps/tinyplot/tinyplot-forest-exponentiated.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + +Odds Ratio +Parameter + + + + + + +0e+00 +1e+17 +2e+17 +3e+17 +4e+17 + + + + +hp +wt +(Intercept) + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/weightit.md b/tests/testthat/_snaps/weightit.md new file mode 100644 index 000000000..b5964c1f6 --- /dev/null +++ b/tests/testthat/_snaps/weightit.md @@ -0,0 +1,51 @@ +# weightit, multinom + + Code + print(model_parameters(fit4, exponentiate = TRUE), zap_small = TRUE) + Output + # Response level: 2 + + Parameter | Odds Ratio | SE | 95% CI | z | p + -------------------------------------------------------------- + (Intercept) | 1.00 | 0.62 | [0.30, 3.39] | 0.00 | 0.998 + treat | 1.08 | 0.25 | [0.68, 1.71] | 0.31 | 0.755 + age | 0.97 | 0.01 | [0.95, 0.99] | -2.38 | 0.018 + educ | 0.98 | 0.05 | [0.89, 1.08] | -0.33 | 0.738 + + # Response level: 3 + + Parameter | Odds Ratio | SE | 95% CI | z | p + --------------------------------------------------------------- + (Intercept) | 0.05 | 0.04 | [0.01, 0.20] | -4.23 | < .001 + treat | 1.18 | 0.29 | [0.73, 1.91] | 0.67 | 0.502 + age | 1.00 | 0.01 | [0.98, 1.02] | -0.01 | 0.989 + educ | 1.20 | 0.06 | [1.08, 1.33] | 3.51 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + +# weightit, ordinal + + Code + print(model_parameters(fit5, exponentiate = TRUE), zap_small = TRUE) + Output + # Fixed Effects + + Parameter | Odds Ratio | SE | 95% CI | z | p + ------------------------------------------------------------ + treat | 1.12 | 0.21 | [0.78, 1.61] | 0.60 | 0.549 + age | 0.99 | 0.01 | [0.97, 1.01] | -0.78 | 0.436 + educ | 1.11 | 0.04 | [1.03, 1.20] | 2.70 | 0.007 + + # Intercept + + Parameter | Odds Ratio | SE | 95% CI | z | p + ------------------------------------------------------------- + 1|2 | 3.28 | 1.70 | [1.19, 9.04] | 2.30 | 0.022 + 2|3 | 9.84 | 5.03 | [3.61, 26.82] | 4.47 | < .001 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + diff --git a/tests/testthat/_snaps/wrs2.md b/tests/testthat/_snaps/wrs2.md new file mode 100644 index 000000000..c57bd2a96 --- /dev/null +++ b/tests/testthat/_snaps/wrs2.md @@ -0,0 +1,11 @@ +# model_parameters.mcp and robtab + + Code + print(df_b, table_width = Inf) + Output + Group1 | Group2 | Psihat | 95% CI | p + ------------------------------------------------- + placebo | low | -1 | [-5.32, 3.32] | 0.435 + placebo | high | -3 | [-7.32, 1.32] | 0.181 + low | high | -2 | [-6.32, 2.32] | 0.317 + diff --git a/tests/testthat/test-glmer.R b/tests/testthat/test-glmer.R index b87622736..ee55e6343 100644 --- a/tests/testthat/test-glmer.R +++ b/tests/testthat/test-glmer.R @@ -82,7 +82,6 @@ test_that("model_parameters.glmer betwithin", { test_that("robust SE/VCOV, using FPC", { skip_if(packageVersion("insight") <= "1.5.0") data(sleepstudy, package = "lme4") - data(sleepstudy, package = "lmerTest") model <- lme4::lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy) out <- standard_error(model, vcov = "fpc", vcov_args = list(population_size = 500)) expect_equal( @@ -95,11 +94,6 @@ test_that("robust SE/VCOV, using FPC", { ignore_attr = TRUE, tolerance = 1e-4 ) - out <- model_parameters( - model, - ci_method = "s", - vcov = "fpc", - vcov_args = list(population_size = 500) - ) + out <- model_parameters(model, vcov = "fpc", vcov_args = list(population_size = 500)) expect_snapshot(print(out, table_width = Inf)) }) diff --git a/tests/testthat/test-lmerTest.R b/tests/testthat/test-lmerTest.R index df8f4bdc8..6df90c781 100644 --- a/tests/testthat/test-lmerTest.R +++ b/tests/testthat/test-lmerTest.R @@ -28,7 +28,11 @@ test_that("model_parameters, kenward", { test_that("mixed-model defaults use satterthwaite for lmerMod", { params_default <- model_parameters(m1, effects = "fixed") - params_satterthwaite <- model_parameters(m1, effects = "fixed", ci_method = "s") + params_satterthwaite <- model_parameters( + m1, + effects = "fixed", + ci_method = "satterthwaite" + ) params_wald <- model_parameters(m1, effects = "fixed", ci_method = "wald") expect_identical(params_default, params_satterthwaite) From 4a7360fe2b60ee0818493615333178c1218362eb Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 15 Oct 2026 16:03:52 +0200 Subject: [PATCH 23/33] add snapshot --- tests/testthat/_snaps/glmer.md | 25 +++++++++++++++++++++++++ tests/testthat/test-glmer.R | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/tests/testthat/_snaps/glmer.md b/tests/testthat/_snaps/glmer.md index 702716130..969b57580 100644 --- a/tests/testthat/_snaps/glmer.md +++ b/tests/testthat/_snaps/glmer.md @@ -94,3 +94,28 @@ Uncertainty intervals for random effect variances computed using a Wald z-distribution approximation. +--- + + Code + print(out, table_width = Inf) + Output + # Fixed Effects + + Parameter | Coefficient | SE | 95% CI | t(174) | p + --------------------------------------------------------------------- + (Intercept) | 251.41 | 6.48 | [237.01, 265.80] | 38.77 | < .001 + Days | 10.47 | 1.49 | [ 7.21, 13.73] | 7.01 | < .001 + + # Random Effects + + Parameter | Coefficient | SE | 95% CI + ------------------------------------------------------------------- + SD (Intercept: Subject) | 24.74 | 5.84 | [15.58, 39.28] + SD (Days: Subject) | 5.92 | 1.25 | [ 3.92, 8.95] + Cor (Intercept~Days: Subject) | 0.07 | 0.32 | [-0.51, 0.60] + SD (Residual) | 25.59 | 1.51 | [22.80, 28.72] + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald t-distribution approximation. + diff --git a/tests/testthat/test-glmer.R b/tests/testthat/test-glmer.R index ee55e6343..0c5cb76c0 100644 --- a/tests/testthat/test-glmer.R +++ b/tests/testthat/test-glmer.R @@ -95,5 +95,13 @@ test_that("robust SE/VCOV, using FPC", { tolerance = 1e-4 ) out <- model_parameters(model, vcov = "fpc", vcov_args = list(population_size = 500)) + + expect_snapshot(print(out, table_width = Inf)) + out <- model_parameters( + model, + ci_method = "wald", + vcov = "fpc", + vcov_args = list(population_size = 500) + ) expect_snapshot(print(out, table_width = Inf)) }) From 64ac096d62d694d73627b5c26e9d4c8d11390c74 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 15 Oct 2026 20:02:47 +0300 Subject: [PATCH 24/33] re-add ci_random test for also including the fixef --- tests/testthat/test-random_effects_ci.R | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-random_effects_ci.R b/tests/testthat/test-random_effects_ci.R index 4f035b493..af53fb70c 100644 --- a/tests/testthat/test-random_effects_ci.R +++ b/tests/testthat/test-random_effects_ci.R @@ -30,7 +30,7 @@ m5 <- suppressMessages(lme4::lmer( expect_message( { - mp1 <- model_parameters(m1, ci_random = TRUE, effects = "random") + mp1 <- model_parameters(m1, ci_random = TRUE, ci_method = "wald") }, regex = "meaningful" ) @@ -62,6 +62,8 @@ test_that("random effects CIs, two slopes, categorical", { expect_equal( mp1$CI_low, c( + 28.7559334902632, 4.97904339539053, -1.95014363947862, -2.70058819820767, + -3.62294029941172, -2.69095690811178, 4.28813, 0.21457, 0.5742, 0.28738, 0.02089, 1e-05, 0.55402, 0, 0, 0.2781, 0.38107, 0.00945, -0.65343, -0.7222, -1, -0.99521, -0.97784, -1, -1, -1, -1, -1, -1, -0.99594, -1, -0.90229, -0.99736, @@ -75,6 +77,12 @@ test_that("random effects CIs, two slopes, categorical", { expect_identical( mp1$Parameter, c( + "(Intercept)", + "temperature.L", + "temperature.Q", + "temperature.C", + "temperature^4", + "temperature^5", "SD (Intercept)", "SD (Intercept)", "SD (temperature.L)", @@ -124,6 +132,12 @@ test_that("random effects CIs, two slopes, categorical", { expect_identical( mp1$Group, c( + "", + "", + "", + "", + "", + "", "replicate", "recipe", "replicate", From 08b89db4fb6f5c7187e03125fb6db8cf399cff6c Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Thu, 15 Oct 2026 12:29:09 -0500 Subject: [PATCH 25/33] Restore the glmgee snapshot deleted by a local test run --- .../_snaps/model_parameters.glmgee.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/testthat/_snaps/model_parameters.glmgee.md diff --git a/tests/testthat/_snaps/model_parameters.glmgee.md b/tests/testthat/_snaps/model_parameters.glmgee.md new file mode 100644 index 000000000..da1e47fb8 --- /dev/null +++ b/tests/testthat/_snaps/model_parameters.glmgee.md @@ -0,0 +1,20 @@ +# model_parameters.glmgee + + Code + print(out) + Output + # Fixed Effects + + Parameter | Log-Prevalence | SE | 95% CI | z | p + --------------------------------------------------------------------------------- + (Intercept) | 5.90 | 0.10 | [ 5.70, 6.11] | 56.30 | < .001 + days [1st degree] | 19.20 | 0.52 | [18.18, 20.22] | 37.03 | < .001 + days [2nd degree] | -2.86 | 0.21 | [-3.26, -2.45] | -13.88 | < .001 + days [3rd degree] | 5.42 | 0.18 | [ 5.06, 5.77] | 29.69 | < .001 + days [4th degree] | -3.57 | 0.12 | [-3.82, -3.33] | -28.64 | < .001 + treat [ozone-enriched] | -0.26 | 0.13 | [-0.51, -0.01] | -2.01 | 0.044 + Message + + Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed + using a Wald z-distribution approximation. + From e759d359bf84f74022f5950a8f45089676af79b4 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Fri, 16 Oct 2026 00:26:19 +0300 Subject: [PATCH 26/33] always pass ci_method --- R/extract_parameters.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/extract_parameters.R b/R/extract_parameters.R index 7eb9814d7..d875cf9bb 100644 --- a/R/extract_parameters.R +++ b/R/extract_parameters.R @@ -522,7 +522,8 @@ ci = ci, vcov = vcov, vcov_args = vcov_args, - verbose = verbose + verbose = verbose, + ci_method = ci_method ) fun_args <- c(fun_args, dots) ci_df <- suppressMessages(do.call("ci", fun_args)) From 7c7ec0bc7a8da44cbc89a38ada7ebc59b8fd7a95 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Fri, 16 Oct 2026 00:26:27 +0300 Subject: [PATCH 27/33] rewrite logic --- R/methods_lme4.R | 51 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 48f62d919..85377695e 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -118,11 +118,13 @@ model_parameters.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- model_parameters.merMod + cl$model <- .attempt_to_lmerModLmerTest(model) cl$ci_method <- .attempt_satterthwaite_method( ci_method, - model, + cl$model, effects, - bootstrap = bootstrap + bootstrap = bootstrap, + verbose = verbose ) eval.parent(cl) } @@ -142,7 +144,8 @@ ci.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- ci.merMod - cl$method <- .attempt_satterthwaite_method(method, x, effects) + cl$x <- .attempt_to_lmerModLmerTest(x) + cl$method <- .attempt_satterthwaite_method(method, cl$x, effects, verbose = verbose) eval.parent(cl) } @@ -153,11 +156,13 @@ standard_error.lmerMod <- function( method = NULL, vcov = NULL, vcov_args = NULL, + verbose = TRUE, ... ) { cl <- match.call() cl[[1]] <- standard_error.merMod - cl$method <- .attempt_satterthwaite_method(method, model, effects) + cl$model <- .attempt_to_lmerModLmerTest(model) + cl$method <- .attempt_satterthwaite_method(method, cl$model, effects, verbose = verbose) eval.parent(cl) } @@ -174,7 +179,8 @@ p_value.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- p_value.merMod - cl$method <- .attempt_satterthwaite_method(method, model, effects) + cl$model <- .attempt_to_lmerModLmerTest(model) + cl$method <- .attempt_satterthwaite_method(method, cl$model, effects, verbose = verbose) eval.parent(cl) } @@ -260,24 +266,44 @@ se_mixed_default <- function(model) { .data_frame(Parameter = params, SE = .get_se_from_summary(model)) } +.attempt_to_lmerModLmerTest <- function(model) { + if ( + inherits(model, "lmerModLmerTest") || !requireNamespace("lmerTest", quietly = TRUE) + ) { + return(model) + } + + tryCatch(lmerTest::as_lmerModLmerTest(model), error = function(e) model) +} + .attempt_satterthwaite_method <- function( method, model, effects, fallback = "wald", - bootstrap = FALSE + bootstrap = FALSE, + verbose = TRUE ) { - is_right_class <- inherits(model, "lmerMod") && - !inherits(model, c("blmerMod", "wblm", "rlmerMod")) - - if (!is.null(method) || !is_right_class || effects == "random" || bootstrap) { + # Cases where we don't want to interfere + if (!is.null(method) || effects == "random" || isTRUE(bootstrap)) { return(method) } + if (inherits(model, "lmerModLmerTest")) { + return("satterthwaite") + } + + # Then the model is DEFNITLY NOT coercible because we already tried to coerce it + if (requireNamespace("lmerTest", quietly = TRUE)) { + return(fallback) + } + + # Model is potentially coercible if lmerTest were installed? installed <- insight::check_if_installed( package = "lmerTest", reason = "for Satterthwaite df (default)", - stop = FALSE + stop = FALSE, + prompt = interactive() && isTRUE(verbose) ) # This is a workaround for the fact that check_if_installed() returns FALSE @@ -287,7 +313,8 @@ se_mixed_default <- function(model) { installed <- requireNamespace("lmerTest", quietly = TRUE) } - if (installed) { + # if lmerTest is newly installed, and the model is coercible... + if (installed && inherits(.attempt_to_lmerModLmerTest(model, "lmerModLmerTest"))) { return("satterthwaite") } From 160dabfc3e6534ce7325524cb3c6c2b2bbf89a60 Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Thu, 15 Oct 2026 17:48:36 -0500 Subject: [PATCH 28/33] Fall back to Wald when Satterthwaite df fail, and keep robust vcov in CIs - The lmerMod wrappers share one helper. It uses Satterthwaite df when no method is given and lmerTest is installed. If that fails (for example, a saved model whose data is gone), it runs the call again with the merMod default and shows a message. Errors that the default method also raises are reported unchanged. - The wrappers no longer coerce the model to lmerModLmerTest. insight::get_df() coerces it anyway, and keeping the lmerMod class restores the footer line about random effect variances. - No install prompt; the lmerTest check respects verbose. - Satterthwaite CIs now use a robust vcov when one is given, and .extract_parameters_mixed() passes ci_method as `method` to the nested ci() and p_value() calls. - The random effect variance footer also shows for lmerModLmerTest models. - Tests for robust vcov, the fallback without model data, and missing lmerTest. --- NEWS.md | 4 +- R/1_model_parameters.R | 6 +- R/ci_generic.R | 2 +- R/extract_parameters.R | 12 ++- R/format.R | 3 +- R/methods_lme4.R | 132 +++++++++++++++++--------------- man/ci.default.Rd | 6 +- man/model_parameters.Rd | 6 +- man/model_parameters.brmsfit.Rd | 6 +- man/model_parameters.default.Rd | 6 +- man/model_parameters.glmmTMB.Rd | 6 +- man/p_value.Rd | 6 +- tests/testthat/_snaps/glmer.md | 8 +- tests/testthat/test-lmerTest.R | 64 ++++++++++++++++ 14 files changed, 189 insertions(+), 78 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2f4e671ec..aef03f91f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,9 @@ * `model_parameters()`, `ci()`, `standard_error()`, and `p_value()` now default to the Satterthwaite approximation for `lmerMod` and `lmerModLmerTest` models when `{lmerTest}` is available, making the outputs more consistent with - `summary()` (#989). + `summary()` (#989). If Satterthwaite degrees of freedom cannot be computed, + for example because the model data is no longer available, these functions + fall back to the Wald method with a message. ## Changes diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index 8bddf3afd..9b0e6c89b 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -197,7 +197,11 @@ #' Wald method (SE and a *t-distribution with Satterthwaite df*); p-values #' computed using the Wald method with a *t-distribution with Satterthwaite df*. #' This is the default for `lmerMod` and `lmerModLmerTest` when the corresponding -#' method argument (`ci_method` or `method`) is `NULL`. +#' method argument (`ci_method` or `method`) is `NULL`, `bootstrap = FALSE`, +#' and `effects` is not `"random"`. It requires the *lmerTest* package. If +#' *lmerTest* is not installed, or if Satterthwaite degrees of freedom cannot +#' be computed (for example, because the data used to fit the model is no +#' longer available), the Wald method is used instead. #' #' `"kenward"` #' - Applies to *linear mixed models*. CIs computed using the Wald diff --git a/R/ci_generic.R b/R/ci_generic.R index cc94de6ea..20fe18509 100644 --- a/R/ci_generic.R +++ b/R/ci_generic.R @@ -41,7 +41,7 @@ } else if (method == "betwithin") { return(ci_betwithin(model, ci = ci)) } else if (method == "satterthwaite") { - return(ci_satterthwaite(model, ci = ci)) + return(ci_satterthwaite(model, ci = ci, vcov = vcov, vcov_args = vcov_args, ...)) } else if (method %in% c("kenward", "kr")) { return(ci_kenward(model, ci = ci)) } diff --git a/R/extract_parameters.R b/R/extract_parameters.R index d875cf9bb..9e463eb90 100644 --- a/R/extract_parameters.R +++ b/R/extract_parameters.R @@ -523,7 +523,7 @@ vcov = vcov, vcov_args = vcov_args, verbose = verbose, - ci_method = ci_method + method = ci_method ) fun_args <- c(fun_args, dots) ci_df <- suppressMessages(do.call("ci", fun_args)) @@ -568,7 +568,13 @@ # p value if (!is.null(vcov)) { - fun_args <- list(model, vcov = vcov, vcov_args = vcov_args, verbose = verbose) + fun_args <- list( + model, + vcov = vcov, + vcov_args = vcov_args, + verbose = verbose, + method = ci_method + ) fun_args <- c(fun_args, dots) parameters <- merge( parameters, @@ -589,7 +595,7 @@ } else { parameters <- merge( parameters, - p_value(model, dof = dof, effects = "fixed"), + p_value(model, dof = dof, method = ci_method, effects = "fixed"), by = "Parameter", sort = FALSE ) diff --git a/R/format.R b/R/format.R index 74e137833..6b9160dd4 100644 --- a/R/format.R +++ b/R/format.R @@ -865,7 +865,8 @@ format.parameters_sem <- function( show_re_msg <- (identical(model_class, "glmmTMB") && (!string_method %in% c("Wald z-", "Wald normal") || !ci_method %in% c("wald", "normal"))) || - ((identical(model_class, "lmerMod") || identical(model_class, "glmerMod")) && + (length(model_class) == 1L && + model_class %in% c("lmerMod", "lmerModLmerTest", "glmerMod") && !ci_method %in% c("wald", "normal", "profile", "boot")) if ( diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 85377695e..faa3a6aef 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -118,15 +118,15 @@ model_parameters.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- model_parameters.merMod - cl$model <- .attempt_to_lmerModLmerTest(model) - cl$ci_method <- .attempt_satterthwaite_method( - ci_method, - cl$model, - effects, + .eval_satterthwaite_default( + cl, + method_arg = "ci_method", + method = ci_method, + effects = effects, bootstrap = bootstrap, - verbose = verbose + verbose = verbose, + envir = parent.frame() ) - eval.parent(cl) } #' @export @@ -144,9 +144,14 @@ ci.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- ci.merMod - cl$x <- .attempt_to_lmerModLmerTest(x) - cl$method <- .attempt_satterthwaite_method(method, cl$x, effects, verbose = verbose) - eval.parent(cl) + .eval_satterthwaite_default( + cl, + method_arg = "method", + method = method, + effects = effects, + verbose = verbose, + envir = parent.frame() + ) } #' @export @@ -161,9 +166,14 @@ standard_error.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- standard_error.merMod - cl$model <- .attempt_to_lmerModLmerTest(model) - cl$method <- .attempt_satterthwaite_method(method, cl$model, effects, verbose = verbose) - eval.parent(cl) + .eval_satterthwaite_default( + cl, + method_arg = "method", + method = method, + effects = effects, + verbose = verbose, + envir = parent.frame() + ) } #' @export @@ -179,9 +189,14 @@ p_value.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- p_value.merMod - cl$model <- .attempt_to_lmerModLmerTest(model) - cl$method <- .attempt_satterthwaite_method(method, cl$model, effects, verbose = verbose) - eval.parent(cl) + .eval_satterthwaite_default( + cl, + method_arg = "method", + method = method, + effects = effects, + verbose = verbose, + envir = parent.frame() + ) } @@ -266,57 +281,52 @@ se_mixed_default <- function(model) { .data_frame(Parameter = params, SE = .get_se_from_summary(model)) } -.attempt_to_lmerModLmerTest <- function(model) { - if ( - inherits(model, "lmerModLmerTest") || !requireNamespace("lmerTest", quietly = TRUE) - ) { - return(model) - } - - tryCatch(lmerTest::as_lmerModLmerTest(model), error = function(e) model) -} - -.attempt_satterthwaite_method <- function( +# Evaluates a call to a merMod method, using Satterthwaite df when the user did +# not choose a method. If Satterthwaite df cannot be computed, for example +# because lmerTest cannot rebuild the deviance function when the data is no +# longer available, the call is evaluated again with the merMod default. +.eval_satterthwaite_default <- function( + cl, + method_arg, method, - model, - effects, - fallback = "wald", + effects = "all", bootstrap = FALSE, - verbose = TRUE + verbose = TRUE, + envir = parent.frame() ) { - # Cases where we don't want to interfere - if (!is.null(method) || effects == "random" || isTRUE(bootstrap)) { - return(method) - } - - if (inherits(model, "lmerModLmerTest")) { - return("satterthwaite") + # cases where we don't want to interfere + if ( + !is.null(method) || + identical(effects, "random") || + isTRUE(bootstrap) || + !.check_lmerTest(verbose) + ) { + return(eval(cl, envir)) } - # Then the model is DEFNITLY NOT coercible because we already tried to coerce it - if (requireNamespace("lmerTest", quietly = TRUE)) { - return(fallback) - } + cl[[method_arg]] <- "satterthwaite" + tryCatch(eval(cl, envir), error = function(e) { + cl[[method_arg]] <- NULL + # if the default method fails as well, the error is not specific to + # Satterthwaite df, so we report the original error + out <- tryCatch(eval(cl, envir), error = function(e2) stop(e)) + if (verbose) { + insight::format_alert(paste0( + "Could not compute Satterthwaite degrees of freedom (", + conditionMessage(e), + "). Falling back to the Wald method." + )) + } + out + }) +} - # Model is potentially coercible if lmerTest were installed? - installed <- insight::check_if_installed( - package = "lmerTest", - reason = "for Satterthwaite df (default)", +.check_lmerTest <- function(verbose = TRUE) { + insight::check_if_installed( + "lmerTest", + reason = "for Satterthwaite degrees of freedom (the default for linear mixed models)", stop = FALSE, - prompt = interactive() && isTRUE(verbose) + quietly = !verbose, + prompt = FALSE ) - - # This is a workaround for the fact that check_if_installed() returns FALSE - # even if the package is not installed, but the user chooses to install it. In - # that case, we need to check again if the package is actually installed. - if (!installed) { - installed <- requireNamespace("lmerTest", quietly = TRUE) - } - - # if lmerTest is newly installed, and the model is coercible... - if (installed && inherits(.attempt_to_lmerModLmerTest(model, "lmerModLmerTest"))) { - return("satterthwaite") - } - - return(fallback) } diff --git a/man/ci.default.Rd b/man/ci.default.Rd index eb1887f97..a4e19838b 100644 --- a/man/ci.default.Rd +++ b/man/ci.default.Rd @@ -142,7 +142,11 @@ CIs and p-values instead. Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}. +method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, +and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If +\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot +be computed (for example, because the data used to fit the model is no +longer available), the Wald method is used instead. } \code{"kenward"} diff --git a/man/model_parameters.Rd b/man/model_parameters.Rd index b0cf3026c..75d39be52 100644 --- a/man/model_parameters.Rd +++ b/man/model_parameters.Rd @@ -222,7 +222,11 @@ CIs and p-values instead. Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}. +method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, +and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If +\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot +be computed (for example, because the data used to fit the model is no +longer available), the Wald method is used instead. } \code{"kenward"} diff --git a/man/model_parameters.brmsfit.Rd b/man/model_parameters.brmsfit.Rd index 92331c0d7..ca8d71b3b 100644 --- a/man/model_parameters.brmsfit.Rd +++ b/man/model_parameters.brmsfit.Rd @@ -302,7 +302,11 @@ CIs and p-values instead. Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}. +method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, +and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If +\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot +be computed (for example, because the data used to fit the model is no +longer available), the Wald method is used instead. } \code{"kenward"} diff --git a/man/model_parameters.default.Rd b/man/model_parameters.default.Rd index 393dc66d3..ef9b2ffcd 100644 --- a/man/model_parameters.default.Rd +++ b/man/model_parameters.default.Rd @@ -227,7 +227,11 @@ CIs and p-values instead. Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}. +method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, +and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If +\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot +be computed (for example, because the data used to fit the model is no +longer available), the Wald method is used instead. } \code{"kenward"} diff --git a/man/model_parameters.glmmTMB.Rd b/man/model_parameters.glmmTMB.Rd index 87bc75f1c..8808736e2 100644 --- a/man/model_parameters.glmmTMB.Rd +++ b/man/model_parameters.glmmTMB.Rd @@ -403,7 +403,11 @@ CIs and p-values instead. Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}. +method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, +and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If +\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot +be computed (for example, because the data used to fit the model is no +longer available), the Wald method is used instead. } \code{"kenward"} diff --git a/man/p_value.Rd b/man/p_value.Rd index c5fb5826b..e7da1b4b7 100644 --- a/man/p_value.Rd +++ b/man/p_value.Rd @@ -160,7 +160,11 @@ CIs and p-values instead. Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}. +method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, +and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If +\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot +be computed (for example, because the data used to fit the model is no +longer available), the Wald method is used instead. } \code{"kenward"} diff --git a/tests/testthat/_snaps/glmer.md b/tests/testthat/_snaps/glmer.md index 969b57580..2a85ae3af 100644 --- a/tests/testthat/_snaps/glmer.md +++ b/tests/testthat/_snaps/glmer.md @@ -76,8 +76,8 @@ Parameter | Coefficient | SE | 95% CI | t(17.00) | p ----------------------------------------------------------------------- - (Intercept) | 251.41 | 6.48 | [237.01, 265.80] | 38.77 | < .001 - Days | 10.47 | 1.49 | [ 7.21, 13.73] | 7.01 | < .001 + (Intercept) | 251.41 | 6.48 | [237.72, 265.09] | 38.77 | < .001 + Days | 10.47 | 1.49 | [ 7.32, 13.62] | 7.01 | < .001 # Random Effects @@ -103,8 +103,8 @@ Parameter | Coefficient | SE | 95% CI | t(174) | p --------------------------------------------------------------------- - (Intercept) | 251.41 | 6.48 | [237.01, 265.80] | 38.77 | < .001 - Days | 10.47 | 1.49 | [ 7.21, 13.73] | 7.01 | < .001 + (Intercept) | 251.41 | 6.48 | [238.61, 264.20] | 38.77 | < .001 + Days | 10.47 | 1.49 | [ 7.52, 13.42] | 7.01 | < .001 # Random Effects diff --git a/tests/testthat/test-lmerTest.R b/tests/testthat/test-lmerTest.R index 6df90c781..55413f573 100644 --- a/tests/testthat/test-lmerTest.R +++ b/tests/testthat/test-lmerTest.R @@ -53,3 +53,67 @@ test_that("mixed-model defaults use satterthwaite for lmerMod", { ) expect_identical(p_value(glmer_model), p_value(glmer_model, method = "wald")) }) + + +test_that("satterthwaite default keeps a robust vcov", { + skip_if_not_installed("clubSandwich") + data("sleepstudy", package = "lme4") + m <- lme4::lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy) + out <- model_parameters( + m, + effects = "fixed", + vcov = "CR0", + vcov_args = list(cluster = sleepstudy$Subject) + ) + expect_equal( + out$CI_low, + out$Coefficient - stats::qt(0.975, out$df_error) * out$SE, + tolerance = 1e-6 + ) + out_ci <- ci(m, vcov = "CR0", vcov_args = list(cluster = sleepstudy$Subject)) + expect_equal(out_ci$CI_low, out$CI_low, tolerance = 1e-6) +}) + + +test_that("satterthwaite default falls back to wald without the model data", { + # fit the models in an environment and remove the data afterwards, as with + # a model that was saved with saveRDS() and loaded in a new session + e <- new.env() + local( + { + d <- lme4::sleepstudy + m_lme4 <- lme4::lmer(Reaction ~ Days + (1 | Subject), data = d) + m_lmerTest <- lmerTest::lmer(Reaction ~ Days + (1 | Subject), data = d) + }, + envir = e + ) + rm("d", envir = e) + + for (m in list(e$m_lme4, e$m_lmerTest)) { + expect_message(out <- model_parameters(m, effects = "fixed"), regex = "Satterthwaite") + expect_equal( + out$CI_low, + model_parameters(m, effects = "fixed", ci_method = "residual")$CI_low, + tolerance = 1e-6 + ) + expect_message(out <- ci(m), regex = "Satterthwaite") + expect_identical(out, ci(m, method = "wald")) + expect_message(out <- p_value(m), regex = "Satterthwaite") + expect_identical(out, p_value(m, method = "wald")) + expect_silent(model_parameters(m, effects = "fixed", verbose = FALSE)) + expect_error(model_parameters(m, ci_method = "satterthwaite")) + } +}) + + +test_that("satterthwaite default is skipped without lmerTest", { + data("sleepstudy", package = "lme4") + m <- lme4::lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy) + local_mocked_bindings(.check_lmerTest = function(verbose = TRUE) FALSE) + expect_identical(ci(m), ci(m, method = "wald")) + expect_identical(p_value(m), p_value(m, method = "wald")) + expect_identical( + model_parameters(m, effects = "fixed"), + model_parameters(m, effects = "fixed", ci_method = "residual") + ) +}) From 80f4272be3064de26bae769621d3081267919b24 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Mon, 19 Oct 2026 09:37:46 +0300 Subject: [PATCH 29/33] setup new default --- DESCRIPTION | 2 +- NEWS.md | 7 +-- R/1_model_parameters.R | 9 ++-- R/methods_lme4.R | 96 +++++++++++++-------------------- man/ci.default.Rd | 9 ++-- man/model_parameters.Rd | 9 ++-- man/model_parameters.brmsfit.Rd | 9 ++-- man/model_parameters.default.Rd | 9 ++-- man/model_parameters.glmmTMB.Rd | 9 ++-- man/p_value.Rd | 9 ++-- 10 files changed, 61 insertions(+), 107 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bf670bac3..f13558004 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -241,4 +241,4 @@ Config/testthat/parallel: false Config/Needs/website: easystats/easystatstemplate Config/Needs/check: stan-dev/cmdstanr Config/rcmdcheck/ignore-inconsequential-notes: true -Config/roxygen2/version: 8.1.0 +Config/roxygen2/version: 8.1.1 diff --git a/NEWS.md b/NEWS.md index aef03f91f..6002caa00 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,11 +3,8 @@ ## Breaking Changes * `model_parameters()`, `ci()`, `standard_error()`, and `p_value()` now default - to the Satterthwaite approximation for `lmerMod` and `lmerModLmerTest` models - when `{lmerTest}` is available, making the outputs more consistent with - `summary()` (#989). If Satterthwaite degrees of freedom cannot be computed, - for example because the model data is no longer available, these functions - fall back to the Wald method with a message. + to the Satterthwaite approximation for `lmerModLmerTest` models and suggest + doing so for `lmerMod` models (#989). ## Changes diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index 9b0e6c89b..15d3f4ebb 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -196,12 +196,9 @@ #' - Applies to *linear mixed models*. CIs computed using the #' Wald method (SE and a *t-distribution with Satterthwaite df*); p-values #' computed using the Wald method with a *t-distribution with Satterthwaite df*. -#' This is the default for `lmerMod` and `lmerModLmerTest` when the corresponding -#' method argument (`ci_method` or `method`) is `NULL`, `bootstrap = FALSE`, -#' and `effects` is not `"random"`. It requires the *lmerTest* package. If -#' *lmerTest* is not installed, or if Satterthwaite degrees of freedom cannot -#' be computed (for example, because the data used to fit the model is no -#' longer available), the Wald method is used instead. +#' This is the default for `lmerModLmerTest` models when the corresponding +#' method argument (`ci_method` or `method`) is `NULL` (and +#' `bootstrap = FALSE`). #' #' `"kenward"` #' - Applies to *linear mixed models*. CIs computed using the Wald diff --git a/R/methods_lme4.R b/R/methods_lme4.R index faa3a6aef..381276fac 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -118,15 +118,14 @@ model_parameters.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- model_parameters.merMod - .eval_satterthwaite_default( - cl, - method_arg = "ci_method", + cl$ci_method <- .check_ci_method( + model, method = ci_method, effects = effects, bootstrap = bootstrap, - verbose = verbose, - envir = parent.frame() + verbose = verbose ) + eval.parent(cl) } #' @export @@ -144,14 +143,13 @@ ci.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- ci.merMod - .eval_satterthwaite_default( - cl, - method_arg = "method", + cl$ci_method <- .check_ci_method( + x, method = method, effects = effects, - verbose = verbose, - envir = parent.frame() + verbose = verbose ) + eval.parent(cl) } #' @export @@ -166,14 +164,13 @@ standard_error.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- standard_error.merMod - .eval_satterthwaite_default( - cl, - method_arg = "method", + cl$ci_method <- .check_ci_method( + model, method = method, effects = effects, - verbose = verbose, - envir = parent.frame() + verbose = verbose ) + eval.parent(cl) } #' @export @@ -189,14 +186,13 @@ p_value.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- p_value.merMod - .eval_satterthwaite_default( - cl, - method_arg = "method", + cl$ci_method <- .check_ci_method( + model, method = method, effects = effects, - verbose = verbose, - envir = parent.frame() + verbose = verbose ) + eval.parent(cl) } @@ -281,52 +277,34 @@ se_mixed_default <- function(model) { .data_frame(Parameter = params, SE = .get_se_from_summary(model)) } -# Evaluates a call to a merMod method, using Satterthwaite df when the user did -# not choose a method. If Satterthwaite df cannot be computed, for example -# because lmerTest cannot rebuild the deviance function when the data is no -# longer available, the call is evaluated again with the merMod default. -.eval_satterthwaite_default <- function( - cl, - method_arg, +.check_ci_method <- function( + model, method, effects = "all", bootstrap = FALSE, verbose = TRUE, - envir = parent.frame() + fallback = "wald" ) { - # cases where we don't want to interfere + if (!is.null(method) || isTRUE(bootstrap) || identical(effects, "random")) { + return(method) + } + + mod_class <- class(model) + if (identical(mod_class, "lmerModLmerTest")) { + return("satterthwaite") + } + if ( - !is.null(method) || - identical(effects, "random") || - isTRUE(bootstrap) || - !.check_lmerTest(verbose) + isTRUE(verbose) && + !isTRUE(getOption(".suggest_satterthwaite_for_lmerMod")) && + identical(mod_class, "lmerMod") ) { - return(eval(cl, envir)) + insight::format_alert( + 'Concider setting `ci_method = "satterthwaite"` for better covarage and type-1 error control.', + "This message will only show once per session." + ) + options(.suggest_satterthwaite_for_lmerMod = FALSE) } - cl[[method_arg]] <- "satterthwaite" - tryCatch(eval(cl, envir), error = function(e) { - cl[[method_arg]] <- NULL - # if the default method fails as well, the error is not specific to - # Satterthwaite df, so we report the original error - out <- tryCatch(eval(cl, envir), error = function(e2) stop(e)) - if (verbose) { - insight::format_alert(paste0( - "Could not compute Satterthwaite degrees of freedom (", - conditionMessage(e), - "). Falling back to the Wald method." - )) - } - out - }) -} - -.check_lmerTest <- function(verbose = TRUE) { - insight::check_if_installed( - "lmerTest", - reason = "for Satterthwaite degrees of freedom (the default for linear mixed models)", - stop = FALSE, - quietly = !verbose, - prompt = FALSE - ) + return(fallback) } diff --git a/man/ci.default.Rd b/man/ci.default.Rd index a4e19838b..6a5f24642 100644 --- a/man/ci.default.Rd +++ b/man/ci.default.Rd @@ -141,12 +141,9 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. -This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, -and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If -\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot -be computed (for example, because the data used to fit the model is no -longer available), the Wald method is used instead. +This is the default for \code{lmerModLmerTest} models when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL} (and +\code{bootstrap = FALSE}). } \code{"kenward"} diff --git a/man/model_parameters.Rd b/man/model_parameters.Rd index 75d39be52..2b85090e4 100644 --- a/man/model_parameters.Rd +++ b/man/model_parameters.Rd @@ -221,12 +221,9 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. -This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, -and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If -\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot -be computed (for example, because the data used to fit the model is no -longer available), the Wald method is used instead. +This is the default for \code{lmerModLmerTest} models when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL} (and +\code{bootstrap = FALSE}). } \code{"kenward"} diff --git a/man/model_parameters.brmsfit.Rd b/man/model_parameters.brmsfit.Rd index ca8d71b3b..006620506 100644 --- a/man/model_parameters.brmsfit.Rd +++ b/man/model_parameters.brmsfit.Rd @@ -301,12 +301,9 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. -This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, -and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If -\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot -be computed (for example, because the data used to fit the model is no -longer available), the Wald method is used instead. +This is the default for \code{lmerModLmerTest} models when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL} (and +\code{bootstrap = FALSE}). } \code{"kenward"} diff --git a/man/model_parameters.default.Rd b/man/model_parameters.default.Rd index ef9b2ffcd..10a2e3833 100644 --- a/man/model_parameters.default.Rd +++ b/man/model_parameters.default.Rd @@ -226,12 +226,9 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. -This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, -and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If -\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot -be computed (for example, because the data used to fit the model is no -longer available), the Wald method is used instead. +This is the default for \code{lmerModLmerTest} models when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL} (and +\code{bootstrap = FALSE}). } \code{"kenward"} diff --git a/man/model_parameters.glmmTMB.Rd b/man/model_parameters.glmmTMB.Rd index 8808736e2..7abda13ff 100644 --- a/man/model_parameters.glmmTMB.Rd +++ b/man/model_parameters.glmmTMB.Rd @@ -402,12 +402,9 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. -This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, -and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If -\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot -be computed (for example, because the data used to fit the model is no -longer available), the Wald method is used instead. +This is the default for \code{lmerModLmerTest} models when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL} (and +\code{bootstrap = FALSE}). } \code{"kenward"} diff --git a/man/p_value.Rd b/man/p_value.Rd index e7da1b4b7..987c1791d 100644 --- a/man/p_value.Rd +++ b/man/p_value.Rd @@ -159,12 +159,9 @@ CIs and p-values instead. \item Applies to \emph{linear mixed models}. CIs computed using the Wald method (SE and a \emph{t-distribution with Satterthwaite df}); p-values computed using the Wald method with a \emph{t-distribution with Satterthwaite df}. -This is the default for \code{lmerMod} and \code{lmerModLmerTest} when the corresponding -method argument (\code{ci_method} or \code{method}) is \code{NULL}, \code{bootstrap = FALSE}, -and \code{effects} is not \code{"random"}. It requires the \emph{lmerTest} package. If -\emph{lmerTest} is not installed, or if Satterthwaite degrees of freedom cannot -be computed (for example, because the data used to fit the model is no -longer available), the Wald method is used instead. +This is the default for \code{lmerModLmerTest} models when the corresponding +method argument (\code{ci_method} or \code{method}) is \code{NULL} (and +\code{bootstrap = FALSE}). } \code{"kenward"} From 64690f403f677e5a68f5ece632d989340d1b436d Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Mon, 19 Oct 2026 13:21:05 +0300 Subject: [PATCH 30/33] fix compare_parameters default ci --- NEWS.md | 3 + R/compare_parameters.R | 114 ++++++++++++++------ tests/testthat/_snaps/compare_parameters.md | 2 +- 3 files changed, 85 insertions(+), 34 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6002caa00..5b24c0f48 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,9 @@ ## Breaking Changes +* `compare_parameters()`'s `ci_method` now defaults to `NULL`, so the value is + potentially set by the models' unique methods. + * `model_parameters()`, `ci()`, `standard_error()`, and `p_value()` now default to the Satterthwaite approximation for `lmerModLmerTest` models and suggest doing so for `lmerMod` models (#989). diff --git a/R/compare_parameters.R b/R/compare_parameters.R index ec8793de9..17e2e01c3 100644 --- a/R/compare_parameters.R +++ b/R/compare_parameters.R @@ -69,23 +69,25 @@ #' compare_parameters(list("linear model" = m1, "logistic reg." = m2)) #' } #' @export -compare_parameters <- function(..., - ci = 0.95, - effects = "fixed", - component = "conditional", - standardize = NULL, - exponentiate = FALSE, - ci_method = "wald", - p_adjust = NULL, - select = NULL, - column_names = NULL, - pretty_names = TRUE, - coefficient_names = NULL, - keep = NULL, - drop = NULL, - include_reference = FALSE, - groups = NULL, - verbose = TRUE) { +compare_parameters <- function( + ..., + ci = 0.95, + effects = "fixed", + component = "conditional", + standardize = NULL, + exponentiate = FALSE, + ci_method = NULL, + p_adjust = NULL, + select = NULL, + column_names = NULL, + pretty_names = TRUE, + coefficient_names = NULL, + keep = NULL, + drop = NULL, + include_reference = FALSE, + groups = NULL, + verbose = TRUE +) { models <- list(...) if (length(models) == 1) { @@ -117,14 +119,23 @@ compare_parameters <- function(..., } } - supported_models <- vapply(models, function(i) { - insight::is_model_supported(i) || inherits(i, "lavaan") || inherits(i, "parameters_model") - }, TRUE) + supported_models <- vapply( + models, + function(i) { + insight::is_model_supported(i) || + inherits(i, "lavaan") || + inherits(i, "parameters_model") + }, + TRUE + ) if (!all(supported_models)) { if (verbose) { insight::format_alert( - sprintf("Following objects are not supported: %s", toString(model_names[!supported_models])), + sprintf( + "Following objects are not supported: %s", + toString(model_names[!supported_models]) + ), "Dropping unsupported models now." ) } @@ -169,7 +180,14 @@ compare_parameters <- function(..., dat <- model } else { # set default-ci_type for Bayesian models - if (insight::is_bayesian_model(model, exclude = c("bmerMod", "bayesx", "blmerMod", "bglmerMod")) && !ci_method %in% c("hdi", "quantile", "ci", "eti", "si", "bci", "bcai")) { # nolint + if ( + insight::is_bayesian_model( + model, + exclude = c("bmerMod", "bayesx", "blmerMod", "bglmerMod") + ) && + !ci_method %in% c("hdi", "quantile", "ci", "eti", "si", "bci", "bcai") + ) { + # nolint ci_method_tmp <- "eti" } else { ci_method_tmp <- ci_method @@ -217,7 +235,10 @@ compare_parameters <- function(..., # add zi-suffix to parameter names if (any(dat$Component == "zero_inflated")) { - dat$Parameter[dat$Component == "zero_inflated"] <- paste0(dat$Parameter[dat$Component == "zero_inflated"], " (zi)") + dat$Parameter[dat$Component == "zero_inflated"] <- paste0( + dat$Parameter[dat$Component == "zero_inflated"], + " (zi)" + ) } # add suffix @@ -235,15 +256,28 @@ compare_parameters <- function(..., names(object_attributes) <- model_names # merge all data frames - all_models <- suppressWarnings(Reduce(function(x, y) { - merge(x, y, all = TRUE, sort = FALSE, by = c("Parameter", "Component", "Effects", "Group")) - }, m)) + all_models <- suppressWarnings(Reduce( + function(x, y) { + merge( + x, + y, + all = TRUE, + sort = FALSE, + by = c("Parameter", "Component", "Effects", "Group") + ) + }, + m + )) # find columns with model numbers and create new variable "params_order", # which is pasted together of all model-column indices. Take lowest index of # all model-column indices, which then indicates order of parameters/rows. model_cols <- which(startsWith(colnames(all_models), "model")) - params_order <- as.numeric(substr(gsub("NA", "", do.call(paste0, all_models[model_cols]), fixed = TRUE), 0, 1)) + params_order <- as.numeric(substr( + gsub("NA", "", do.call(paste0, all_models[model_cols]), fixed = TRUE), + 0, + 1 + )) all_models <- all_models[order(params_order), ] all_models[model_cols] <- NULL @@ -253,11 +287,20 @@ compare_parameters <- function(..., all_models$Group <- NULL } - attr(all_models, "model_names") <- gsub("\"", "", unlist(lapply(model_names, insight::safe_deparse)), fixed = TRUE) + attr(all_models, "model_names") <- gsub( + "\"", + "", + unlist(lapply(model_names, insight::safe_deparse)), + fixed = TRUE + ) attr(all_models, "output_style") <- select attr(all_models, "all_attributes") <- object_attributes attr(all_models, "parameter_groups") <- groups - class(all_models) <- c("compare_parameters", "see_compare_parameters", unique(class(all_models))) + class(all_models) <- c( + "compare_parameters", + "see_compare_parameters", + unique(class(all_models)) + ) all_models } @@ -270,11 +313,12 @@ compare_models <- compare_parameters # helper ---------------------------- - .set_pretty_names <- function(x, pretty_names) { # check if pretty names should be replaced by value labels # (if we have labelled data) - if (isTRUE(getOption("parameters_labels", FALSE)) || identical(pretty_names, "labels")) { + if ( + isTRUE(getOption("parameters_labels", FALSE)) || identical(pretty_names, "labels") + ) { attr(x, "pretty_names") <- attr(x, "pretty_labels", exact = TRUE) pretty_names <- TRUE } @@ -288,7 +332,9 @@ compare_models <- compare_parameters match_pretty_names <- match(names(att$pretty_names), x$Parameter) match_pretty_names <- match_pretty_names[!is.na(match_pretty_names)] if (length(match_pretty_names)) { - x$Parameter[match_pretty_names] <- att$pretty_names[x$Parameter[match_pretty_names]] + x$Parameter[match_pretty_names] <- att$pretty_names[x$Parameter[ + match_pretty_names + ]] } } else { match_pretty_names <- att$pretty_names[x$Parameter] @@ -296,7 +342,9 @@ compare_models <- compare_parameters match_pretty_names <- match(names(att$pretty_names), x$Parameter) match_pretty_names <- match_pretty_names[!is.na(match_pretty_names)] if (length(match_pretty_names)) { - x$Parameter[match_pretty_names] <- att$pretty_names[x$Parameter[match_pretty_names]] + x$Parameter[match_pretty_names] <- att$pretty_names[x$Parameter[ + match_pretty_names + ]] } } else { x$Parameter <- att$pretty_names[x$Parameter] diff --git a/tests/testthat/_snaps/compare_parameters.md b/tests/testthat/_snaps/compare_parameters.md index 6c357c58d..1a58fa541 100644 --- a/tests/testthat/_snaps/compare_parameters.md +++ b/tests/testthat/_snaps/compare_parameters.md @@ -20,7 +20,7 @@ Parameter | m0 | m1 | m2 -------------------------------------------------------------------------------- (Intercept) | 0.91 ( 0.75, 1.07) | 0.68 (-0.54, 1.91) | 1.41 ( 1.06, 1.75) - child | -1.23 (-1.39, -1.08) | -1.67 (-1.84, -1.51) | -0.53 (-0.77, -0.29) + child | -1.23 (-1.40, -1.08) | -1.67 (-1.84, -1.51) | -0.53 (-0.77, -0.29) camper [1] | 1.05 ( 0.88, 1.23) | 0.94 ( 0.77, 1.12) | 0.58 ( 0.39, 0.78) zg | | | 0.13 ( 0.05, 0.21) From 307e2d2508a88e9c832b7945f5cc5dee30cd0255 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Mon, 19 Oct 2026 13:56:37 +0300 Subject: [PATCH 31/33] fix tests Some of these are reverted back to the orig tests --- R/methods_lme4.R | 26 +++--- tests/testthat/_snaps/glmer.md | 14 ++-- .../testthat/_snaps/model_parameters.mixed.md | 84 +++++++++---------- tests/testthat/test-ci.R | 12 +-- tests/testthat/test-lavaan.R | 2 +- tests/testthat/test-lmerTest.R | 60 +++---------- .../test-model_parameters_df_method.R | 33 ++++---- .../test-model_parameters_std_mixed.R | 16 ++-- tests/testthat/test-p_adjust.R | 2 +- tests/testthat/test-p_value.R | 3 +- tests/testthat/test-parameters_table.R | 3 +- 11 files changed, 109 insertions(+), 146 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 381276fac..8ed5af18b 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -123,7 +123,8 @@ model_parameters.lmerMod <- function( method = ci_method, effects = effects, bootstrap = bootstrap, - verbose = verbose + verbose = verbose, + fallback = NULL # this is the default for merMod ) eval.parent(cl) } @@ -143,11 +144,12 @@ ci.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- ci.merMod - cl$ci_method <- .check_ci_method( + cl$method <- .check_ci_method( x, method = method, effects = effects, - verbose = verbose + verbose = verbose, + fallback = "wald" # this is the default for merMod ) eval.parent(cl) } @@ -164,11 +166,12 @@ standard_error.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- standard_error.merMod - cl$ci_method <- .check_ci_method( + cl$method <- .check_ci_method( model, method = method, effects = effects, - verbose = verbose + verbose = verbose, + fallback = NULL # this is the default for merMod ) eval.parent(cl) } @@ -186,11 +189,12 @@ p_value.lmerMod <- function( ) { cl <- match.call() cl[[1]] <- p_value.merMod - cl$ci_method <- .check_ci_method( + cl$method <- .check_ci_method( model, method = method, effects = effects, - verbose = verbose + verbose = verbose, + fallback = "wald" # this is the default for merMod ) eval.parent(cl) } @@ -283,21 +287,21 @@ se_mixed_default <- function(model) { effects = "all", bootstrap = FALSE, verbose = TRUE, - fallback = "wald" + fallback = NULL ) { if (!is.null(method) || isTRUE(bootstrap) || identical(effects, "random")) { return(method) } mod_class <- class(model) - if (identical(mod_class, "lmerModLmerTest")) { + if (setequal(mod_class, "lmerModLmerTest")) { return("satterthwaite") } if ( isTRUE(verbose) && - !isTRUE(getOption(".suggest_satterthwaite_for_lmerMod")) && - identical(mod_class, "lmerMod") + isTRUE(getOption(".suggest_satterthwaite_for_lmerMod", default = TRUE)) && + setequal(mod_class, "lmerMod") ) { insight::format_alert( 'Concider setting `ci_method = "satterthwaite"` for better covarage and type-1 error control.', diff --git a/tests/testthat/_snaps/glmer.md b/tests/testthat/_snaps/glmer.md index 2a85ae3af..6f1fb2c74 100644 --- a/tests/testthat/_snaps/glmer.md +++ b/tests/testthat/_snaps/glmer.md @@ -74,10 +74,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t(17.00) | p - ----------------------------------------------------------------------- - (Intercept) | 251.41 | 6.48 | [237.72, 265.09] | 38.77 | < .001 - Days | 10.47 | 1.49 | [ 7.32, 13.62] | 7.01 | < .001 + Parameter | Coefficient | SE | 95% CI | t(174) | p + --------------------------------------------------------------------- + (Intercept) | 251.41 | 6.48 | [238.61, 264.20] | 38.77 | < .001 + Days | 10.47 | 1.49 | [ 7.52, 13.42] | 7.01 | < .001 # Random Effects @@ -90,9 +90,9 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution with Satterthwaite approximation. - Uncertainty intervals for random effect variances computed using a Wald - z-distribution approximation. + using a Wald t-distribution approximation. Uncertainty intervals for + random effect variances computed using a Wald z-distribution + approximation. --- diff --git a/tests/testthat/_snaps/model_parameters.mixed.md b/tests/testthat/_snaps/model_parameters.mixed.md index f26a1db31..685934ad5 100644 --- a/tests/testthat/_snaps/model_parameters.mixed.md +++ b/tests/testthat/_snaps/model_parameters.mixed.md @@ -3,26 +3,26 @@ Code model_parameters(model, effects = "fixed", wb_component = TRUE) Output - Parameter | Coefficient | SE | 95% CI | t | df | p - --------------------------------------------------------------------------- - (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | 559.94 | < .001 - time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 374.00 | 0.089 + Parameter | Coefficient | SE | 95% CI | t(558) | p + ------------------------------------------------------------------- + (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | < .001 + time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 0.089 # Within-Effects - Parameter | Coefficient | SE | 95% CI | t(374.00) | p - ---------------------------------------------------------------------- - phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | < .001 + Parameter | Coefficient | SE | 95% CI | t(558) | p + ------------------------------------------------------------------- + phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | < .001 # Between-Effects - Parameter | Coefficient | SE | 95% CI | t(186.00) | p - ----------------------------------------------------------------------- - phq4 between | -6.28 | 0.50 | [-7.27, -5.29] | -12.53 | < .001 + Parameter | Coefficient | SE | 95% CI | t(558) | p + -------------------------------------------------------------------- + phq4 between | -6.28 | 0.50 | [-7.27, -5.30] | -12.53 | < .001 Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution with Satterthwaite approximation. + using a Wald t-distribution approximation. --- @@ -31,16 +31,16 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t | df | p - ----------------------------------------------------------------------------- - (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | 559.94 | < .001 - time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 374.00 | 0.089 - phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | 374.00 | < .001 - phq4 between | -6.28 | 0.50 | [-7.27, -5.29] | -12.53 | 186.00 | < .001 + Parameter | Coefficient | SE | 95% CI | t(558) | p + -------------------------------------------------------------------- + (Intercept) | 71.53 | 1.56 | [68.48, 74.59] | 45.98 | < .001 + time | 1.09 | 0.64 | [-0.17, 2.34] | 1.70 | 0.089 + phq4 within | -3.66 | 0.41 | [-4.46, -2.86] | -8.95 | < .001 + phq4 between | -6.28 | 0.50 | [-7.27, -5.30] | -12.53 | < .001 Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution with Satterthwaite approximation. + using a Wald t-distribution approximation. # print-model_parameters-2 @@ -49,10 +49,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t | df | p - ------------------------------------------------------------------------ - (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 - cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 + Parameter | Coefficient | SE | 95% CI | t(28) | p + ----------------------------------------------------------------- + (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 + cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 # Random Effects @@ -63,9 +63,9 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution with Satterthwaite approximation. - Uncertainty intervals for random effect variances computed using a Wald - z-distribution approximation. + using a Wald t-distribution approximation. Uncertainty intervals for + random effect variances computed using a Wald z-distribution + approximation. --- @@ -74,10 +74,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t | df | p - ------------------------------------------------------------------------ - (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 - cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 + Parameter | Coefficient | SE | 95% CI | t(28) | p + ----------------------------------------------------------------- + (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 + cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 # Random Effects @@ -88,9 +88,9 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution with Satterthwaite approximation. - Uncertainty intervals for random effect variances computed using a Wald - z-distribution approximation. + using a Wald t-distribution approximation. Uncertainty intervals for + random effect variances computed using a Wald z-distribution + approximation. --- @@ -99,10 +99,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t | df | p - ------------------------------------------------------------------------ - (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 - cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 + Parameter | Coefficient | SE | 95% CI | t(28) | p + ----------------------------------------------------------------- + (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 + cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 Model: wt ~ cyl (32 Observations) Sigma: 0.594 (df = 28) @@ -111,7 +111,7 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution with Satterthwaite approximation. + using a Wald t-distribution approximation. --- @@ -120,10 +120,10 @@ Output # Fixed Effects - Parameter | Coefficient | SE | 95% CI | t | df | p - ------------------------------------------------------------------------ - (Intercept) | 0.65 | 0.50 | [-0.47, 1.77] | 1.29 | 10.17 | 0.224 - cyl | 0.40 | 0.08 | [ 0.24, 0.57] | 5.29 | 16.13 | < .001 + Parameter | Coefficient | SE | 95% CI | t(28) | p + ----------------------------------------------------------------- + (Intercept) | 0.65 | 0.50 | [-0.38, 1.68] | 1.29 | 0.206 + cyl | 0.40 | 0.08 | [ 0.25, 0.56] | 5.29 | < .001 Model: wt ~ cyl (32 Observations) Sigma: 0.594 (df = 28) @@ -132,5 +132,5 @@ Message Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed - using a Wald t-distribution with Satterthwaite approximation. + using a Wald t-distribution approximation. diff --git a/tests/testthat/test-ci.R b/tests/testthat/test-ci.R index 2d7fa34db..2743277c3 100644 --- a/tests/testthat/test-ci.R +++ b/tests/testthat/test-ci.R @@ -13,24 +13,20 @@ test_that("ci", { expect_equal(suppressMessages(ci(model))[1, 3], 1.934013, tolerance = 0.01) model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars) - expect_equal( - suppressMessages(ci(model, method = "normal"))[1, 3], - -0.335063, - tolerance = 0.01 - ) + expect_equal(suppressMessages(ci(model))[1, 3], -0.3795646, tolerance = 0.01) model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars) - expect_equal(ci(model, method = "wald")[1, 3], -0.3795646, tolerance = 0.01) + expect_equal(ci(model)[1, 3], -0.3795646, tolerance = 0.01) set.seed(1) val <- ci(model, method = "boot")[1, 3] expect_equal(val, -0.555424, tolerance = 0.01) model <- lme4::glmer(vs ~ cyl + (1 | gear), data = mtcars, family = "binomial") - expect_equal(ci(model, method = "wald")[1, 3], -0.7876679, tolerance = 0.01) + expect_equal(ci(model)[1, 3], -0.7876679, tolerance = 0.01) model <- lme4::glmer(vs ~ drat + cyl + (1 | gear), data = mtcars, family = "binomial") - expect_equal(ci(model, method = "wald")[1, 3], -48.14195, tolerance = 0.01) + expect_equal(ci(model)[1, 3], -48.14195, tolerance = 0.01) }) diff --git a/tests/testthat/test-lavaan.R b/tests/testthat/test-lavaan.R index b879af2e7..c31e135a1 100644 --- a/tests/testthat/test-lavaan.R +++ b/tests/testthat/test-lavaan.R @@ -86,7 +86,7 @@ test_that("simulate_model and equivalence_test work for lavaan", { ) set.seed(123) - out <- equivalence_test(m, range = c(-0.2, 0.2)) + out <- equivalence_test(m, range = c(-0.2, 0.2), ci_method = "ETI") expect_identical( capture.output(out), c( diff --git a/tests/testthat/test-lmerTest.R b/tests/testthat/test-lmerTest.R index 55413f573..f85329613 100644 --- a/tests/testthat/test-lmerTest.R +++ b/tests/testthat/test-lmerTest.R @@ -10,7 +10,7 @@ m1 <- lmerTest::lmer( ) test_that("model_parameters, satterthwaite", { - params <- model_parameters(m1, effects = "fixed", ci_method = "satterthwaite") + params <- model_parameters(m1, effects = "fixed") s <- summary(m1) expect_equal(params$df, as.vector(s$coefficients[, "df"]), tolerance = 1e-4) expect_equal(params$t, as.vector(s$coefficients[, "t value"]), tolerance = 1e-4) @@ -26,7 +26,7 @@ test_that("model_parameters, kenward", { }) -test_that("mixed-model defaults use satterthwaite for lmerMod", { +test_that("mixed-model defaults use satterthwaite for lmerModLmerTest", { params_default <- model_parameters(m1, effects = "fixed") params_satterthwaite <- model_parameters( m1, @@ -43,15 +43,6 @@ test_that("mixed-model defaults use satterthwaite for lmerMod", { expect_identical(ci(m1), ci(m1, method = "satterthwaite")) expect_identical(standard_error(m1), standard_error(m1, method = "satterthwaite")) expect_identical(p_value(m1), p_value(m1, method = "satterthwaite")) - - glmer_model <- lme4::glmer(vs ~ cyl + (1 | gear), data = mtcars, family = "binomial") - - expect_identical(ci(glmer_model), ci(glmer_model, method = "wald")) - expect_identical( - standard_error(glmer_model), - standard_error(glmer_model, method = "wald") - ) - expect_identical(p_value(glmer_model), p_value(glmer_model, method = "wald")) }) @@ -62,6 +53,7 @@ test_that("satterthwaite default keeps a robust vcov", { out <- model_parameters( m, effects = "fixed", + ci_method = "satterthwaite", vcov = "CR0", vcov_args = list(cluster = sleepstudy$Subject) ) @@ -74,46 +66,20 @@ test_that("satterthwaite default keeps a robust vcov", { expect_equal(out_ci$CI_low, out$CI_low, tolerance = 1e-6) }) +test_that("glmer", { + glmer_model <- lme4::glmer(vs ~ cyl + (1 | gear), data = mtcars, family = "binomial") -test_that("satterthwaite default falls back to wald without the model data", { - # fit the models in an environment and remove the data afterwards, as with - # a model that was saved with saveRDS() and loaded in a new session - e <- new.env() - local( - { - d <- lme4::sleepstudy - m_lme4 <- lme4::lmer(Reaction ~ Days + (1 | Subject), data = d) - m_lmerTest <- lmerTest::lmer(Reaction ~ Days + (1 | Subject), data = d) - }, - envir = e + expect_identical(ci(glmer_model), ci(glmer_model, method = "wald")) + expect_identical( + standard_error(glmer_model), + standard_error(glmer_model, method = "wald") ) - rm("d", envir = e) - - for (m in list(e$m_lme4, e$m_lmerTest)) { - expect_message(out <- model_parameters(m, effects = "fixed"), regex = "Satterthwaite") - expect_equal( - out$CI_low, - model_parameters(m, effects = "fixed", ci_method = "residual")$CI_low, - tolerance = 1e-6 - ) - expect_message(out <- ci(m), regex = "Satterthwaite") - expect_identical(out, ci(m, method = "wald")) - expect_message(out <- p_value(m), regex = "Satterthwaite") - expect_identical(out, p_value(m, method = "wald")) - expect_silent(model_parameters(m, effects = "fixed", verbose = FALSE)) - expect_error(model_parameters(m, ci_method = "satterthwaite")) - } + expect_identical(p_value(glmer_model), p_value(glmer_model, method = "wald")) }) - -test_that("satterthwaite default is skipped without lmerTest", { +test_that("lmerMod with lme4 give a warning once", { data("sleepstudy", package = "lme4") m <- lme4::lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy) - local_mocked_bindings(.check_lmerTest = function(verbose = TRUE) FALSE) - expect_identical(ci(m), ci(m, method = "wald")) - expect_identical(p_value(m), p_value(m, method = "wald")) - expect_identical( - model_parameters(m, effects = "fixed"), - model_parameters(m, effects = "fixed", ci_method = "residual") - ) + expect_message(ci(m)) + expect_no_message(ci(m)) }) diff --git a/tests/testthat/test-model_parameters_df_method.R b/tests/testthat/test-model_parameters_df_method.R index 02a6ac317..459fff46c 100644 --- a/tests/testthat/test-model_parameters_df_method.R +++ b/tests/testthat/test-model_parameters_df_method.R @@ -30,27 +30,30 @@ mp2 <- model_parameters(model, digits = 5, ci_method = "s", effects = "fixed") mp3 <- model_parameters(model, digits = 5, ci_method = "kr", effects = "fixed") mp4 <- model_parameters(model, digits = 5, ci_method = "wald", effects = "fixed") mp5 <- model_parameters(model3, digits = 5, ci_method = "kr", effects = "fixed") -mp6 <- model_parameters(model3, digits = 5, ci_method = "residual", effects = "fixed") +mp6 <- model_parameters( + model3, + digits = 5, + ci_method = "satterthwaite", + effects = "fixed" +) -test_that("model_parameters, ci_method default (satterthwaite)", { +test_that("model_parameters, ci_method default (residual)", { expect_equal( mp0$SE, c(2.77457, 3.69574, 3.521, 0.01574, 1.58514, 0.86316, 0.02973, 0.01668), tolerance = 1e-3 ) - expect_equal(mp0$df, c(24, 24, 24, 24, 24, 24, 24, 24), tolerance = 1e-3) + expect_equal(mp0$df, c(22, 22, 22, 22, 22, 22, 22, 22), tolerance = 1e-3) expect_equal( mp0$p, - c(0, 0.00236, 0.14179, 0.16979, 0.84763, 0.00542, 0.00136, 0.32563), + c(0, 0.00258, 0.14297, 0.17095, 0.84778, 0.00578, 0.00151, 0.32653), tolerance = 1e-3 ) expect_equal( mp0$CI_low, - c(24.57489, 4.93385, -1.91805, -0.05477, -2.96368, -4.41987, -0.16904, -0.05117), + c(24.54722, 4.89698, -1.95317, -0.05493, -2.97949, -4.42848, -0.16933, -0.05133), tolerance = 1e-3 ) - expect_equal(mp0$SE, mp6$SE, tolerance = 1e-3) - expect_equal(mp0$df_error, mp2$df_error, tolerance = 1e-3) }) test_that("model_parameters, ci_method normal", { @@ -72,23 +75,25 @@ test_that("model_parameters, ci_method normal", { ) }) -test_that("model_parameters, ci_method residual", { +test_that("model_parameters, ci_method satterthwaite", { expect_equal( - mp6$SE, + mp2$SE, c(2.77457, 3.69574, 3.521, 0.01574, 1.58514, 0.86316, 0.02973, 0.01668), tolerance = 1e-3 ) - expect_equal(mp6$df, c(22, 22, 22, 22, 22, 22, 22, 22), tolerance = 1e-3) + expect_equal(mp2$df, c(24, 24, 24, 24, 24, 24, 24, 24), tolerance = 1e-3) expect_equal( - mp6$p, - c(0, 0.00258, 0.14297, 0.17095, 0.84778, 0.00578, 0.00151, 0.32653), + mp2$p, + c(0, 0.00236, 0.14179, 0.16979, 0.84763, 0.00542, 0.00136, 0.32563), tolerance = 1e-3 ) expect_equal( - mp6$CI_low, - c(24.54722, 4.89698, -1.95317, -0.05493, -2.97949, -4.42848, -0.16933, -0.05133), + mp2$CI_low, + c(24.57489, 4.93385, -1.91805, -0.05477, -2.96368, -4.41987, -0.16904, -0.05117), tolerance = 1e-3 ) + expect_equal(mp2$SE, mp6$SE, tolerance = 1e-3) + expect_equal(mp2$df_error, mp6$df_error, tolerance = 1e-3) }) test_that("model_parameters, ci_method kenward", { diff --git a/tests/testthat/test-model_parameters_std_mixed.R b/tests/testthat/test-model_parameters_std_mixed.R index 2f882fc01..f4f043d57 100644 --- a/tests/testthat/test-model_parameters_std_mixed.R +++ b/tests/testthat/test-model_parameters_std_mixed.R @@ -59,8 +59,7 @@ test_that("model_parameters, standardize-refit", { model, standardize = "refit", verbose = FALSE, - effects = "fixed", - ci_method = "wald" + effects = "fixed" ) expect_equal(c(nrow(params), ncol(params)), c(7, 10)) expect_equal( @@ -83,14 +82,12 @@ test_that("model_parameters, standardize-refit", { model, standardize = "refit", verbose = FALSE, - effects = "all", - ci_method = "wald" + effects = "all" ) paramsZ <- model_parameters( effectsize::standardize(model), effects = "all", - verbose = FALSE, - ci_method = "wald" + verbose = FALSE ) expect_equal(paramsZ, params, ignore_attr = TRUE) }) @@ -100,8 +97,7 @@ test_that("model_parameters, standardize-posthoc", { model, standardize = "posthoc", verbose = FALSE, - effects = "fixed", - ci_method = "wald" + effects = "fixed" ) expect_equal(c(nrow(params), ncol(params)), c(7, 10)) expect_equal( @@ -219,8 +215,7 @@ test_that("model_parameters, standardize-basic", { model, standardize = "basic", verbose = FALSE, - effects = "fixed", - ci_method = "wald" + effects = "fixed" ) expect_equal( params$CI_high, @@ -236,7 +231,6 @@ test_that("model_parameters, standardize-refit robust", { standardize = "refit", effects = "fixed", vcov = "CR", - ci_method = "wald", vcov_args = list(type = "CR1", cluster = iris$grp), verbose = FALSE ) diff --git a/tests/testthat/test-p_adjust.R b/tests/testthat/test-p_adjust.R index 6a79b6154..96b5089a7 100644 --- a/tests/testthat/test-p_adjust.R +++ b/tests/testthat/test-p_adjust.R @@ -118,7 +118,7 @@ test_that("model_parameters, simultaenous confidence intervals", { data = qol_cancer ) set.seed(123) - mp <- model_parameters(model, p_adjust = "sup-t", ci_method = "wald") + mp <- model_parameters(model, p_adjust = "sup-t") expect_equal(mp$p, c(0, 0.27904, 0, 0, NA, NA), tolerance = 1e-3) expect_equal( mp$CI_low, diff --git a/tests/testthat/test-p_value.R b/tests/testthat/test-p_value.R index 53d9275e6..e1fc0cfc0 100644 --- a/tests/testthat/test-p_value.R +++ b/tests/testthat/test-p_value.R @@ -122,9 +122,8 @@ test_that("p_value", { expect_equal(p_value(model)$p[2], 0, tolerance = 0.01) # Mixed models - skip_if_not_installed("lmerTest") model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars) - expect_equal(p_value(model)$p[1], 0.2242536, tolerance = 0.01) + expect_equal(p_value(model)$p[1], 0.206219, tolerance = 0.01) expect_equal(p_value(model, method = "normal")$p[1], 0.1956467, tolerance = 0.01) expect_equal(p_value(model, method = "kr")$p[1], 0.319398, tolerance = 0.01) diff --git a/tests/testthat/test-parameters_table.R b/tests/testthat/test-parameters_table.R index 2ee8a5d7c..d3ba8ec56 100644 --- a/tests/testthat/test-parameters_table.R +++ b/tests/testthat/test-parameters_table.R @@ -14,8 +14,7 @@ test_that("parameters_table 2", { skip_if_not_installed("lme4") x <- model_parameters( lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris), - effects = "fixed", - ci_method = "wald" + effects = "fixed" ) tab <- insight::format_table(x) expect_true(all( From fee935f024c15f28865af5b36e3877f8731618f1 Mon Sep 17 00:00:00 2001 From: Jeffrey Girard Date: Mon, 19 Oct 2026 09:10:56 -0500 Subject: [PATCH 32/33] Fix failing tests for the Satterthwaite default - The robust vcov test now fits the model with lmerTest::lmer(), because lme4::lmer() models no longer get Satterthwaite by default. - The "message once" test resets the option first, because an earlier test in the same session can already have shown the message. - The printing test for compare_parameters() expects the profile CI for the glm, because ci_method now defaults to the model's own method. - Fix typos in the lmerMod message. - Update the compare_parameters() help page for the new ci_method default. --- R/methods_lme4.R | 2 +- man/compare_parameters.Rd | 4 ++-- tests/testthat/test-lmerTest.R | 6 ++++-- tests/testthat/test-printing2.R | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/R/methods_lme4.R b/R/methods_lme4.R index 8ed5af18b..c311968fb 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -304,7 +304,7 @@ se_mixed_default <- function(model) { setequal(mod_class, "lmerMod") ) { insight::format_alert( - 'Concider setting `ci_method = "satterthwaite"` for better covarage and type-1 error control.', + 'Consider setting `ci_method = "satterthwaite"` for better coverage and type-1 error control.', "This message will only show once per session." ) options(.suggest_satterthwaite_for_lmerMod = FALSE) diff --git a/man/compare_parameters.Rd b/man/compare_parameters.Rd index 11534dd13..e7c815eb8 100644 --- a/man/compare_parameters.Rd +++ b/man/compare_parameters.Rd @@ -12,7 +12,7 @@ compare_parameters( component = "conditional", standardize = NULL, exponentiate = FALSE, - ci_method = "wald", + ci_method = NULL, p_adjust = NULL, select = NULL, column_names = NULL, @@ -32,7 +32,7 @@ compare_models( component = "conditional", standardize = NULL, exponentiate = FALSE, - ci_method = "wald", + ci_method = NULL, p_adjust = NULL, select = NULL, column_names = NULL, diff --git a/tests/testthat/test-lmerTest.R b/tests/testthat/test-lmerTest.R index f85329613..9ef3fb306 100644 --- a/tests/testthat/test-lmerTest.R +++ b/tests/testthat/test-lmerTest.R @@ -49,7 +49,7 @@ test_that("mixed-model defaults use satterthwaite for lmerModLmerTest", { test_that("satterthwaite default keeps a robust vcov", { skip_if_not_installed("clubSandwich") data("sleepstudy", package = "lme4") - m <- lme4::lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy) + m <- lmerTest::lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy) out <- model_parameters( m, effects = "fixed", @@ -80,6 +80,8 @@ test_that("glmer", { test_that("lmerMod with lme4 give a warning once", { data("sleepstudy", package = "lme4") m <- lme4::lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy) - expect_message(ci(m)) + # other tests in this session may already have shown the message + withr::local_options(.suggest_satterthwaite_for_lmerMod = TRUE) + expect_message(ci(m), "satterthwaite") expect_no_message(ci(m)) }) diff --git a/tests/testthat/test-printing2.R b/tests/testthat/test-printing2.R index 04ff9eaf0..4339284a3 100644 --- a/tests/testthat/test-printing2.R +++ b/tests/testthat/test-printing2.R @@ -233,7 +233,7 @@ withr::with_options(list(parameters_interaction = "*", easystats_table_width = I "Parameter | m0 | m1 | m2", "--------------------------------------------------------------------------------", "(Intercept) | 0.91 ( 0.75, 1.07) | 0.68 (-0.54, 1.91) | 1.41 ( 1.06, 1.75)", - "child | -1.23 (-1.39, -1.08) | -1.67 (-1.84, -1.51) | -0.53 (-0.77, -0.29)", + "child | -1.23 (-1.40, -1.08) | -1.67 (-1.84, -1.51) | -0.53 (-0.77, -0.29)", "camper [1] | 1.05 ( 0.88, 1.23) | 0.94 ( 0.77, 1.12) | 0.58 ( 0.39, 0.78)", "zg | | | 0.13 ( 0.05, 0.21)", "", From 1251d6d7f1ffde50a827acb57a2395ce45bb5d73 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" <35330040+mattansb@users.noreply.github.com> Date: Tue, 20 Oct 2026 08:59:59 +0300 Subject: [PATCH 33/33] Update R/compare_parameters.R Co-authored-by: Jeffrey Girard --- R/compare_parameters.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/compare_parameters.R b/R/compare_parameters.R index 17e2e01c3..3971db4e2 100644 --- a/R/compare_parameters.R +++ b/R/compare_parameters.R @@ -185,7 +185,8 @@ compare_parameters <- function( model, exclude = c("bmerMod", "bayesx", "blmerMod", "bglmerMod") ) && - !ci_method %in% c("hdi", "quantile", "ci", "eti", "si", "bci", "bcai") + (is.null(ci_method) || + !ci_method %in% c("hdi", "quantile", "ci", "eti", "si", "bci", "bcai")) ) { # nolint ci_method_tmp <- "eti"