Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up deprecated args, lintr #973

Merged
merged 3 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: parameters
Title: Processing of Model Parameters
Version: 0.21.7.1
Version: 0.21.7.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -218,4 +218,4 @@ Config/Needs/website:
r-lib/pkgdown,
easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/insight, easystats/datawizard, easystats/performance, easystats/bayestestR
Remotes: easystats/insight, easystats/datawizard, easystats/performance, easystats/bayestestR, easystats/effectsize
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# parameters 0.21.8

## Breaking changes

* Deprecated arguments in `model_parameters()` for `htest`, `aov` and
`BFBayesFactor` objects were removed.

# parameters 0.21.7

## Changes
Expand Down
2 changes: 1 addition & 1 deletion R/dof_kenward.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ dof_kenward <- function(model) {

Gp <- lme4::getME(model, "Gp")
n.RT <- length(Gp) - 1 ## Number of random terms (i.e. of (|)'s)
n.lev.by.RT <- sapply(lme4::getME(model, "flist"), function(x) length(levels(x)))
n.lev.by.RT <- sapply(lme4::getME(model, "flist"), nlevels)
n.comp.by.RT <- .get.RT.dim.by.RT(model)
n.parm.by.RT <- (n.comp.by.RT + 1) * n.comp.by.RT / 2
n.RE.by.RT <- diff(Gp)
Expand Down
42 changes: 18 additions & 24 deletions R/methods_BayesFactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#' @inheritParams bayestestR::describe_posterior
#' @inheritParams p_value
#' @inheritParams model_parameters.htest
#' @param cohens_d,cramers_v Deprecated. Please use `effectsize_type`.
#'
#' @details
#' The meaning of the extracted parameters:
Expand All @@ -29,24 +28,26 @@
#' the *g* parameters; See the *Bayes Factors for ANOVAs* paper
#' (\doi{10.1016/j.jmp.2012.08.001}).
#'
#' @examples
#' @examplesIf require("BayesFactor")
#' \donttest{
#' if (require("BayesFactor")) {
#' # Bayesian t-test
#' model <- ttestBF(x = rnorm(100, 1, 1))
#' model_parameters(model)
#' model_parameters(model, cohens_d = TRUE, ci = .9)
#' # Bayesian t-test
#' model <- BayesFactor::ttestBF(x = rnorm(100, 1, 1))
#' model_parameters(model)
#' model_parameters(model, effectsize_type = "cohens_d", ci = 0.9)
#'
#' # Bayesian contingency table analysis
#' data(raceDolls)
#' bf <- contingencyTableBF(raceDolls, sampleType = "indepMulti", fixedMargin = "cols")
#' model_parameters(bf,
#' centrality = "mean",
#' dispersion = TRUE,
#' verbose = FALSE,
#' effectsize_type = "cramers_v"
#' )
#' }
#' # Bayesian contingency table analysis
#' data(raceDolls)
#' bf <- BayesFactor::contingencyTableBF(
#' raceDolls,
#' sampleType = "indepMulti",
#' fixedMargin = "cols"
#' )
#' model_parameters(bf,
#' centrality = "mean",
#' dispersion = TRUE,
#' verbose = FALSE,
#' effectsize_type = "cramers_v"
#' )
#' }
#' @return A data frame of indices related to the model's parameters.
#' @export
Expand All @@ -62,16 +63,9 @@
effectsize_type = NULL,
include_proportions = FALSE,
verbose = TRUE,
cohens_d = NULL,
cramers_v = NULL,
...) {
insight::check_if_installed("BayesFactor")

## TODO: remove in a later update
# handle deprected arguments ------
if (!is.null(cramers_v)) effectsize_type <- "cramers_v"
if (!is.null(cohens_d)) effectsize_type <- "cohens_d"

if (any(startsWith(names(model@numerator), "Null"))) {
if (isTRUE(verbose)) {
insight::format_alert(
Expand Down Expand Up @@ -121,7 +115,7 @@
tryCatch(
{
bfm <- as.data.frame(bayestestR::bayesfactor_models(model)[-1, ])
if (!is.null(bfm$log_BF)) {

Check warning on line 118 in R/methods_BayesFactor.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/methods_BayesFactor.R,line=118,col=11,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
out$BF <- exp(bfm$log_BF)
} else {
out$BF <- bfm$BF
Expand Down
30 changes: 16 additions & 14 deletions R/methods_DirichletReg.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@

## TODO check merge by

junk <- utils::capture.output(out <- .model_parameters_generic( # nolint
model = model,
ci = ci,
component = component,
bootstrap = bootstrap,
iterations = iterations,
merge_by = merge_by,
standardize = standardize,
exponentiate = exponentiate,
p_adjust = p_adjust,
keep_parameters = keep,
drop_parameters = drop,
...
))
junk <- utils::capture.output({
out <- .model_parameters_generic(
model = model,
ci = ci,
component = component,
bootstrap = bootstrap,
iterations = iterations,
merge_by = merge_by,
standardize = standardize,
exponentiate = exponentiate,
p_adjust = p_adjust,
keep_parameters = keep,
drop_parameters = drop,
...
)
})

out$Response[is.na(out$Response)] <- ""
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
Expand Down Expand Up @@ -78,7 +80,7 @@
SE = as.vector(model$se)
)

if (!is.null(params$Component)) {

Check warning on line 83 in R/methods_DirichletReg.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/methods_DirichletReg.R,line=83,col=7,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
out$Component <- params$Component
} else {
component <- "all"
Expand Down Expand Up @@ -119,7 +121,7 @@
p = as.vector(2 * stats::pnorm(-abs(params$Estimate / model$se)))
)

if (!is.null(params$Component)) {

Check warning on line 124 in R/methods_DirichletReg.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/methods_DirichletReg.R,line=124,col=7,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
out$Component <- params$Component
} else {
component <- "all"
Expand Down
28 changes: 0 additions & 28 deletions R/methods_aov.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#' (e.g., `"g"`, `"l"`, `"two"`...). See section *One-Sided CIs* in
#' the [effectsize_CIs vignette](https://easystats.github.io/effectsize/).
#' @inheritParams model_parameters.default
#' @param omega_squared,eta_squared,epsilon_squared Deprecated. Please use `effectsize_type`.
#' @param ... Arguments passed to [`effectsize::effectsize()`]. For example,
#' to calculate _partial_ effect sizes types, use `partial = TRUE`. For objects
#' of class `htest` or `BFBayesFactor`, `adjust = TRUE` can be used to return
Expand Down Expand Up @@ -110,34 +109,7 @@
drop = NULL,
table_wide = FALSE,
verbose = TRUE,
omega_squared = NULL,
eta_squared = NULL,
epsilon_squared = NULL,
...) {
## TODO: remove in a later update
# handle deprected arguments ------
if (!is.null(omega_squared)) {
insight::format_warning(
"Argument `omega_squared` is deprecated.",
"Please use `effectsize_type = \"omega\"` instead."
)
effectsize_type <- "omega"
}
if (!is.null(eta_squared)) {
insight::format_warning(
"Argument `eta_squared` is deprecated.",
"Please use `effectsize_type = \"eta\"` instead."
)
effectsize_type <- "eta"
}
if (!is.null(epsilon_squared)) {
insight::format_warning(
"Argument `epsilon_squared` is deprecated.",
"Please use `effectsize_type = \"epsilon\"` instead."
)
effectsize_type <- "epsilon"
}

# save model object, for later checks
original_model <- model
object_name <- insight::safe_deparse_symbol(substitute(model))
Expand Down Expand Up @@ -432,7 +404,7 @@
predictors <- .safe(insight::get_predictors(model))

# if data available, check contrasts and mean centering
if (!is.null(predictors)) {

Check warning on line 407 in R/methods_aov.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/methods_aov.R,line=407,col=9,[if_not_else_linter] Prefer `if (A) x else y` to the less-readable `if (!A) y else x` in a simple if/else statement.
treatment_contrasts_or_not_centered <- vapply(predictors, function(i) {
if (is.factor(i)) {
cn <- stats::contrasts(i)
Expand Down
Loading
Loading