From 503e983c4fcec1cec8d0c64e7a3a75d619feac54 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 1 Jan 2025 18:11:24 +0100 Subject: [PATCH 1/9] `parameters.fixest`: Uninformative error Fixes #1054 --- DESCRIPTION | 2 +- NEWS.md | 5 ++ R/1_model_parameters.R | 198 +++++++++++++++++++++-------------------- R/methods_fixest.R | 45 ++++------ R/methods_mmrm.R | 53 ++++------- 5 files changed, 143 insertions(+), 160 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 09f8f5dcf..e28c367b8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.24.0.4 +Version: 0.24.0.5 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 01e162617..4f179d778 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ # parameters 0.24.1 +## Changes + +* `model_parameters()` now gives informative error messages for more model + classes than before when the function fails to extract model parameters. + ## Bug fixes * Fixed issue when printing `model_parameters()` with models from `mgcv::gam()`. diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index 41c0d073e..b8eb05dbb 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -605,32 +605,31 @@ model_parameters.default <- function(model, ) # extract model parameters table, as data frame - out <- tryCatch( - .model_parameters_generic( - model = model, - ci = ci, - ci_method = ci_method, - bootstrap = bootstrap, - iterations = iterations, - merge_by = "Parameter", - standardize = standardize, - exponentiate = exponentiate, - p_adjust = p_adjust, - include_info = include_info, - keep_parameters = keep, - drop_parameters = drop, - vcov = vcov, - vcov_args = vcov_args, - verbose = verbose, - ... - ), - error = function(e) { - fail <- NA - attr(fail, "error") <- gsub(" ", " ", gsub("\\n", "", e$message), fixed = TRUE) - fail - } + out <- .model_parameters_generic( + model = model, + ci = ci, + ci_method = ci_method, + bootstrap = bootstrap, + iterations = iterations, + merge_by = "Parameter", + standardize = standardize, + exponentiate = exponentiate, + p_adjust = p_adjust, + include_info = include_info, + keep_parameters = keep, + drop_parameters = drop, + vcov = vcov, + vcov_args = vcov_args, + verbose = verbose, + ... ) + attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model)) + out +} + + +.fail_error_message <- function(out, model) { # tell user if something went wrong... if (length(out) == 1 && isTRUE(is.na(out))) { insight::format_error( @@ -650,14 +649,9 @@ model_parameters.default <- function(model, ) ) } - - attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model)) - out } - - # helper function for the composition of the parameters table, # including a bunch of attributes required for further processing # (like printing etc.) @@ -682,76 +676,90 @@ model_parameters.default <- function(model, ...) { dots <- list(...) - # ==== 1. first step, extracting (bootstrapped) model parameters ------- - - # Processing, bootstrapped parameters - if (bootstrap) { - # set default method for bootstrapped CI - if (is.null(ci_method) || missing(ci_method)) { - ci_method <- "quantile" - } - - fun_args <- list( - model, - iterations = iterations, - ci = ci, - ci_method = ci_method - ) - fun_args <- c(fun_args, dots) - params <- do.call("bootstrap_parameters", fun_args) + out <- tryCatch( + { + # ==== 1. first step, extracting (bootstrapped) model parameters ------- + + # Processing, bootstrapped parameters + if (bootstrap) { + # set default method for bootstrapped CI + if (is.null(ci_method) || missing(ci_method)) { + ci_method <- "quantile" + } + + fun_args <- list( + model, + iterations = iterations, + ci = ci, + ci_method = ci_method + ) + fun_args <- c(fun_args, dots) + params <- do.call("bootstrap_parameters", fun_args) + + # Processing, non-bootstrapped parameters + } else { + # set default method for CI + if (is.null(ci_method) || missing(ci_method)) { + ci_method <- "wald" + } + + fun_args <- list( + model, + ci = ci, + component = component, + merge_by = merge_by, + standardize = standardize, + effects = effects, + ci_method = ci_method, + p_adjust = p_adjust, + keep_parameters = keep_parameters, + drop_parameters = drop_parameters, + verbose = verbose, + vcov = vcov, + vcov_args = vcov_args + ) + fun_args <- c(fun_args, dots) + params <- do.call(".extract_parameters_generic", fun_args) + } + + + # ==== 2. second step, exponentiate ------- + + # exponentiate coefficients and SE/CI, if requested + params <- .exponentiate_parameters(params, model, exponentiate) + + + # ==== 3. third step, add information as attributes ------- + + # add further information as attributes + params <- .add_model_parameters_attributes( + params, + model, + ci, + exponentiate, + bootstrap, + iterations, + ci_method = ci_method, + p_adjust = p_adjust, + include_info = include_info, + verbose = verbose, + ... + ) - # Processing, non-bootstrapped parameters - } else { - # set default method for CI - if (is.null(ci_method) || missing(ci_method)) { - ci_method <- "wald" + class(params) <- c("parameters_model", "see_parameters_model", class(params)) + params + }, + error = function(e) { + fail <- NA + attr(fail, "error") <- gsub(" ", " ", gsub("\\n", "", e$message), fixed = TRUE) + fail } - - fun_args <- list( - model, - ci = ci, - component = component, - merge_by = merge_by, - standardize = standardize, - effects = effects, - ci_method = ci_method, - p_adjust = p_adjust, - keep_parameters = keep_parameters, - drop_parameters = drop_parameters, - verbose = verbose, - vcov = vcov, - vcov_args = vcov_args - ) - fun_args <- c(fun_args, dots) - params <- do.call(".extract_parameters_generic", fun_args) - } - - - # ==== 2. second step, exponentiate ------- - - # exponentiate coefficients and SE/CI, if requested - params <- .exponentiate_parameters(params, model, exponentiate) - - - # ==== 3. third step, add information as attributes ------- - - # add further information as attributes - params <- .add_model_parameters_attributes( - params, - model, - ci, - exponentiate, - bootstrap, - iterations, - ci_method = ci_method, - p_adjust = p_adjust, - include_info = include_info, - verbose = verbose, - ... ) - class(params) <- c("parameters_model", "see_parameters_model", class(params)) - params + # check if everything is ok + .fail_error_message(out, model) + + out } diff --git a/R/methods_fixest.R b/R/methods_fixest.R index ca058dcb4..d2252242f 100644 --- a/R/methods_fixest.R +++ b/R/methods_fixest.R @@ -33,36 +33,25 @@ model_parameters.fixest <- function(model, } # extract model parameters table, as data frame - out <- tryCatch( - { - .model_parameters_generic( - model = model, - ci = ci, - ci_method = ci_method, - bootstrap = bootstrap, - iterations = iterations, - merge_by = "Parameter", - standardize = standardize, - exponentiate = exponentiate, - p_adjust = p_adjust, - include_info = include_info, - keep_parameters = keep, - drop_parameters = drop, - vcov = vcov, - vcov_args = vcov_args, - verbose = verbose, - ... - ) - }, - error = function(e) { - NULL - } + out <- .model_parameters_generic( + model = model, + ci = ci, + ci_method = ci_method, + bootstrap = bootstrap, + iterations = iterations, + merge_by = "Parameter", + standardize = standardize, + exponentiate = exponentiate, + p_adjust = p_adjust, + include_info = include_info, + keep_parameters = keep, + drop_parameters = drop, + vcov = vcov, + vcov_args = vcov_args, + verbose = verbose, + ... ) - if (is.null(out)) { - insight::format_error("Something went wrong... :-/") - } - attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model)) out } diff --git a/R/methods_mmrm.R b/R/methods_mmrm.R index d786dca5d..c93a0d5fb 100644 --- a/R/methods_mmrm.R +++ b/R/methods_mmrm.R @@ -27,44 +27,25 @@ model_parameters.mmrm <- function(model, } # extract model parameters table, as data frame - out <- tryCatch( - .model_parameters_generic( - model = model, - ci = ci, - ci_method = ci_method, - bootstrap = bootstrap, - iterations = iterations, - merge_by = "Parameter", - standardize = standardize, - exponentiate = exponentiate, - p_adjust = p_adjust, - include_info = include_info, - keep_parameters = keep, - drop_parameters = drop, - vcov = NULL, - vcov_args = NULL, - verbose = verbose, - ... - ), - error = function(e) { - fail <- NA - attr(fail, "error") <- gsub(" ", " ", gsub("\\n", "", e$message), fixed = TRUE) - fail - } + out <- .model_parameters_generic( + model = model, + ci = ci, + ci_method = ci_method, + bootstrap = bootstrap, + iterations = iterations, + merge_by = "Parameter", + standardize = standardize, + exponentiate = exponentiate, + p_adjust = p_adjust, + include_info = include_info, + keep_parameters = keep, + drop_parameters = drop, + vcov = NULL, + vcov_args = NULL, + verbose = verbose, + ... ) - # tell user if something went wrong... - if (length(out) == 1 && isTRUE(is.na(out))) { - insight::format_error( - paste0( - "Sorry, `model_parameters()` failed with the following error (possible class `", - class(model)[1], - "` not supported):\n" - ), - attr(out, "error") - ) - } - attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model)) out } From f86634155ad2b46e568bffe09e51250b71d2c1cf Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 1 Jan 2025 18:32:30 +0100 Subject: [PATCH 2/9] fix standard_error.fixest, add test --- R/methods_fixest.R | 9 +++++-- .../_snaps/model_parameters.fixest.md | 25 +++++++++++++++++++ tests/testthat/test-model_parameters.fixest.R | 14 +++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/R/methods_fixest.R b/R/methods_fixest.R index d2252242f..5d0ad501b 100644 --- a/R/methods_fixest.R +++ b/R/methods_fixest.R @@ -65,7 +65,7 @@ standard_error.fixest <- function(model, vcov = NULL, vcov_args = NULL, ...) { # get standard errors from summary # see https://github.com/easystats/parameters/issues/1039 stats <- summary(model) - SE <- as.vector(stats$coeftable[, "Std. Error"]) + SE <- stats$coeftable[, "Std. Error"] } else { # we don't want to wrap this in a tryCatch because the `fixest` error is # informative when `vcov` is wrong. @@ -73,9 +73,14 @@ standard_error.fixest <- function(model, vcov = NULL, vcov_args = NULL, ...) { SE <- sqrt(diag(V)) } + # remove .theta parameter + if (".theta" %in% names(SE)) { + SE <- SE[names(SE) != ".theta"] + } + .data_frame( Parameter = params$Parameter, - SE = SE + SE = as.vector(SE) ) } diff --git a/tests/testthat/_snaps/model_parameters.fixest.md b/tests/testthat/_snaps/model_parameters.fixest.md index dacb2944e..a0907f7e4 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/test-model_parameters.fixest.R b/tests/testthat/test-model_parameters.fixest.R index 50cf3ea5b..9a8d175ef 100644 --- a/tests/testthat/test-model_parameters.fixest.R +++ b/tests/testthat/test-model_parameters.fixest.R @@ -133,3 +133,17 @@ test_that("standard errors, Sun and Abraham", { out <- model_parameters(m) expect_equal(out$SE, m$coeftable[, "Std. Error"], tolerance = 1e-4, ignore_attr = TRUE) }) + + +skip_if_not_installed("withr") +skip_if_not_installed("glmmTMB") + +withr::with_options( + list(parameters_warning_exponentiate = TRUE), + test_that("model_parameters works for fixest-negbin", { + data(Salamanders, package = "glmmTMB") + mod <- fixest::fenegbin(count ~ mined + spp, data = Salamanders) + out <- model_parameters(mod) + expect_snapshot(print(out)) + }) +) From 384e4a4a21c3324964d219a6039698057013c142 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 1 Jan 2025 22:57:02 +0100 Subject: [PATCH 3/9] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e28c367b8..9f8a00dd4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -224,4 +224,4 @@ Config/testthat/edition: 3 Config/testthat/parallel: true Config/Needs/website: easystats/easystatstemplate Config/rcmdcheck/ignore-inconsequential-notes: true -Remotes: easystats/datawizard, easystats/performance +Remotes: easystats/insight, easystats/datawizard, easystats/performance From 0121a9f5639a6337f4aa62f12bd9980fe70f914c Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 2 Jan 2025 12:13:05 +0100 Subject: [PATCH 4/9] styler --- tests/testthat/test-geeglm.R | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-geeglm.R b/tests/testthat/test-geeglm.R index 96746a4de..fec37180c 100644 --- a/tests/testthat/test-geeglm.R +++ b/tests/testthat/test-geeglm.R @@ -1,13 +1,12 @@ skip_if_not_installed("geepack") data(warpbreaks) -m1 <- - geepack::geeglm( - breaks ~ tension, - id = wool, - data = warpbreaks, - family = poisson, - corstr = "ar1" - ) +m1 <- geepack::geeglm( + breaks ~ tension, + id = wool, + data = warpbreaks, + family = poisson, + corstr = "ar1" +) test_that("ci", { expect_equal( From bdf3a07ddc74271ce5075dd3c20830f99ccd3bd2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 2 Jan 2025 12:16:46 +0100 Subject: [PATCH 5/9] update snapshots --- .../_snaps/model_parameters_ordinal.md | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/testthat/_snaps/model_parameters_ordinal.md b/tests/testthat/_snaps/model_parameters_ordinal.md index 9b9a76bcf..11f04370b 100644 --- a/tests/testthat/_snaps/model_parameters_ordinal.md +++ b/tests/testthat/_snaps/model_parameters_ordinal.md @@ -5,13 +5,13 @@ Output # Intercept - Parameter | Odds Ratio | SE | 95% CI | z | p - ---------------------------------------------------------------------------- - Confidence1|Confidence2 | 0.48 | 0.02 | [0.45, 0.52] | -20.13 | < .001 - Confidence2|Confidence3 | 0.85 | 0.03 | [0.80, 0.91] | -5.02 | < .001 - Confidence3|Confidence4 | 1.30 | 0.04 | [1.23, 1.39] | 8.52 | < .001 - Confidence4|Confidence5 | 2.01 | 0.07 | [1.88, 2.14] | 20.39 | < .001 - Confidence5|Confidence6 | 3.44 | 0.15 | [3.16, 3.74] | 29.03 | < .001 + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------------- + Confidence1|Confidence2 | 0.48 | 0.02 | [0.45, 0.52] | -20.13 | < .001 + Confidence2|Confidence3 | 0.85 | 0.03 | [0.80, 0.91] | -5.02 | < .001 + Confidence3|Confidence4 | 1.30 | 0.04 | [1.23, 1.39] | 8.52 | < .001 + Confidence4|Confidence5 | 2.01 | 0.07 | [1.88, 2.14] | 20.39 | < .001 + Confidence5|Confidence6 | 3.44 | 0.15 | [3.16, 3.74] | 29.03 | < .001 # Location Parameters @@ -36,13 +36,13 @@ Output # Intercept - Parameter | Odds Ratio | SE | 95% CI | z | p - ---------------------------------------------------------------------------- - Confidence1|Confidence2 | 0.48 | 0.02 | [0.45, 0.52] | -20.13 | < .001 - Confidence2|Confidence3 | 0.85 | 0.03 | [0.80, 0.91] | -5.02 | < .001 - Confidence3|Confidence4 | 1.30 | 0.04 | [1.23, 1.39] | 8.52 | < .001 - Confidence4|Confidence5 | 2.01 | 0.07 | [1.88, 2.14] | 20.39 | < .001 - Confidence5|Confidence6 | 3.44 | 0.15 | [3.16, 3.74] | 29.03 | < .001 + Parameter | Coefficient | SE | 95% CI | z | p + ----------------------------------------------------------------------------- + Confidence1|Confidence2 | 0.48 | 0.02 | [0.45, 0.52] | -20.13 | < .001 + Confidence2|Confidence3 | 0.85 | 0.03 | [0.80, 0.91] | -5.02 | < .001 + Confidence3|Confidence4 | 1.30 | 0.04 | [1.23, 1.39] | 8.52 | < .001 + Confidence4|Confidence5 | 2.01 | 0.07 | [1.88, 2.14] | 20.39 | < .001 + Confidence5|Confidence6 | 3.44 | 0.15 | [3.16, 3.74] | 29.03 | < .001 # Location Parameters From 0c1b769521e894a0e6f694cfa91a0faeb6f94843 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 2 Jan 2025 12:51:00 +0100 Subject: [PATCH 6/9] update vignette --- vignettes/demean.Rmd | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/vignettes/demean.Rmd b/vignettes/demean.Rmd index e59ff6df4..d3660c961 100644 --- a/vignettes/demean.Rmd +++ b/vignettes/demean.Rmd @@ -27,7 +27,6 @@ knitr::opts_chunk$set( pkgs <- c( "datawizard", - "poorman", "see", "ggplot2", "parameters", @@ -110,10 +109,7 @@ and as such, FE avoids estimating a parameter for each higher-level unit. ## Computing the de-meaned and group-meaned variables ```{r} -qol_cancer <- cbind( - qol_cancer, - datawizard::demean(qol_cancer, select = c("phq4", "QoL"), by = "ID") -) +qol_cancer <- datawizard::demean(qol_cancer, select = c("phq4", "QoL"), by = "ID") ``` Now we have: @@ -330,7 +326,6 @@ faster, typists make more mistakes (individual-level pattern). ```{r} library(ggplot2) -library(poorman) library(see) set.seed(123) @@ -346,15 +341,15 @@ d <- do.call(rbind, lapply(1:n, function(i) { ) })) -d <- d %>% - group_by(grp) %>% - mutate(x = rev(15 - (x + 1.5 * as.numeric(grp)))) %>% - ungroup() +d <- d |> + datawizard::data_group(grp) |> + datawizard::data_modify(x = rev(15 - (x + 1.5 * as.numeric(grp)))) |> + datawizard::data_ungroup() labs <- c("very slow", "slow", "average", "fast", "very fast") levels(d$grp) <- rev(labs) -d <- cbind(d, datawizard::demean(d, c("x", "y"), by = "grp")) +d <- datawizard::demean(d, c("x", "y"), by = "grp") ``` Let's look at the raw data... @@ -518,15 +513,15 @@ d$grp[sample(which(d$grp == 8), 10)] <- 6 d$grp[sample(which(d$grp == 4), 8)] <- 2 d$grp[sample(which(d$grp == 10), 9)] <- 6 -d <- d %>% - group_by(grp) %>% - mutate(x = rev(15 - (x + 1.5 * as.numeric(grp)))) %>% - ungroup() +d <- d |> + datawizard::data_group(grp) |> + datawizard::data_modify(x = rev(15 - (x + 1.5 * as.numeric(grp)))) |> + datawizard::data_ungroup() labs <- c("very slow", "slow", "average", "fast", "very fast") levels(d$grp) <- rev(labs) -d <- cbind(d, datawizard::demean(d, c("x", "y"), by = "grp")) +d <- datawizard::demean(d, c("x", "y"), by = "grp") # Between-subject effect of typing speed m1 <- lm(y ~ x_between, data = d) From b2f99bf9f0fd225911cb95150582a0a438a176a4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 2 Jan 2025 12:58:28 +0100 Subject: [PATCH 7/9] styler --- R/1_model_parameters.R | 2 -- R/4_standard_error.R | 6 ---- R/5_simulate_model.R | 5 ---- R/bootstrap_model.R | 4 --- R/ci_kenward.R | 1 - R/ci_profile_boot.R | 3 -- R/cluster_analysis.R | 3 -- R/cluster_discrimination.R | 1 - R/cluster_meta.R | 4 --- R/convert_efa_to_cfa.R | 5 ---- R/display.R | 14 --------- R/dof_kenward.R | 2 -- R/dof_ml1.R | 4 --- R/dominance_analysis.R | 2 -- R/equivalence_test.R | 18 ------------ R/extract_parameters.R | 11 ------- R/extract_parameters_anova.R | 4 --- R/extract_random_parameters.R | 1 - R/extract_random_variances.R | 11 ------- R/factor_analysis.R | 2 -- R/format.R | 4 --- R/format_p_adjust.R | 3 -- R/format_parameters.R | 3 -- R/methods_BayesFM.R | 1 - R/methods_BayesFactor.R | 2 -- R/methods_aov.R | 7 ----- R/methods_base.R | 4 --- R/methods_brglm2.R | 4 --- R/methods_cplm.R | 4 --- R/methods_emmeans.R | 2 -- R/methods_fixest.R | 3 -- R/methods_gam.R | 2 -- R/methods_glmmTMB.R | 4 --- R/methods_glmx.R | 1 - R/methods_hclust.R | 1 - R/methods_htest.R | 26 ---------------- R/methods_kmeans.R | 8 ----- R/methods_lavaan.R | 9 ------ R/methods_lm.R | 2 -- R/methods_lme4.R | 1 - R/methods_lqmm.R | 2 -- R/methods_lrm.R | 4 --- R/methods_mass.R | 3 -- R/methods_metaplus.R | 9 ------ R/methods_mfx.R | 4 --- R/methods_mhurdle.R | 1 - R/methods_model_fit.R | 4 --- R/methods_nlme.R | 2 -- R/methods_ordinal.R | 5 ---- R/methods_other.R | 2 -- R/methods_panelr.R | 5 ---- R/methods_plm.R | 2 -- R/methods_posterior.R | 3 -- R/methods_pscl.R | 5 ---- R/methods_quantreg.R | 7 ----- R/methods_survey.R | 6 ---- R/methods_survival.R | 7 ----- R/methods_varest.R | 5 ---- R/methods_vgam.R | 5 ---- R/n_clusters.R | 6 ---- R/n_clusters_easystats.R | 13 -------- R/n_factors.R | 4 --- R/p_function.R | 1 - R/p_significance.R | 1 - R/p_value_kenward.R | 4 --- R/parameters_type.R | 6 ---- R/pool_parameters.R | 3 -- R/principal_components.R | 6 ---- R/print.parameters_model.R | 11 ------- R/print_html.R | 1 - R/print_md.R | 14 --------- R/random_parameters.R | 2 -- R/reduce_parameters.R | 18 ------------ R/reshape_loadings.R | 4 --- R/select_parameters.R | 1 - R/standardize_info.R | 12 -------- R/standardize_parameters.R | 5 ---- R/utils.R | 2 -- R/utils_cleaners.R | 2 -- R/utils_format.R | 14 --------- R/utils_model_parameters.R | 7 ----- R/utils_pca_efa.R | 31 -------------------- tests/testthat/test-GLMMadaptive.R | 1 - tests/testthat/test-glmer.R | 1 - tests/testthat/test-glmmTMB.R | 2 -- tests/testthat/test-model_parameters.anova.R | 1 - tests/testthat/test-model_parameters_df.R | 1 - tests/testthat/test-p_value.R | 1 - tests/testthat/test-quantreg.R | 1 - tests/testthat/test-random_effects_ci.R | 10 ------- tests/testthat/test-robust.R | 6 ---- tests/testthat/test-standardize_parameters.R | 3 -- 92 files changed, 470 deletions(-) diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index b8eb05dbb..89b90d223 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -763,8 +763,6 @@ model_parameters.default <- function(model, } - - #################### .glm ---------------------- diff --git a/R/4_standard_error.R b/R/4_standard_error.R index 07a7c9c46..3b0727c56 100644 --- a/R/4_standard_error.R +++ b/R/4_standard_error.R @@ -70,7 +70,6 @@ standard_error <- function(model, ...) { } - # Default methods --------------------------------------------------------- #' @rdname standard_error @@ -160,8 +159,6 @@ standard_error.default <- function(model, } - - # helper ----------------------------------------------------------------- @@ -192,15 +189,12 @@ standard_error.default <- function(model, } - .check_vcov_args <- function(robust, ...) { dots <- list(...) isTRUE(isTRUE(robust) || isTRUE(dots$robust) || ("vcov" %in% names(dots) && !is.null(dots[["vcov"]]))) } - - # .ranef_se <- function(x) { # insight::check_if_installed("lme4") # diff --git a/R/5_simulate_model.R b/R/5_simulate_model.R index 8cafc20b4..16b9984c3 100644 --- a/R/5_simulate_model.R +++ b/R/5_simulate_model.R @@ -56,7 +56,6 @@ simulate_model <- function(model, iterations = 1000, ...) { } - # Models with single component only ----------------------------------------- #' @rdname simulate_model @@ -224,10 +223,6 @@ simulate_model.brmultinom <- simulate_model.default simulate_model.bracl <- simulate_model.default - - - - # helper ----------------------------------------- diff --git a/R/bootstrap_model.R b/R/bootstrap_model.R index 46a18a1ae..21c426a36 100644 --- a/R/bootstrap_model.R +++ b/R/bootstrap_model.R @@ -57,10 +57,6 @@ bootstrap_model <- function(model, } - - - - #' @rdname bootstrap_model #' @export bootstrap_model.default <- function(model, diff --git a/R/ci_kenward.R b/R/ci_kenward.R index f7b505399..855bf5868 100644 --- a/R/ci_kenward.R +++ b/R/ci_kenward.R @@ -20,7 +20,6 @@ ci_kenward <- function(model, ci = 0.95) { } - .ci_kenward_dof <- function(model, ci = 0.95, df_kr) { out <- lapply(ci, function(i) { .ci_dof( diff --git a/R/ci_profile_boot.R b/R/ci_profile_boot.R index 6dfc4bbb2..aa844f67d 100644 --- a/R/ci_profile_boot.R +++ b/R/ci_profile_boot.R @@ -32,7 +32,6 @@ } - # we need this function for models where confint and get_parameters return # different length (e.g. as for "polr" models) .ci_profiled2 <- function(model, ci) { @@ -98,7 +97,6 @@ } - #' @keywords internal .ci_uniroot_glmmTMB <- function(x, ci, component, ...) { # make sure "..." doesn't pass invalid arguments to package TMB @@ -157,7 +155,6 @@ } - #' @keywords internal .ci_boot_merMod <- function(x, ci, iterations = 500, effects = "fixed", ...) { insight::check_if_installed("lme4") diff --git a/R/cluster_analysis.R b/R/cluster_analysis.R index 374f070be..2d1022117 100644 --- a/R/cluster_analysis.R +++ b/R/cluster_analysis.R @@ -197,7 +197,6 @@ cluster_analysis <- function(x, } - # Apply clustering -------------------------------------------------------- @@ -286,7 +285,6 @@ cluster_analysis <- function(x, } - # Clustering Methods -------------------------------------------------------- #' @keywords internal @@ -406,7 +404,6 @@ cluster_analysis <- function(x, } - # Methods ---------------------------------------------------------------- #' @export diff --git a/R/cluster_discrimination.R b/R/cluster_discrimination.R index 9e0265199..2497004ed 100644 --- a/R/cluster_discrimination.R +++ b/R/cluster_discrimination.R @@ -34,7 +34,6 @@ cluster_discrimination.cluster_analysis <- function(x, cluster_groups = NULL, .. } - #' @export cluster_discrimination.default <- function(x, cluster_groups = NULL, ...) { if (is.null(cluster_groups)) { diff --git a/R/cluster_meta.R b/R/cluster_meta.R index 3d8335e0a..d494dd417 100644 --- a/R/cluster_meta.R +++ b/R/cluster_meta.R @@ -94,8 +94,6 @@ cluster_meta <- function(list_of_clusters, rownames = NULL, ...) { } - - #' @keywords internal .cluster_meta_matrix <- function(data) { # Internal function @@ -128,8 +126,6 @@ cluster_meta <- function(list_of_clusters, rownames = NULL, ...) { } - - # Methods ---------------------------------------------------------------- #' @export diff --git a/R/convert_efa_to_cfa.R b/R/convert_efa_to_cfa.R index 739144bee..e0f7bc180 100644 --- a/R/convert_efa_to_cfa.R +++ b/R/convert_efa_to_cfa.R @@ -31,7 +31,6 @@ convert_efa_to_cfa <- function(model, ...) { } - #' @rdname convert_efa_to_cfa #' @inheritParams model_parameters.principal #' @export @@ -51,7 +50,6 @@ convert_efa_to_cfa.fa <- function(model, convert_efa_to_cfa.fa.ci <- convert_efa_to_cfa.fa - #' @export convert_efa_to_cfa.parameters_efa <- function(model, threshold = NULL, @@ -69,14 +67,11 @@ convert_efa_to_cfa.parameters_efa <- function(model, convert_efa_to_cfa.parameters_pca <- convert_efa_to_cfa.parameters_efa - #' @rdname convert_efa_to_cfa #' @export efa_to_cfa <- convert_efa_to_cfa - - #' @keywords internal .efa_to_cfa <- function(loadings, names = NULL, max_per_dimension = NULL, ...) { loadings <- attributes(loadings)$loadings_long diff --git a/R/display.R b/R/display.R index 6b348bc9e..4ea879a93 100644 --- a/R/display.R +++ b/R/display.R @@ -135,9 +135,6 @@ display.parameters_simulate <- display.parameters_model display.parameters_brms_meta <- display.parameters_model - - - # Compare Parameters ------------------------ @@ -167,9 +164,6 @@ display.compare_parameters <- function(object, } - - - # SEM models ------------------------ @@ -186,9 +180,6 @@ display.parameters_sem <- function(object, } - - - # PCA /EFA models ------------------------ @@ -213,9 +204,6 @@ display.parameters_efa <- function(object, format = "markdown", digits = 2, sort display.parameters_pca <- display.parameters_efa - - - # Equivalence tests ------------------------ @@ -226,8 +214,6 @@ display.equivalence_test_lm <- function(object, format = "markdown", digits = 2, } - - # Other functions ------------------------ diff --git a/R/dof_kenward.R b/R/dof_kenward.R index 4d8976ace..c6296c508 100644 --- a/R/dof_kenward.R +++ b/R/dof_kenward.R @@ -13,7 +13,6 @@ dof_kenward <- function(model) { } - # The following code was taken from the "pbkrtest" package and slightly modified #' @author Søren Højsgaard, \email{sorenh@@math.aau.dk} .kenward_adjusted_ddf <- function(model, linear_coef, adjusted_vcov) { @@ -90,7 +89,6 @@ dof_kenward <- function(model) { } - .get_SigmaG <- function(model) { insight::check_if_installed("lme4") insight::check_if_installed("Matrix") diff --git a/R/dof_ml1.R b/R/dof_ml1.R index 28cdc94d4..36c1e95b5 100644 --- a/R/dof_ml1.R +++ b/R/dof_ml1.R @@ -38,8 +38,6 @@ dof_ml1 <- function(model) { } - - .get_df_ml1_approx <- function(x, g) { if (!is.factor(g)) { g <- as.factor(g) @@ -62,8 +60,6 @@ dof_ml1 <- function(model) { } - - .find_term_assignment <- function(model_data, predictors, parameters) { parms <- unlist(lapply(seq_along(predictors), function(i) { p <- predictors[i] diff --git a/R/dominance_analysis.R b/R/dominance_analysis.R index 8981c714b..88269d2e0 100644 --- a/R/dominance_analysis.R +++ b/R/dominance_analysis.R @@ -596,8 +596,6 @@ dominance_analysis <- function(model, sets = NULL, all = NULL, } - - # methods ------------------------------ diff --git a/R/equivalence_test.R b/R/equivalence_test.R index 93aea99fb..1fd0ba776 100644 --- a/R/equivalence_test.R +++ b/R/equivalence_test.R @@ -3,7 +3,6 @@ bayestestR::equivalence_test - #' @title Equivalence test #' #' @description Compute the (conditional) equivalence test for frequentist models. @@ -268,7 +267,6 @@ equivalence_test.lm <- function(x, } - # standard models, only fixed effects ---------------------- #' @export @@ -305,9 +303,6 @@ equivalence_test.zeroinfl <- equivalence_test.lm equivalence_test.rma <- equivalence_test.lm - - - # mixed models, also random effects ---------------------- #' @export @@ -363,7 +358,6 @@ equivalence_test.glmmTMB <- equivalence_test.merMod equivalence_test.MixMod <- equivalence_test.merMod - # Special classes ------------------------- #' @export @@ -490,7 +484,6 @@ equivalence_test.ggeffects <- function(x, } - # helper ------------------- @@ -590,7 +583,6 @@ equivalence_test.ggeffects <- function(x, } - #' @keywords internal .equivalence_test_frequentist_random <- function(x, range = "default", @@ -667,8 +659,6 @@ equivalence_test.ggeffects <- function(x, } - - #' @keywords internal .equivalence_test_numeric <- function(ci = 0.95, ci_wide, @@ -736,8 +726,6 @@ equivalence_test.ggeffects <- function(x, } - - # helper --------------------- # this function simply takes the length of the range and calculates the proportion @@ -849,14 +837,9 @@ equivalence_test.ggeffects <- function(x, } - - - - # methods ---------------- - #' @export format.equivalence_test_lm <- function(x, digits = 2, @@ -899,7 +882,6 @@ format.equivalence_test_lm <- function(x, } - #' @export print.equivalence_test_lm <- function(x, digits = 2, diff --git a/R/extract_parameters.R b/R/extract_parameters.R index 919493873..98450ad8d 100644 --- a/R/extract_parameters.R +++ b/R/extract_parameters.R @@ -325,7 +325,6 @@ } - .filter_parameters <- function(params, keep = NULL, drop = NULL, verbose = TRUE) { if (!is.null(keep) && is.list(keep)) { for (i in names(keep)) { @@ -648,7 +647,6 @@ } - .add_within_between_effects <- function(model, parameters) { # This function checks whether the model contains predictors that were # "demeaned" using the "demean()" function. If so, these columns have an @@ -703,7 +701,6 @@ } - .find_within_between <- function(model, which_effect) { mf <- stats::model.frame(model) unlist(sapply(names(mf), function(i) { @@ -714,10 +711,6 @@ } - - - - # Bayes function ------------------------------------------------------ @@ -850,9 +843,6 @@ } - - - # SEM function ------------------------------------------------------ @@ -1010,7 +1000,6 @@ } - # tools ------------------------- diff --git a/R/extract_parameters_anova.R b/R/extract_parameters_anova.R index 5699a0d8c..a8ae1be26 100644 --- a/R/extract_parameters_anova.R +++ b/R/extract_parameters_anova.R @@ -83,7 +83,6 @@ } - # helpers ----- @@ -274,8 +273,6 @@ } - - # test helper ------------- @@ -330,7 +327,6 @@ } - # parameter-power ---------------- diff --git a/R/extract_random_parameters.R b/R/extract_random_parameters.R index 6b5fbb03f..268eea868 100644 --- a/R/extract_random_parameters.R +++ b/R/extract_random_parameters.R @@ -52,7 +52,6 @@ } - .extract_random_parameters.glmmTMB <- function(model, ci = 0.95, effects = "random", diff --git a/R/extract_random_variances.R b/R/extract_random_variances.R index c54f76ce1..61dbdb1b3 100644 --- a/R/extract_random_variances.R +++ b/R/extract_random_variances.R @@ -149,7 +149,6 @@ } - # workhorse ------------------------ .extract_random_variances_helper <- function(model, @@ -268,7 +267,6 @@ } - #' @export as.data.frame.VarCorr.lme <- function(x, row.names = NULL, optional = FALSE, ...) { # retrieve RE SD and COR @@ -334,9 +332,6 @@ as.data.frame.VarCorr.lme <- function(x, row.names = NULL, optional = FALSE, ... } - - - # extract CI for random SD ------------------------ .random_sd_ci <- function(model, @@ -689,9 +684,6 @@ as.data.frame.VarCorr.lme <- function(x, row.names = NULL, optional = FALSE, ... } - - - # Extract Variance and Correlation Components ---- # store essential information about variance components... @@ -843,9 +835,6 @@ as.data.frame.VarCorr.lme <- function(x, row.names = NULL, optional = FALSE, ... } - - - # glmmTMB returns a list of model information, one for conditional # and one for zero-inflation part, so here we "unlist" it, returning # only the conditional part. diff --git a/R/factor_analysis.R b/R/factor_analysis.R index bd0aa836f..c60634ab4 100644 --- a/R/factor_analysis.R +++ b/R/factor_analysis.R @@ -12,7 +12,6 @@ factor_analysis <- function(x, } - #' @export factor_analysis.data.frame <- function(x, n = "auto", @@ -42,7 +41,6 @@ factor_analysis.data.frame <- function(x, } - #' @keywords internal .factor_analysis_rotate <- function(x, n, diff --git a/R/format.R b/R/format.R index 94dd3f874..cb25e421b 100644 --- a/R/format.R +++ b/R/format.R @@ -234,9 +234,6 @@ format.parameters_simulate <- format.parameters_model format.parameters_brms_meta <- format.parameters_model - - - # Compare parameters ---------------------- @@ -467,7 +464,6 @@ format.compare_parameters <- function(x, } - # sem-models --------------------------------- #' @export diff --git a/R/format_p_adjust.R b/R/format_p_adjust.R index b1b4713a8..ab56f514d 100644 --- a/R/format_p_adjust.R +++ b/R/format_p_adjust.R @@ -30,9 +30,6 @@ format_p_adjust <- function(method) { } - - - .p_adjust <- function(params, p_adjust, model = NULL, verbose = TRUE) { # check if we have any adjustment at all, and a p-column if (!is.null(p_adjust) && "p" %in% colnames(params) && p_adjust != "none") { diff --git a/R/format_parameters.R b/R/format_parameters.R index 6f10001bd..c6cc6424c 100644 --- a/R/format_parameters.R +++ b/R/format_parameters.R @@ -62,8 +62,6 @@ format_parameters.parameters_model <- function(model, ...) { } - - # Utilities --------------------------------------------------------------- @@ -365,7 +363,6 @@ format_parameters.parameters_model <- function(model, ...) { } - # replace pretty names with value labels, when present --------------- .format_value_labels <- function(params, model = NULL) { diff --git a/R/methods_BayesFM.R b/R/methods_BayesFM.R index 008474d4e..e847dea06 100644 --- a/R/methods_BayesFM.R +++ b/R/methods_BayesFM.R @@ -112,7 +112,6 @@ model_parameters.befa <- function(model, loadings <- .wide_loadings(long_loadings, loadings_columns = names(long_loadings)[3], component_column = "Component", variable_column = "Variable") - # Add attributes attr(loadings, "model") <- model attr(loadings, "additional_arguments") <- list(...) diff --git a/R/methods_BayesFactor.R b/R/methods_BayesFactor.R index af09804ae..a6dd1fad0 100644 --- a/R/methods_BayesFactor.R +++ b/R/methods_BayesFactor.R @@ -253,8 +253,6 @@ p_value.BFBayesFactor <- function(model, ...) { } - - # helper ------- diff --git a/R/methods_aov.R b/R/methods_aov.R index b3af12ea6..38bcb2215 100644 --- a/R/methods_aov.R +++ b/R/methods_aov.R @@ -218,7 +218,6 @@ p_value.aov <- function(model, ...) { } - # .anova ------ #' @export @@ -231,7 +230,6 @@ p_value.anova <- p_value.aov model_parameters.anova <- model_parameters.aov - # .aov.list ------ #' @export @@ -244,7 +242,6 @@ p_value.aovlist <- p_value.aov model_parameters.aovlist <- model_parameters.aov - # .afex_aov ------ #' @export @@ -299,7 +296,6 @@ model_parameters.afex_aov <- function(model, } - # others ------ #' @export @@ -315,7 +311,6 @@ model_parameters.maov <- model_parameters.aov model_parameters.seqanova.svyglm <- model_parameters.aov - # helper ------------------------------ .anova_type <- function(model, type = NULL, verbose = TRUE) { @@ -486,8 +481,6 @@ model_parameters.seqanova.svyglm <- model_parameters.aov } - - # internals -------------------------- # add effect size column and related CI to the parameters diff --git a/R/methods_base.R b/R/methods_base.R index 1e071ca52..20d98595c 100644 --- a/R/methods_base.R +++ b/R/methods_base.R @@ -18,8 +18,6 @@ model_parameters.data.frame <- function(model, } - - # Standard Errors from standard classes --------------------------------------------- @@ -113,8 +111,6 @@ standard_error.parameters_standardized <- function(model, verbose = TRUE, ...) { } - - # p-Values from standard classes --------------------------------------------- #' @export diff --git a/R/methods_brglm2.R b/R/methods_brglm2.R index 9270f7491..b9cee27fb 100644 --- a/R/methods_brglm2.R +++ b/R/methods_brglm2.R @@ -144,8 +144,6 @@ p_value.bracl <- function(model, verbose = TRUE, ...) { } - - ############# .multinom -------------- @@ -284,8 +282,6 @@ simulate_parameters.multinom <- function(model, } - - ############# .brmultinom -------------- diff --git a/R/methods_cplm.R b/R/methods_cplm.R index bfcaefa16..027327ee3 100644 --- a/R/methods_cplm.R +++ b/R/methods_cplm.R @@ -188,7 +188,6 @@ p_value.zcpglm <- function(model, component = "all", ...) { } - ########## .bcpglm --------------- #' @export @@ -199,7 +198,6 @@ model_parameters.bcplm <- model_parameters.bayesQR p_value.bcplm <- p_value.brmsfit - ########## .cpglm --------------- #' @export @@ -230,7 +228,6 @@ standard_error.cpglm <- function(model, ...) { } - ########## .cpglmm --------------- #' @export @@ -309,7 +306,6 @@ standard_error.cpglmm <- function(model, ...) { } - # tools -------------------- .check_df_method <- function(df_method) { diff --git a/R/methods_emmeans.R b/R/methods_emmeans.R index 1cd68e539..f44c53672 100644 --- a/R/methods_emmeans.R +++ b/R/methods_emmeans.R @@ -251,7 +251,6 @@ model_parameters.summary_emm <- function(model, } - # standard errors ----------------- @@ -319,7 +318,6 @@ boot_em_standard_error <- function(model) { } - # p values ---------------------- diff --git a/R/methods_fixest.R b/R/methods_fixest.R index 5d0ad501b..11c6d1971 100644 --- a/R/methods_fixest.R +++ b/R/methods_fixest.R @@ -114,8 +114,6 @@ p_value.feglm <- function(model, ...) { } - - # .fixest_multi ----------------------------------- #' @export @@ -230,7 +228,6 @@ simulate_model.fixest_multi <- function(model, ...) { } - # helper --------------------------------- .get_fixest_multi_columns <- function(model) { diff --git a/R/methods_gam.R b/R/methods_gam.R index 43a31a21e..248b47d42 100644 --- a/R/methods_gam.R +++ b/R/methods_gam.R @@ -81,8 +81,6 @@ simulate_model.gam <- function(model, iterations = 1000, ...) { } - - #################### .list ------ diff --git a/R/methods_glmmTMB.R b/R/methods_glmmTMB.R index d948310ac..be69af49a 100644 --- a/R/methods_glmmTMB.R +++ b/R/methods_glmmTMB.R @@ -533,8 +533,6 @@ standard_error.glmmTMB <- function(model, } - - # simulate model ----- @@ -627,8 +625,6 @@ simulate_model.glmmTMB <- function(model, } - - # simulate_parameters ----- #' @export diff --git a/R/methods_glmx.R b/R/methods_glmx.R index 90711db4e..58dcdbe34 100644 --- a/R/methods_glmx.R +++ b/R/methods_glmx.R @@ -64,7 +64,6 @@ p_value.glmx <- function(model, ...) { } - #' @export simulate_model.glmx <- function(model, iterations = 1000, component = "all", ...) { component <- insight::validate_argument( diff --git a/R/methods_hclust.R b/R/methods_hclust.R index cd9bf93b0..f25eb916b 100644 --- a/R/methods_hclust.R +++ b/R/methods_hclust.R @@ -147,7 +147,6 @@ model_parameters.pvclust <- function(model, data = NULL, clusters = NULL, ci = 0 } - # Utils ------------------------------------------------------------------- diff --git a/R/methods_htest.R b/R/methods_htest.R index 4cf38ba3f..e3337804b 100644 --- a/R/methods_htest.R +++ b/R/methods_htest.R @@ -107,7 +107,6 @@ model_parameters.pairwise.htest <- function(model, verbose = TRUE, ...) { } - # survey-table -------------------- #' @export @@ -116,7 +115,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - # ==== extract parameters ==== #' @keywords internal @@ -176,8 +174,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest Box-Pierce ---------------------- #' @keywords internal @@ -193,7 +189,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - # extract htest correlation ---------------------- #' @keywords internal @@ -241,8 +236,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest ranktest ---------------------- #' @keywords internal @@ -294,8 +287,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest leveneTest ---------------------- #' @keywords internal @@ -311,8 +302,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest var.test ---------------------- #' @keywords internal @@ -332,8 +321,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest ttest ---------------------- #' @keywords internal @@ -442,8 +429,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest oneway ---------------------- #' @keywords internal @@ -459,8 +444,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest chi2 ---------------------- #' @keywords internal @@ -512,8 +495,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest prop ---------------------- #' @keywords internal @@ -541,8 +522,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # extract htest binom ---------------------- #' @keywords internal @@ -562,8 +541,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # ==== effectsizes ===== .add_effectsize_htest <- function(model, @@ -651,8 +628,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - - # ==== add attributes ==== #' @keywords internal @@ -718,7 +693,6 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { } - #' @keywords internal .add_htest_attributes <- function(params, model, diff --git a/R/methods_kmeans.R b/R/methods_kmeans.R index 3ee0d0241..46b6db308 100644 --- a/R/methods_kmeans.R +++ b/R/methods_kmeans.R @@ -32,9 +32,6 @@ model_parameters.kmeans <- function(model, ...) { } - - - # factoextra::hkmeans ----------------------------------------------------- @@ -42,7 +39,6 @@ model_parameters.kmeans <- function(model, ...) { model_parameters.hkmeans <- model_parameters.kmeans - # Methods ------------------------------------------------------------------- @@ -65,10 +61,6 @@ print.parameters_clusters <- function(x, digits = 2, ...) { } - - - - # Predict ----------------------------------------------------------------- diff --git a/R/methods_lavaan.R b/R/methods_lavaan.R index f4a43a8f5..bef412a0b 100644 --- a/R/methods_lavaan.R +++ b/R/methods_lavaan.R @@ -36,7 +36,6 @@ model_parameters.lavaan <- function(model, } - #' @export model_parameters.blavaan <- function(model, centrality = "median", @@ -94,8 +93,6 @@ model_parameters.blavaan <- function(model, } - - # ci --------------------------- @@ -107,8 +104,6 @@ ci.lavaan <- function(x, ci = 0.95, ...) { } - - # SE --------------------------- @@ -130,8 +125,6 @@ standard_error.blavaan <- function(model, ...) { } - - # p-value --------------------------- @@ -146,8 +139,6 @@ p_value.lavaan <- function(model, ...) { p_value.blavaan <- p_value.BFBayesFactor - - # print --------------------------- #' @export diff --git a/R/methods_lm.R b/R/methods_lm.R index 42c13e0d5..35ec47fae 100644 --- a/R/methods_lm.R +++ b/R/methods_lm.R @@ -13,8 +13,6 @@ ci.lm <- function(x, ci = 0.95, method = "residual", ...) { } - - # .summary.lm --------------------- #' @export diff --git a/R/methods_lme4.R b/R/methods_lme4.R index fc8ad47f4..d4aafc841 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -268,7 +268,6 @@ standard_error.merMod <- function(model, } - # helpers -------------- .standard_errors_random <- function(model) { diff --git a/R/methods_lqmm.R b/R/methods_lqmm.R index 108af5274..8e18c5317 100644 --- a/R/methods_lqmm.R +++ b/R/methods_lqmm.R @@ -78,8 +78,6 @@ p_value.lqmm <- function(model, ...) { p_value.lqm <- p_value.lqmm - - # helper ------------------ diff --git a/R/methods_lrm.R b/R/methods_lrm.R index b5915fc4d..a04f0daeb 100644 --- a/R/methods_lrm.R +++ b/R/methods_lrm.R @@ -8,8 +8,6 @@ model_parameters.blrm <- model_parameters.bayesQR - - # standard error ------------- @@ -36,8 +34,6 @@ standard_error.rms <- standard_error.lrm standard_error.psm <- standard_error.lrm - - # p-values ----------------------- #' @export diff --git a/R/methods_mass.R b/R/methods_mass.R index bfdb891a4..9b6e4fd7c 100644 --- a/R/methods_mass.R +++ b/R/methods_mass.R @@ -36,7 +36,6 @@ ci.polr <- function(x, ci = 0.95, dof = NULL, method = "profile", ...) { } - # SE ----------------- #' @export @@ -57,7 +56,6 @@ standard_error.polr <- function(model, method = NULL, ...) { } - # p ----------------- #' @export @@ -94,7 +92,6 @@ p_value.polr <- function(model, method = NULL, ...) { } - # parameters ----------------- #' @export diff --git a/R/methods_metaplus.R b/R/methods_metaplus.R index 6eb71c55f..5bcbd98ce 100644 --- a/R/methods_metaplus.R +++ b/R/methods_metaplus.R @@ -142,8 +142,6 @@ ci.metaplus <- function(x, ...) { } - - ###### .meta_random ------------------- @@ -284,8 +282,6 @@ ci.meta_random <- function(x, method = "eti", ...) { } - - ###### .meta_fixed ------------------- #' @export @@ -300,8 +296,6 @@ standard_error.meta_fixed <- standard_error.meta_random ci.meta_fixed <- ci.meta_random - - ###### .meta_bma ------------------- @@ -400,8 +394,6 @@ standard_error.meta_bma <- standard_error.meta_random ci.meta_bma <- ci.meta_random - - # helper ------ @@ -419,7 +411,6 @@ ci.meta_bma <- ci.meta_random } - # format_parameters ----------------------------------- #' @export diff --git a/R/methods_mfx.R b/R/methods_mfx.R index 3e970577f..7ca5038bd 100644 --- a/R/methods_mfx.R +++ b/R/methods_mfx.R @@ -148,7 +148,6 @@ model_parameters.betamfx <- function(model, } - # ci ------------------ #' @export @@ -211,7 +210,6 @@ ci.betamfx <- function(x, } - # standard error ------------------ #' @export @@ -302,7 +300,6 @@ standard_error.betamfx <- function(model, component = "all", ...) { } - # p values ------------------ #' @export @@ -389,7 +386,6 @@ p_value.betamfx <- function(model, component = "all", ...) { } - # simulate model ------------------ #' @export diff --git a/R/methods_mhurdle.R b/R/methods_mhurdle.R index 8d6a97f8c..12e606a1c 100644 --- a/R/methods_mhurdle.R +++ b/R/methods_mhurdle.R @@ -86,7 +86,6 @@ standard_error.mhurdle <- function(model, component = c("all", "conditional", "z } - #' @export simulate_model.mhurdle <- function(model, iterations = 1000, component = c("all", "conditional", "zi", "zero_inflated", "infrequent_purchase", "ip", "auxiliary"), ...) { component <- match.arg(component) diff --git a/R/methods_model_fit.R b/R/methods_model_fit.R index 306a305a8..8875865fd 100644 --- a/R/methods_model_fit.R +++ b/R/methods_model_fit.R @@ -33,7 +33,6 @@ model_parameters.model_fit <- function(model, } - # ci ------------------ @@ -43,7 +42,6 @@ ci.model_fit <- function(x, ci = 0.95, method = NULL, ...) { } - # standard error ------------------ @@ -53,7 +51,6 @@ standard_error.model_fit <- function(model, ...) { } - # p values ------------------ @@ -63,7 +60,6 @@ p_value.model_fit <- function(model, ...) { } - # simulate model ------------------ diff --git a/R/methods_nlme.R b/R/methods_nlme.R index d84421bb7..d55232d8b 100644 --- a/R/methods_nlme.R +++ b/R/methods_nlme.R @@ -85,8 +85,6 @@ p_value.lme <- function(model, standard_error.lme <- standard_error.default - - ############### .gls -------------- diff --git a/R/methods_ordinal.R b/R/methods_ordinal.R index 9bda0204b..2d21b3a26 100644 --- a/R/methods_ordinal.R +++ b/R/methods_ordinal.R @@ -59,8 +59,6 @@ model_parameters.clmm2 <- model_parameters.clm2 model_parameters.clmm <- model_parameters.cpglmm - - # CI --------------------- @@ -77,7 +75,6 @@ ci.clm2 <- function(x, ci = 0.95, component = c("all", "conditional", "scale"), ci.clmm2 <- ci.clm2 - # standard errors ----------------- @@ -99,8 +96,6 @@ standard_error.clm2 <- function(model, component = "all", ...) { standard_error.clmm2 <- standard_error.clm2 - - # p values ---------------- diff --git a/R/methods_other.R b/R/methods_other.R index f92090ac1..c7b539131 100644 --- a/R/methods_other.R +++ b/R/methods_other.R @@ -20,8 +20,6 @@ p_value.complmrob <- p_value.default ci.complmrob <- ci.default - - ############# .Gam -------------- diff --git a/R/methods_panelr.R b/R/methods_panelr.R index b64b015be..d9aac01e7 100644 --- a/R/methods_panelr.R +++ b/R/methods_panelr.R @@ -112,8 +112,6 @@ standard_error.wbm <- function(model, ...) { standard_error.wbgee <- standard_error.wbm - - # p values ------------------- @@ -139,9 +137,6 @@ p_value.wbm <- function(model, ...) { p_value.wbgee <- p_value.wbm - - - # utils ------------------- diff --git a/R/methods_plm.R b/R/methods_plm.R index 271c9ee93..5d242b233 100644 --- a/R/methods_plm.R +++ b/R/methods_plm.R @@ -48,7 +48,6 @@ standard_error.plm <- function(model, vcov = NULL, vcov_args = NULL, verbose = T p_value.plm <- p_value.default - # pggls ------------------------ @@ -63,7 +62,6 @@ p_value.pggls <- function(model, ...) { } - # pgmm -------------------- diff --git a/R/methods_posterior.R b/R/methods_posterior.R index eecbc83ac..c927f9968 100644 --- a/R/methods_posterior.R +++ b/R/methods_posterior.R @@ -44,7 +44,6 @@ model_parameters.draws <- function(model, } - # Standard Errors --------------------------------------------- #' @export @@ -57,7 +56,6 @@ standard_error.draws <- function(model, verbose = TRUE, ...) { } - # p-Values --------------------------------------------- #' @export @@ -71,7 +69,6 @@ p_value.draws <- function(model, ...) { } - # helper ------------------------------ .posterior_draws_to_df <- function(x) { diff --git a/R/methods_pscl.R b/R/methods_pscl.R index 6cb4846c9..e9dcc0967 100644 --- a/R/methods_pscl.R +++ b/R/methods_pscl.R @@ -12,7 +12,6 @@ model_parameters.hurdle <- model_parameters.zcpglm model_parameters.zerocount <- model_parameters.zcpglm - # ci ----------------- #' @export @@ -48,7 +47,6 @@ ci.hurdle <- ci.zeroinfl ci.zerocount <- ci.zeroinfl - # standard error ----------------- #' @export @@ -107,7 +105,6 @@ standard_error.hurdle <- standard_error.zeroinfl standard_error.zerocount <- standard_error.zeroinfl - # p values ----------------------- #' @export @@ -161,7 +158,6 @@ p_value.hurdle <- p_value.zeroinfl p_value.zerocount <- p_value.zeroinfl - # simulate model ----------------- #' @export @@ -174,7 +170,6 @@ simulate_model.hurdle <- simulate_model.zeroinfl simulate_model.zerocount <- simulate_model.zeroinfl - # simulate paramaters ----------------- #' @export diff --git a/R/methods_quantreg.R b/R/methods_quantreg.R index bed08b33e..34f73a43a 100644 --- a/R/methods_quantreg.R +++ b/R/methods_quantreg.R @@ -39,8 +39,6 @@ model_parameters.rqs <- function(model, } - - # ci --------------------- @@ -64,9 +62,6 @@ ci.nlrq <- ci.default ci.rqs <- ci.default - - - # standard errors --------------------- @@ -191,8 +186,6 @@ standard_error.rqss <- function(model, } - - # p values --------------------- diff --git a/R/methods_survey.R b/R/methods_survey.R index 7112b822b..5469fd24a 100644 --- a/R/methods_survey.R +++ b/R/methods_survey.R @@ -53,7 +53,6 @@ model_parameters.svyglm <- function(model, } - # simulate_model ----------------------------------------- #' @export @@ -64,7 +63,6 @@ simulate_model.svyglm.nb <- simulate_model.default simulate_model.svyglm.zip <- simulate_model.default - # standard erors ----------------------------------------- #' @export @@ -98,7 +96,6 @@ standard_error.svyglm <- function(model, ...) { standard_error.svyolr <- standard_error.svyglm - # confidence intervals ----------------------------------- #' @export @@ -119,7 +116,6 @@ ci.svyglm <- function(x, ci = 0.95, method = "wald", ...) { ci.svyolr <- ci.svyglm - # p values ----------------------------------------------- ## TODO how to calculate p when ci-method is "likelihood"? @@ -161,8 +157,6 @@ p_value.svyglm.nb <- function(model, ...) { p_value.svyglm.zip <- p_value.svyglm.nb - - # helper -------------------- .ci_likelihood <- function(model, ci) { diff --git a/R/methods_survival.R b/R/methods_survival.R index 1b125009c..b375dbd5d 100644 --- a/R/methods_survival.R +++ b/R/methods_survival.R @@ -47,8 +47,6 @@ p_value.coxph <- function(model, ...) { } - - #################### .aareg ------ @@ -76,9 +74,6 @@ p_value.aareg <- function(model, ...) { } - - - #################### .survreg ------ @@ -114,8 +109,6 @@ p_value.survreg <- function(model, method = NULL, ...) { } - - #################### .riskRegression ------ diff --git a/R/methods_varest.R b/R/methods_varest.R index d666a5601..dbe37387a 100644 --- a/R/methods_varest.R +++ b/R/methods_varest.R @@ -32,7 +32,6 @@ model_parameters.varest <- function(model, } - #' @export ci.varest <- function(x, ci = 0.95, method = NULL, ...) { params <- lapply(names(x$varresult), function(i) { @@ -45,7 +44,6 @@ ci.varest <- function(x, ci = 0.95, method = NULL, ...) { } - #' @export standard_error.varest <- function(model, method = NULL, ...) { params <- lapply(names(model$varresult), function(i) { @@ -58,7 +56,6 @@ standard_error.varest <- function(model, method = NULL, ...) { } - #' @export p_value.varest <- function(model, ...) { params <- lapply(names(model$varresult), function(i) { @@ -71,7 +68,6 @@ p_value.varest <- function(model, ...) { } - #' @export simulate_model.varest <- function(model, iterations = 1000, ...) { out <- lapply(names(model$varresult), function(i) { @@ -83,7 +79,6 @@ simulate_model.varest <- function(model, iterations = 1000, ...) { } - #' @export simulate_parameters.varest <- function(model, iterations = 1000, diff --git a/R/methods_vgam.R b/R/methods_vgam.R index a0018afdb..377cdbbf5 100644 --- a/R/methods_vgam.R +++ b/R/methods_vgam.R @@ -39,8 +39,6 @@ simulate_model.vgam <- function(model, iterations = 1000, ...) { } - - ########### .vglm --------------- @@ -68,9 +66,6 @@ standard_error.vglm <- function(model, ...) { } - - - # ci.vgam <- function(x, ci = 0.95, component = c("all", "conditional", "smooth"), ...) { # component <- match.arg(component) # diff --git a/R/n_clusters.R b/R/n_clusters.R index 91bd53794..8eeff47e5 100644 --- a/R/n_clusters.R +++ b/R/n_clusters.R @@ -138,8 +138,6 @@ n_clusters <- function(x, } - - #' @keywords internal .n_clusters_mclust <- function(x, n_max = 10, ...) { insight::check_if_installed("mclust") @@ -161,8 +159,6 @@ n_clusters <- function(x, } - - # Methods ----------------------------------------------------------------- @@ -192,8 +188,6 @@ n_clusters <- function(x, } - - #' @keywords internal .n_clusters_NbClust <- function(x, fast = TRUE, nbclust_method = "kmeans", n_max = 10, indices = "all", ...) { insight::check_if_installed("NbClust") diff --git a/R/n_clusters_easystats.R b/R/n_clusters_easystats.R index 486d1c4c9..88af68244 100644 --- a/R/n_clusters_easystats.R +++ b/R/n_clusters_easystats.R @@ -36,8 +36,6 @@ n_clusters_elbow <- function(x, } - - #' @rdname n_clusters #' @examples #' \donttest{ @@ -86,7 +84,6 @@ n_clusters_gap <- function(x, } - #' @rdname n_clusters #' @examples #' \donttest{ @@ -127,7 +124,6 @@ n_clusters_silhouette <- function(x, } - #' @rdname n_clusters #' @examples #' \donttest{ @@ -196,10 +192,6 @@ n_clusters_dbscan <- function(x, } - - - - #' @rdname n_clusters #' @examples #' \donttest{ @@ -250,12 +242,9 @@ n_clusters_hclust <- function(x, } - - # Utils ------------------------------------------------------------------- - #' @keywords internal .n_clusters_factoextra <- function(x, method = "wss", @@ -272,8 +261,6 @@ n_clusters_hclust <- function(x, } - - # Printing ---------------------------------------------------------------- #' @export diff --git a/R/n_factors.R b/R/n_factors.R index 27b53c8ba..98c0dca66 100644 --- a/R/n_factors.R +++ b/R/n_factors.R @@ -357,7 +357,6 @@ n_factors <- function(x, } - #' @rdname n_factors #' @export n_components <- function(x, @@ -381,7 +380,6 @@ n_components <- function(x, } - #' @export print.n_factors <- function(x, ...) { results <- attributes(x)$summary @@ -647,8 +645,6 @@ print.n_clusters <- print.n_factors } - - #' @keywords internal .n_factors_fit <- function(x = NULL, cor = NULL, diff --git a/R/p_function.R b/R/p_function.R index 2d004c8cb..11cc8b06d 100644 --- a/R/p_function.R +++ b/R/p_function.R @@ -442,7 +442,6 @@ print_html.parameters_p_function <- function(x, } - # helper ---------- .print_p_function <- function(x, diff --git a/R/p_significance.R b/R/p_significance.R index c8f8eeb33..1812ac243 100644 --- a/R/p_significance.R +++ b/R/p_significance.R @@ -3,7 +3,6 @@ bayestestR::p_significance - #' @title Practical Significance (ps) #' #' @description Compute the probability of **Practical Significance** (*ps*), diff --git a/R/p_value_kenward.R b/R/p_value_kenward.R index 159141513..388b16c9f 100644 --- a/R/p_value_kenward.R +++ b/R/p_value_kenward.R @@ -50,8 +50,6 @@ p_value_kenward.lmerMod <- function(model, dof = NULL) { } - - # helper ------------------------------ .p_value_dof <- function(model, @@ -121,8 +119,6 @@ p_value_kenward.lmerMod <- function(model, dof = NULL) { } - - .p_value_dof_kr <- function(model, params, dof) { if ("SE" %in% colnames(params) && "SE" %in% colnames(dof)) { params$SE <- NULL diff --git a/R/parameters_type.R b/R/parameters_type.R index dd503ede1..0024459b9 100644 --- a/R/parameters_type.R +++ b/R/parameters_type.R @@ -145,7 +145,6 @@ parameters_type <- function(model, ...) { } - #' @keywords internal .parameters_type_table <- function(names, data, reference) { out <- lapply(names, .parameters_type, data = data, reference = reference) @@ -155,7 +154,6 @@ parameters_type <- function(model, ...) { } - #' @keywords internal .parameters_type <- function(name, data, reference) { if (grepl(":", name, fixed = TRUE)) { @@ -179,8 +177,6 @@ parameters_type <- function(model, ...) { } - - #' @keywords internal .parameters_type_basic <- function(name, data, reference, brackets = c("[", "]")) { if (is.na(name)) { @@ -295,7 +291,6 @@ parameters_type <- function(model, ...) { } - #' @keywords internal .poly_info <- function(x, what = "degree") { if (what == "degree") { @@ -308,7 +303,6 @@ parameters_type <- function(model, ...) { } - #' @keywords internal .list_factors_numerics <- function(data, model) { out <- list() diff --git a/R/pool_parameters.R b/R/pool_parameters.R index 46675d2c6..cd5c0fb35 100644 --- a/R/pool_parameters.R +++ b/R/pool_parameters.R @@ -316,8 +316,6 @@ pool_parameters <- function(x, } - - # helper ------ @@ -334,7 +332,6 @@ pool_parameters <- function(x, } - .add_pooled_params_attributes <- function(pooled_params, model_params, model, ci, exponentiate, verbose = TRUE) { info <- insight::model_info(model, verbose = FALSE) pretty_names <- attributes(model_params)$pretty_names diff --git a/R/principal_components.R b/R/principal_components.R index 9f3e74f8e..4caa95e63 100644 --- a/R/principal_components.R +++ b/R/principal_components.R @@ -218,9 +218,6 @@ principal_components <- function(x, } - - - #' @rdname principal_components #' @export rotated_data <- function(pca_results, verbose = TRUE) { @@ -252,7 +249,6 @@ rotated_data <- function(pca_results, verbose = TRUE) { } - #' @export principal_components.data.frame <- function(x, n = "auto", @@ -363,7 +359,6 @@ principal_components.data.frame <- function(x, data_summary <- data_summary[1:n, , drop = FALSE] - # Compute loadings if (length(model$sdev) > 1) { pca_loadings <- as.data.frame(model$rotation %*% diag(model$sdev)) @@ -445,7 +440,6 @@ principal_components.data.frame <- function(x, } - #' @keywords internal .pca_rotate <- function(x, n, diff --git a/R/print.parameters_model.R b/R/print.parameters_model.R index 61ab8cb81..e97533c91 100644 --- a/R/print.parameters_model.R +++ b/R/print.parameters_model.R @@ -379,8 +379,6 @@ print.parameters_simulate <- print.parameters_model print.parameters_brms_meta <- print.parameters_model - - # Random effects ------------------ #' @export @@ -390,8 +388,6 @@ print.parameters_random <- function(x, digits = 2, ...) { } - - # helper -------------------- .print_core <- function(x, @@ -427,8 +423,6 @@ print.parameters_random <- function(x, digits = 2, ...) { } - - .print_footer <- function(x, digits = 3, show_sigma = FALSE, @@ -464,8 +458,6 @@ print.parameters_random <- function(x, digits = 2, ...) { } - - .print_caption <- function(x, caption = NULL, format = "text") { no_caption <- attributes(x)$no_caption # no table-title for certain model tables, indicated by the no_caption attribute @@ -524,8 +516,6 @@ print.parameters_random <- function(x, digits = 2, ...) { } - - #' @keywords internal .print_random_parameters <- function(random_params, digits = 2) { insight::print_color("# Random Effects\n\n", "blue") @@ -586,7 +576,6 @@ print.parameters_random <- function(x, digits = 2, ...) { } - .find_min_colwidth <- function(formatted_table) { shared_cols <- unique(unlist(lapply(formatted_table, colnames))) col_width <- rep(NA, length(shared_cols)) diff --git a/R/print_html.R b/R/print_html.R index 616791b5b..24df6c814 100644 --- a/R/print_html.R +++ b/R/print_html.R @@ -242,7 +242,6 @@ print_html.compare_parameters <- function(x, } - # helper ------------------ .add_gt_options <- function(out, diff --git a/R/print_md.R b/R/print_md.R index 877d7dc01..bdc2783ce 100644 --- a/R/print_md.R +++ b/R/print_md.R @@ -117,9 +117,6 @@ print_md.parameters_brms_meta <- print_md.parameters_model print_md.parameters_simulate <- print_md.parameters_model - - - # compare parameters ------------------------- @@ -210,9 +207,6 @@ print_md.compare_parameters <- function(x, } - - - # SEM print ---------------------------- #' @export @@ -249,8 +243,6 @@ print_md.parameters_sem <- function(x, } - - # PCA / EFA / CFA ---------------------------- #' @export @@ -285,9 +277,6 @@ print_md.parameters_efa <- function(x, digits = 2, sort = FALSE, threshold = NUL print_md.parameters_pca <- print_md.parameters_efa - - - # Equivalence test ---------------------------- #' @export @@ -344,9 +333,6 @@ print_md.equivalence_test_lm <- function(x, } - - - # distribution print ---------------------------- #' @export diff --git a/R/random_parameters.R b/R/random_parameters.R index 452f666a5..a7cd20bb3 100644 --- a/R/random_parameters.R +++ b/R/random_parameters.R @@ -62,7 +62,6 @@ random_parameters <- function(model, component = "conditional") { } - # helper ----------------------------------- .n_randomeffects <- function(model) { @@ -74,7 +73,6 @@ random_parameters <- function(model, component = "conditional") { } - .randomeffects_summary <- function(model, component = "conditional") { out <- list() diff --git a/R/reduce_parameters.R b/R/reduce_parameters.R index 92bdb0aa5..c7c362bc3 100644 --- a/R/reduce_parameters.R +++ b/R/reduce_parameters.R @@ -83,7 +83,6 @@ reduce_data <- function(x, method = "PCA", n = "max", distance = "euclidean", .. } - #' @export reduce_parameters.data.frame <- function(x, method = "PCA", n = "max", distance = "euclidean", ...) { x <- datawizard::to_numeric(x, dummy_factors = TRUE) @@ -140,7 +139,6 @@ reduce_parameters.data.frame <- function(x, method = "PCA", n = "max", distance } - #' @export reduce_parameters.lm <- function(x, method = "PCA", n = "max", distance = "euclidean", ...) { model_data <- reduce_parameters( @@ -162,9 +160,6 @@ reduce_parameters.lm <- function(x, method = "PCA", n = "max", distance = "eucli reduce_parameters.merMod <- reduce_parameters.lm - - - #' @export principal_components.lm <- function(x, ...) { reduce_parameters(x, method = "PCA", ...) @@ -174,11 +169,6 @@ principal_components.lm <- function(x, ...) { principal_components.merMod <- principal_components.lm - - - - - #' @keywords internal .cmds <- function(x, n = "all", distance = "euclidean", ...) { n <- .get_n_factors(x, n = n, type = "PCA", rotation = "none") @@ -192,12 +182,6 @@ principal_components.merMod <- principal_components.lm } - - - - - - #' @keywords internal .drr <- function(x, n = "all", ...) { n <- .get_n_factors(x, n = n, type = "PCA", rotation = "none") @@ -214,8 +198,6 @@ principal_components.merMod <- principal_components.lm } - - #' @keywords internal .ica <- function(x, n = "all", ...) { n <- .get_n_factors(x, n = n, type = "PCA", rotation = "none") diff --git a/R/reshape_loadings.R b/R/reshape_loadings.R index 3657ee996..67ceb5093 100644 --- a/R/reshape_loadings.R +++ b/R/reshape_loadings.R @@ -41,7 +41,6 @@ reshape_loadings.data.frame <- function(x, threshold = NULL, loadings_columns = } - #' @keywords internal .wide_loadings <- function(loadings, loadings_columns = "Loading", @@ -121,9 +120,6 @@ reshape_loadings.data.frame <- function(x, threshold = NULL, loadings_columns = } - - - #' @export print.parameters_loadings <- function(x, ...) { formatted_table <- insight::format_table(x) diff --git a/R/select_parameters.R b/R/select_parameters.R index 93c697017..5ecbfd5b9 100644 --- a/R/select_parameters.R +++ b/R/select_parameters.R @@ -64,7 +64,6 @@ select_parameters.lm <- function(model, } - #' @rdname select_parameters #' @export select_parameters.merMod <- function(model, diff --git a/R/standardize_info.R b/R/standardize_info.R index d84e9c18d..1c067e2cd 100644 --- a/R/standardize_info.R +++ b/R/standardize_info.R @@ -164,8 +164,6 @@ standardize_info.default <- function(model, } - - # Predictors - Smart ------------------------------------------------------------ @@ -204,7 +202,6 @@ standardize_info.default <- function(model, } - #' @keywords internal .std_info_predictor_smart <- function(data, variable, @@ -295,9 +292,6 @@ standardize_info.default <- function(model, } - - - # Predictors - sdy ------------------------------------------------------------ @@ -322,9 +316,6 @@ standardize_info.default <- function(model, } - - - # Response ------------------------------------------------------------ #' @keywords internal @@ -372,7 +363,6 @@ standardize_info.default <- function(model, } - #' @keywords internal .std_info_response_basic <- function(model, info, params, robust = FALSE, w = NULL, ...) { if (inherits(model, c("gls", "lme"))) { @@ -404,7 +394,6 @@ standardize_info.default <- function(model, } - # Pseudo (GLMM) ----------------------------------------------------------- .std_info_pseudo <- function(model, @@ -552,7 +541,6 @@ standardize_info.default <- function(model, } - # Utils ------------------------------------------------------------------- diff --git a/R/standardize_parameters.R b/R/standardize_parameters.R index 8a2d2b3fc..ef4c91a8c 100644 --- a/R/standardize_parameters.R +++ b/R/standardize_parameters.R @@ -471,8 +471,6 @@ standardize_parameters.model_fit <- function(model, } - - # methods -------------------------------- #' @export @@ -541,9 +539,6 @@ print_html.parameters_standardized <- function(x, digits = 2, ...) { } - - - # helper ------------------------- diff --git a/R/utils.R b/R/utils.R index f0da0c204..358fefc91 100644 --- a/R/utils.R +++ b/R/utils.R @@ -63,7 +63,6 @@ } - # Find log-terms inside model formula, and return "clean" term names .log_terms <- function(model) { x <- insight::find_terms(model, flatten = TRUE, verbose = FALSE) @@ -84,7 +83,6 @@ } - #' @keywords internal .get_object <- function(x, attribute_name = "object_name") { obj_name <- attr(x, attribute_name, exact = TRUE) diff --git a/R/utils_cleaners.R b/R/utils_cleaners.R index 9938abe2c..3ef4af17e 100644 --- a/R/utils_cleaners.R +++ b/R/utils_cleaners.R @@ -42,8 +42,6 @@ } - - #' @keywords internal .remove_backticks_from_string <- function(x) { if (is.character(x)) { diff --git a/R/utils_format.R b/R/utils_format.R index 27bd3ff5b..c38c8655a 100644 --- a/R/utils_format.R +++ b/R/utils_format.R @@ -267,9 +267,6 @@ } - - - # other helper ------------------------ @@ -554,7 +551,6 @@ } - # helper to format the header / subheader of different model components -------------- .format_model_component_header <- function(x, @@ -719,9 +715,6 @@ } - - - # helper grouping parameters ------------------- @@ -818,7 +811,6 @@ } - # .insert_row <- function(x, newrow, r) { # existingDF[seq(r+1,nrow(existingDF)+1),] <- existingDF[seq(r,nrow(existingDF)),] # existingDF[r,] <- newrow @@ -892,8 +884,6 @@ } - - .prepare_splitby_for_print <- function(x) { if (!is.null(attributes(x)$model_class) && any(attributes(x)$model_class == "mvord")) { x$Response <- NULL @@ -919,8 +909,6 @@ } - - # this function is actually similar to "insight::print_parameters()", but more # sophisticated, to ensure nicely outputs even for complicated or complex models, # or edge cases... @@ -1216,8 +1204,6 @@ } - - # helper to fix unequal number of columns for list of data frames, # when used for HTML printing diff --git a/R/utils_model_parameters.R b/R/utils_model_parameters.R index ef5d26a30..4fea543f0 100644 --- a/R/utils_model_parameters.R +++ b/R/utils_model_parameters.R @@ -343,8 +343,6 @@ } - - .add_pretty_names <- function(params, model) { attr(params, "model_class") <- class(model) cp <- insight::clean_parameters(model) @@ -367,8 +365,6 @@ } - - #' @keywords internal .add_anova_attributes <- function(params, model, ci, test = NULL, alternative = NULL, ...) { dot.arguments <- lapply(match.call(expand.dots = FALSE)$`...`, function(x) x) # nolint @@ -420,7 +416,6 @@ } - .additional_arguments <- function(x, value, default) { add_args <- attributes(x)$additional_arguments @@ -438,7 +433,6 @@ } - # checks for valid inputs in model_parameters(). E.g., some models don't support # the "vcov" argument - this should not be silently ignored, but rather the user # should be informed that robust SE are not available for that model. @@ -470,7 +464,6 @@ } - # functions to check if necessary default argument was provided ------------ .is_model_valid <- function(model) { diff --git a/R/utils_pca_efa.R b/R/utils_pca_efa.R index 68eed7452..c48b39728 100644 --- a/R/utils_pca_efa.R +++ b/R/utils_pca_efa.R @@ -67,8 +67,6 @@ get_scores <- function(x, n_items = NULL) { } - - # model parameters ----------------------------------------------------------------- @@ -89,10 +87,6 @@ model_parameters.parameters_efa <- function(model, ...) { model_parameters.parameters_pca <- model_parameters.parameters_efa - - - - # summary ----------------------------------------------------------------- @@ -132,11 +126,6 @@ summary.parameters_omega <- function(object, ...) { } - - - - - # predict ----------------------------------------------------------------- @@ -194,8 +183,6 @@ predict.parameters_efa <- function(object, predict.parameters_pca <- predict.parameters_efa - - .merge_na <- function(object, out, verbose = TRUE) { compl_cases <- attributes(object)$complete_cases if (is.null(compl_cases)) { @@ -214,10 +201,6 @@ predict.parameters_pca <- predict.parameters_efa } - - - - # print ------------------------------------------------------------------- @@ -298,10 +281,6 @@ print.parameters_omega_summary <- function(x, ...) { } - - - - # print-helper ---------------------- @@ -371,7 +350,6 @@ print.parameters_omega_summary <- function(x, ...) { } - #' @keywords internal .text_components_variance <- function(x, sep = "") { type <- attributes(x)$type @@ -431,10 +409,6 @@ print.parameters_omega_summary <- function(x, ...) { } - - - - # sort -------------------------------------------------------------------- #' @rdname principal_components @@ -495,9 +469,6 @@ sort.parameters_pca <- sort.parameters_efa } - - - # Filter -------------------------------------------------------------------- @@ -527,7 +498,6 @@ sort.parameters_pca <- sort.parameters_efa } - # closest_component ------------------------------------------------------- @@ -542,7 +512,6 @@ closest_component <- function(pca_results) { } - .closest_component <- function(loadings, loadings_columns = NULL, variable_names = NULL) { if (is.matrix(loadings)) loadings <- as.data.frame(loadings) if (is.null(loadings_columns)) loadings_columns <- seq_len(ncol(loadings)) diff --git a/tests/testthat/test-GLMMadaptive.R b/tests/testthat/test-GLMMadaptive.R index 89cf207dc..fce257254 100644 --- a/tests/testthat/test-GLMMadaptive.R +++ b/tests/testthat/test-GLMMadaptive.R @@ -52,7 +52,6 @@ test_that("ci", { }) - test_that("se", { expect_equal( standard_error(m1)$SE, diff --git a/tests/testthat/test-glmer.R b/tests/testthat/test-glmer.R index 5d2161ad7..0fbfc7c9e 100644 --- a/tests/testthat/test-glmer.R +++ b/tests/testthat/test-glmer.R @@ -43,7 +43,6 @@ test_that("print model_parameters", { }) - test_that("model_parameters.glmer ml1", { params <- model_parameters(model, ci_method = "ml1", effects = "fixed") expect_equal(params$SE, c(0.22758, 0.30329, 0.32351, 0.42445), tolerance = 1e-2) diff --git a/tests/testthat/test-glmmTMB.R b/tests/testthat/test-glmmTMB.R index 0ccb75779..44079deb3 100644 --- a/tests/testthat/test-glmmTMB.R +++ b/tests/testthat/test-glmmTMB.R @@ -70,7 +70,6 @@ withr::with_options( }) - test_that("se", { expect_equal( standard_error(m1)$SE, @@ -630,7 +629,6 @@ withr::with_options( }) - test_that("model_parameters.mixed-all", { skip_on_os(c("mac", "linux", "solaris")) skip_if_not(getRversion() >= "4.3.3") diff --git a/tests/testthat/test-model_parameters.anova.R b/tests/testthat/test-model_parameters.anova.R index 9e03f2966..528c1c9c9 100644 --- a/tests/testthat/test-model_parameters.anova.R +++ b/tests/testthat/test-model_parameters.anova.R @@ -93,7 +93,6 @@ test_that("model_parameters_Anova.mlm", { }) - test_that("model_parameters_Anova-effectsize", { skip_if_not_installed("lme4") skip_if_not_installed("effectsize", minimum_version = "0.4.3") diff --git a/tests/testthat/test-model_parameters_df.R b/tests/testthat/test-model_parameters_df.R index d347cd60d..65463744c 100644 --- a/tests/testthat/test-model_parameters_df.R +++ b/tests/testthat/test-model_parameters_df.R @@ -211,7 +211,6 @@ test_that("model_parameters.ivreg", { }) - # plm --------------------------- diff --git a/tests/testthat/test-p_value.R b/tests/testthat/test-p_value.R index 551d3b2d9..cebc5cd75 100644 --- a/tests/testthat/test-p_value.R +++ b/tests/testthat/test-p_value.R @@ -98,7 +98,6 @@ test_that("p_value", { expect_equal(p_value(model)$p[2], 0, tolerance = 0.01) - # Mixed models model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars) expect_equal(p_value(model)$p[1], 0.206219, tolerance = 0.01) diff --git a/tests/testthat/test-quantreg.R b/tests/testthat/test-quantreg.R index 2fa1ea166..d0a763e77 100644 --- a/tests/testthat/test-quantreg.R +++ b/tests/testthat/test-quantreg.R @@ -29,7 +29,6 @@ test_that("mp_rq", { }) - # rqs --------- test_that("mp_rqs", { skip_if_not_installed("quantreg") diff --git a/tests/testthat/test-random_effects_ci.R b/tests/testthat/test-random_effects_ci.R index b801921da..5b5a78492 100644 --- a/tests/testthat/test-random_effects_ci.R +++ b/tests/testthat/test-random_effects_ci.R @@ -107,7 +107,6 @@ test_that("random effects CIs, two slopes, categorical", { }) - # model 2 --------------------- test_that("random effects CIs, simple slope", { @@ -133,7 +132,6 @@ test_that("random effects CIs, simple slope", { }) - # model 3 --------------------- test_that("random effects CIs, categorical slope-1", { @@ -182,7 +180,6 @@ test_that("random effects CIs, categorical slope-1", { }) - # model 4 --------------------- test_that("random effects CIs, categorical slope-2", { @@ -228,7 +225,6 @@ test_that("random effects CIs, categorical slope-2", { }) - # model 5 --------------------- test_that("random effects CIs, double slope", { @@ -258,8 +254,6 @@ test_that("random effects CIs, double slope", { }) - - # no random intercept -------------------------- test_that("random effects CIs, simple slope", { data(sleepstudy, package = "lme4") @@ -300,8 +294,6 @@ test_that("random effects CIs, simple slope", { }) - - # poly random slope -------------------------- test_that("random effects CIs, poly slope", { data(cake, package = "lme4") @@ -332,8 +324,6 @@ test_that("random effects CIs, poly slope", { }) - - # poly and categorical random slope -------------------------- test_that("random effects CIs, poly categorical slope", { diff --git a/tests/testthat/test-robust.R b/tests/testthat/test-robust.R index ad84ff23f..971c67beb 100644 --- a/tests/testthat/test-robust.R +++ b/tests/testthat/test-robust.R @@ -90,8 +90,6 @@ test_that("robust-se survival", { }) - - # p-values ------------------------------------- test_that("robust-p lm", { @@ -200,8 +198,6 @@ test_that("robust-p survival", { }) - - # CI ------------------------------------- @@ -344,8 +340,6 @@ test_that("robust-ci survival", { }) - - # mixed models ---------------------- skip_if_not_installed("clubSandwich") diff --git a/tests/testthat/test-standardize_parameters.R b/tests/testthat/test-standardize_parameters.R index cb71e4e73..c3dbeeb73 100644 --- a/tests/testthat/test-standardize_parameters.R +++ b/tests/testthat/test-standardize_parameters.R @@ -80,7 +80,6 @@ test_that("standardize_parameters (bootstrap_model)", { }) - # lm with ci ----------------------------------- test_that("standardize_parameters (lm with ci)", { data("iris") @@ -169,7 +168,6 @@ test_that("standardize_parameters (aov)", { }) - # with function interactions" ------------------- test_that("standardize_parameters (with functions / interactions)", { skip_on_cran() @@ -413,7 +411,6 @@ test_that("standardize_parameters (Pseudo - GLMM)", { ) - ## Give warning for within that is also between mW <- lme4::lmer(Y ~ X_between + Z_within + C + (1 | ID), dat) mM <- lme4::lmer(Y ~ X + Z + C + (1 | ID), dat) From 847c13a9f72914a743243783ec3d44b967d731df Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 2 Jan 2025 13:12:24 +0100 Subject: [PATCH 8/9] lintr --- R/factor_analysis.R | 14 ++++++------- R/format_p_adjust.R | 2 +- R/methods_BayesFM.R | 48 ++++++++++++++++++++++++--------------------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/R/factor_analysis.R b/R/factor_analysis.R index c60634ab4..0b68f1f9c 100644 --- a/R/factor_analysis.R +++ b/R/factor_analysis.R @@ -59,7 +59,13 @@ factor_analysis.data.frame <- function(x, } # Pass cor if available - if (!is.null(cor)) { + if (is.null(cor)) { + out <- model_parameters( + psych::fa(x, nfactors = n, rotate = rotation, ...), + sort = sort, + threshold = threshold + ) + } else { out <- model_parameters( psych::fa( cor, @@ -71,12 +77,6 @@ factor_analysis.data.frame <- function(x, sort = sort, threshold = threshold ) - } else { - out <- model_parameters( - psych::fa(x, nfactors = n, rotate = rotation, ...), - sort = sort, - threshold = threshold - ) } attr(out, "dataset") <- x diff --git a/R/format_p_adjust.R b/R/format_p_adjust.R index ab56f514d..7971c7b01 100644 --- a/R/format_p_adjust.R +++ b/R/format_p_adjust.R @@ -110,7 +110,7 @@ format_p_adjust <- function(method) { } if (isTRUE(all(old_p_vals == params$p)) && !identical(p_adjust, "none") && verbose) { - insight::format_warning(paste0("Could not apply ", p_adjust, "-adjustment to p-values. Either something went wrong, or the non-adjusted p-values were already very large.")) + insight::format_warning(paste0("Could not apply ", p_adjust, "-adjustment to p-values. Either something went wrong, or the non-adjusted p-values were already very large.")) # nolint } } else if (verbose) { insight::format_alert(paste0("`p_adjust` must be one of ", toString(all_methods))) diff --git a/R/methods_BayesFM.R b/R/methods_BayesFM.R index e847dea06..cbb7ed9f7 100644 --- a/R/methods_BayesFM.R +++ b/R/methods_BayesFM.R @@ -35,17 +35,17 @@ model_parameters.befa <- function(model, if (!attr(model, "post.sign.switch")) model <- BayesFM::post.sign.switch(model) } - loadings <- as.data.frame(model$alpha) - names(loadings) <- gsub("alpha:", "", names(loadings), fixed = TRUE) - loadings <- stats::reshape( - loadings, + factor_loadings <- as.data.frame(model$alpha) + names(factor_loadings) <- gsub("alpha:", "", names(factor_loadings), fixed = TRUE) + factor_loadings <- stats::reshape( + factor_loadings, direction = "long", - varying = list(names(loadings)), + varying = list(names(factor_loadings)), sep = "_", timevar = "Variable", v.names = "Loading", idvar = "Draw", - times = names(loadings) + times = names(factor_loadings) ) components <- as.data.frame(model$dedic) @@ -61,17 +61,17 @@ model_parameters.befa <- function(model, times = names(components) ) - loadings <- merge(components, loadings) + factor_loadings <- merge(components, factor_loadings) # Compute posterior by dedic long_loadings <- data.frame() - for (var in unique(loadings$Variable)) { - for (comp in unique(loadings$Component)) { - chunk <- loadings[loadings$Variable == var & loadings$Component == comp, ] + for (var in unique(factor_loadings$Variable)) { + for (comp in unique(factor_loadings$Component)) { + chunk <- factor_loadings[factor_loadings$Variable == var & factor_loadings$Component == comp, ] # nolint if (nrow(chunk) == 0) { rez <- bayestestR::describe_posterior( - loadings$Loading, + factor_loadings$Loading, centrality = centrality, dispersion = dispersion, ci = ci, @@ -109,29 +109,33 @@ model_parameters.befa <- function(model, } long_loadings <- long_loadings[long_loadings$Component != 0, ] - loadings <- .wide_loadings(long_loadings, loadings_columns = names(long_loadings)[3], component_column = "Component", variable_column = "Variable") - + factor_loadings <- .wide_loadings( + long_loadings, + loadings_columns = names(long_loadings)[3], + component_column = "Component", + variable_column = "Variable" + ) # Add attributes - attr(loadings, "model") <- model - attr(loadings, "additional_arguments") <- list(...) - attr(loadings, "n") <- insight::n_unique(long_loadings$Component) - attr(loadings, "loadings_columns") <- names(loadings)[2:ncol(loadings)] - attr(loadings, "ci") <- ci + attr(factor_loadings, "model") <- model + attr(factor_loadings, "additional_arguments") <- list(...) + attr(factor_loadings, "n") <- insight::n_unique(long_loadings$Component) + attr(factor_loadings, "loadings_columns") <- names(factor_loadings)[2:ncol(factor_loadings)] + attr(factor_loadings, "ci") <- ci # Sorting if (isTRUE(sort)) { - loadings <- .sort_loadings(loadings) + factor_loadings <- .sort_loadings(factor_loadings) } # Add some more attributes long_loadings <- stats::na.omit(long_loadings) row.names(long_loadings) <- NULL - attr(loadings, "loadings_long") <- long_loadings + attr(factor_loadings, "loadings_long") <- long_loadings # add class-attribute for printing - class(loadings) <- c("parameters_efa", class(loadings)) + class(factor_loadings) <- c("parameters_efa", class(factor_loadings)) - loadings + factor_loadings } From 7beafa80cf9472d6d609aed63e7c40327ff11e10 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 2 Jan 2025 13:13:09 +0100 Subject: [PATCH 9/9] lintr --- R/dof_ml1.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/dof_ml1.R b/R/dof_ml1.R index 36c1e95b5..ad5654ade 100644 --- a/R/dof_ml1.R +++ b/R/dof_ml1.R @@ -53,9 +53,9 @@ dof_ml1 <- function(model) { var.within <- stats::var(x - x.bar) var.between <- stats::var(x.bar) if (var.within >= var.between) { - return(n) + n } else { - return(m) + m } }