From e90b9d01e14f1dca11310f89137297b438941af8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 19 Apr 2023 15:54:17 +0200 Subject: [PATCH] prepare CRAN hotfix (#876) * prepare CRAN hotfix * requires insight dev * check on insight dev * update NAMESPACE * update wordlist * remove remotes * cran comments, release version * submitted * Revert "Remove re-exports (#873)" This reverts commit 9a654dae3e6e7691ebf1f1df512f18e46d10dcd0. * news * cran comments * submitted --- CRAN-SUBMISSION | 6 ++-- DESCRIPTION | 3 +- NAMESPACE | 17 +++++++++-- NEWS.md | 8 ++--- R/dof_satterthwaite.R | 11 ------- R/methods_nlme.R | 6 +--- R/reexports.R | 32 ++++++++++++++++++++ R/standard_error_satterthwaite.R | 16 ---------- cran-comments.md | 8 +++-- inst/WORDLIST | 1 + man/reexports.Rd | 11 +++++-- tests/testthat/test-lme.R | 17 ----------- tests/testthat/test-mipo.R | 1 + tests/testthat/test-model_parameters.mixed.R | 2 +- 14 files changed, 71 insertions(+), 68 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index bbf1bf0ce..f87913c6b 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.20.3 -Date: 2023-04-05 06:07:12 UTC -SHA: ac64894ca63668acf04804f79a9f02490ade31ca +Version: 0.21.0 +Date: 2023-04-19 11:52:51 UTC +SHA: ad9c5390202be4b3132e30dd122cad323f0cbec7 diff --git a/DESCRIPTION b/DESCRIPTION index ee473f10f..d0df66f8a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.20.3.1 +Version: 0.21.0 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -140,7 +140,6 @@ Suggests: ivreg, knitr, lavaan, - lavaSearch2, lfe, lm.beta, lme4, diff --git a/NAMESPACE b/NAMESPACE index ef4ab0e71..47b526d0c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -177,7 +177,6 @@ S3method(display,parameters_pca) S3method(display,parameters_pca_summary) S3method(display,parameters_sem) S3method(display,parameters_simulate) -S3method(dof_satterthwaite,lme) S3method(dof_satterthwaite,lmerMod) S3method(equivalence_test,MixMod) S3method(equivalence_test,feis) @@ -624,8 +623,6 @@ S3method(reduce_parameters,merMod) S3method(reshape_loadings,data.frame) S3method(reshape_loadings,parameters_efa) S3method(se_satterthwaite,default) -S3method(se_satterthwaite,gls) -S3method(se_satterthwaite,lme) S3method(select_parameters,lm) S3method(select_parameters,merMod) S3method(simulate_model,LORgee) @@ -914,6 +911,8 @@ export(confidence_curve) export(consonance_function) export(convert_efa_to_cfa) export(degrees_of_freedom) +export(demean) +export(describe_distribution) export(display) export(dof) export(dof_betwithin) @@ -929,6 +928,7 @@ export(format_order) export(format_p_adjust) export(format_parameters) export(get_scores) +export(kurtosis) export(model_parameters) export(n_clusters) export(n_clusters_dbscan) @@ -955,6 +955,7 @@ export(print_md) export(random_parameters) export(reduce_data) export(reduce_parameters) +export(rescale_weights) export(reshape_loadings) export(rotated_data) export(se_kenward) @@ -962,20 +963,30 @@ export(se_satterthwaite) export(select_parameters) export(simulate_model) export(simulate_parameters) +export(skewness) export(sort_parameters) export(standard_error) export(standardise_info) export(standardise_parameters) export(standardise_posteriors) export(standardize_info) +export(standardize_names) export(standardize_parameters) export(standardize_posteriors) +export(supported_models) export(visualisation_recipe) importFrom(bayestestR,ci) importFrom(bayestestR,equivalence_test) +importFrom(datawizard,demean) +importFrom(datawizard,describe_distribution) +importFrom(datawizard,kurtosis) +importFrom(datawizard,rescale_weights) +importFrom(datawizard,skewness) importFrom(datawizard,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) diff --git a/NEWS.md b/NEWS.md index 8c829f6ac..455bce14a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,11 +2,9 @@ ## Breaking Changes -* As noted in release notes for 0.15.0 version, all re-exported functions from - *datawizard* package have now been removed. - -* Following re-exported functions from *insight* have been removed: - `standardize_names()`, `supported_models()` +* It is no longer possible to calculate Satterthwaite-approximated degrees of + freedom for mixed models from package *nlme*. This was based on the + *lavaSearch2* package, which no longer seems to support models of class `lme`. ## Changes to functions diff --git a/R/dof_satterthwaite.R b/R/dof_satterthwaite.R index 931866608..c7c1915e4 100644 --- a/R/dof_satterthwaite.R +++ b/R/dof_satterthwaite.R @@ -15,14 +15,3 @@ dof_satterthwaite.lmerMod <- function(model) { stats::setNames(as.vector(s$coefficients[, 3]), parameters) } - - -#' @export -dof_satterthwaite.lme <- function(model) { - insight::check_if_installed("lavaSearch2") - - parameters <- insight::find_parameters(model, effects = "fixed", flatten = TRUE) - lavaSearch2::sCorrect(model) <- TRUE - s <- lavaSearch2::summary2(model) - stats::setNames(as.vector(s$tTable[, "df"]), parameters) -} diff --git a/R/methods_nlme.R b/R/methods_nlme.R index dfe31d45c..9b589b32e 100644 --- a/R/methods_nlme.R +++ b/R/methods_nlme.R @@ -15,7 +15,7 @@ ci.lme <- function(x, method = "wald", ...) { method <- tolower(method) - method <- match.arg(method, choices = c("wald", "normal", "residual", "betwithin", "ml1", "satterthwaite")) + method <- match.arg(method, choices = c("wald", "normal", "residual", "betwithin", "ml1")) if (method %in% c("wald", "residual", "normal")) { # `vcov` argument must be computed using the `.ci_generic` function. @@ -49,10 +49,6 @@ ci.lme <- function(x, # betwithin approx } else if (method == "betwithin") { ci_betwithin(x, ci) - - # Satterthwaite - } else if (method == "satterthwaite") { - ci_satterthwaite(x, ci) } } diff --git a/R/reexports.R b/R/reexports.R index e0be14b1b..ef37cd768 100644 --- a/R/reexports.R +++ b/R/reexports.R @@ -1,7 +1,39 @@ +# ----------------------- insight ------------------------------------- + +#' @importFrom insight standardize_names +#' @export +insight::standardize_names + +#' @importFrom insight supported_models +#' @export +insight::supported_models + #' @importFrom insight print_html #' @export insight::print_html +# ----------------------- datawizard ------------------------------------- + +#' @importFrom datawizard describe_distribution +#' @export +datawizard::describe_distribution + +#' @importFrom datawizard demean +#' @export +datawizard::demean + +#' @importFrom datawizard rescale_weights +#' @export +datawizard::rescale_weights + #' @importFrom datawizard visualisation_recipe #' @export datawizard::visualisation_recipe + +#' @importFrom datawizard kurtosis +#' @export +datawizard::kurtosis + +#' @importFrom datawizard skewness +#' @export +datawizard::skewness diff --git a/R/standard_error_satterthwaite.R b/R/standard_error_satterthwaite.R index d5eae1264..78adb730d 100644 --- a/R/standard_error_satterthwaite.R +++ b/R/standard_error_satterthwaite.R @@ -10,19 +10,3 @@ se_satterthwaite.default <- function(model) { .is_model_valid(model) standard_error(model) } - -#' @export -se_satterthwaite.lme <- function(model) { - insight::check_if_installed("lavaSearch2") - params <- insight::get_parameters(model, effects = "fixed") - lavaSearch2::sCorrect(model) <- TRUE - s <- lavaSearch2::summary2(model) - - .data_frame( - Parameter = params$Parameter, - SE = as.vector(s$tTable[, "Std.Error"]) - ) -} - -#' @export -se_satterthwaite.gls <- se_satterthwaite.lme diff --git a/cran-comments.md b/cran-comments.md index 8dd2bdc8c..059af58d9 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,8 @@ +This update fixes CRAN check issues due to breaking changes in the *lavaSearch2* package, as requested by the CRAN team. + +## revdepcheck results + We checked 33 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. - * We saw 1 new problems + * We saw 0 new problems * We failed to check 0 packages - -This update breaks the *performance* package. Test failures are expected, because a bug fix in *parameters* affects test results of the *performance* package. Tests have been corrected and an update of *performance* is ready to be submitted once the *parameters* package is accepted on CRAN. diff --git a/inst/WORDLIST b/inst/WORDLIST index d730a655c..e91cba75b 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -238,6 +238,7 @@ jstatsoft kmeans labelled lavaan +lavaSearch lesslikely lm lme diff --git a/man/reexports.Rd b/man/reexports.Rd index 903ad4acb..72dccd42e 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -9,8 +9,15 @@ \alias{ci} \alias{n_parameters} \alias{print_md} +\alias{standardize_names} +\alias{supported_models} \alias{print_html} +\alias{describe_distribution} +\alias{demean} +\alias{rescale_weights} \alias{visualisation_recipe} +\alias{kurtosis} +\alias{skewness} \title{Objects exported from other packages} \keyword{internal} \description{ @@ -20,8 +27,8 @@ below to see their documentation. \describe{ \item{bayestestR}{\code{\link[bayestestR]{ci}}, \code{\link[bayestestR]{equivalence_test}}} - \item{datawizard}{\code{\link[datawizard]{visualisation_recipe}}} + \item{datawizard}{\code{\link[datawizard]{demean}}, \code{\link[datawizard]{describe_distribution}}, \code{\link[datawizard:skewness]{kurtosis}}, \code{\link[datawizard]{rescale_weights}}, \code{\link[datawizard]{skewness}}, \code{\link[datawizard]{visualisation_recipe}}} - \item{insight}{\code{\link[insight]{display}}, \code{\link[insight]{n_parameters}}, \code{\link[insight:display]{print_html}}, \code{\link[insight:display]{print_md}}} + \item{insight}{\code{\link[insight]{display}}, \code{\link[insight]{n_parameters}}, \code{\link[insight:display]{print_html}}, \code{\link[insight:display]{print_md}}, \code{\link[insight]{standardize_names}}, \code{\link[insight:is_model_supported]{supported_models}}} }} diff --git a/tests/testthat/test-lme.R b/tests/testthat/test-lme.R index 80e79b46f..eb1ac95eb 100644 --- a/tests/testthat/test-lme.R +++ b/tests/testthat/test-lme.R @@ -1,6 +1,5 @@ skip_if_not_installed("nlme") skip_if_not_installed("lme4") -skip_if_not_installed("lavaSearch2") data("sleepstudy", package = "lme4") m1_lme <- nlme::lme(Reaction ~ Days, random = ~ 1 + Days | Subject, data = sleepstudy) @@ -96,19 +95,3 @@ test_that("model_parameters", { # expect_equal(params$df, c(80, 80, 25), tolerance = 1e-4) expect_equal(params$CI_low, c(16.07503, 0.53834, -3.82999), tolerance = 1e-4) }) - -test_that("model_parameters, satterthwaite", { - params <- model_parameters(m2_lme, ci_method = "satterthwaite", effects = "fixed") - expect_equal(params$Coefficient, c(17.70671, 0.66019, -2.32102), tolerance = 1e-4) - expect_equal(params$SE, c(0.83155, 0.06209, 0.74307), tolerance = 1e-4) - # expect_equal(params$df, c(104.1503, 82.87867, 26.25), tolerance = 1e-4) - expect_equal(params$CI_low, c(16.0391, 0.53609, -3.88541), tolerance = 1e-3) -}) - -test_that("model_parameters, satterthwaite", { - params <- model_parameters(m2_lme, ci_method = "satterthwaite", effects = "all") - expect_equal(params$Coefficient, c(17.70671, 0.66019, -2.32102, 1.73008, 1.42273), tolerance = 1e-4) - expect_equal(params$SE, c(0.83155, 0.06209, 0.74307, NA, NA), tolerance = 1e-4) - # expect_equal(params$df, c(104.1503, 82.87867, 26.25), tolerance = 1e-4) - expect_equal(params$CI_low, c(16.0391, 0.53609, -3.88541, NA, NA), tolerance = 1e-3) -}) diff --git a/tests/testthat/test-mipo.R b/tests/testthat/test-mipo.R index b7de69ba7..f138f97ca 100644 --- a/tests/testthat/test-mipo.R +++ b/tests/testthat/test-mipo.R @@ -1,5 +1,6 @@ skip_if_not_installed("mice") skip_if_not_installed("nnet") +skip_if_not(packageVersion("insight") > "0.19.1") test_that("param ordinal", { set.seed(1234) diff --git a/tests/testthat/test-model_parameters.mixed.R b/tests/testthat/test-model_parameters.mixed.R index 86e19364d..230d352d0 100644 --- a/tests/testthat/test-model_parameters.mixed.R +++ b/tests/testthat/test-model_parameters.mixed.R @@ -96,7 +96,7 @@ test_that("model_parameters.mixed-all_pars", { data("qol_cancer") qol_cancer <- cbind( qol_cancer, - datawizard::demean(qol_cancer, select = c("phq4", "QoL"), group = "ID") + demean(qol_cancer, select = c("phq4", "QoL"), group = "ID") ) model <- lme4::lmer( QoL ~ time + phq4_within + phq4_between + (1 | ID),