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

don't partialy match effect in model_parameters() #641

Merged
merged 2 commits into from
May 27, 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
6 changes: 3 additions & 3 deletions R/eta_squared-main.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' @param verbose Toggle warnings and messages on or off.
#' @inheritParams chisq_to_phi
#' @param ... Arguments passed to or from other methods.
#' - Can be `include_intercept = TRUE` to include the effect size for the intercept (when it is included in the ANOVA table).

Check warning on line 26 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=26,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 127 characters.
#' - For Bayesian models, arguments passed to `ss_function`.
#'
#' @return
Expand Down Expand Up @@ -248,7 +248,7 @@
ci = 0.95, alternative = "greater",
verbose = TRUE, ...) {
alternative <- .match.alt(alternative, FALSE)
out <- .anova_es(model, type = "epsilon", partial = partial, ci = ci, alternative = alternative, verbose = verbose, ...)

Check warning on line 251 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=251,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 122 characters.
class(out) <- unique(c("effectsize_anova", "effectsize_table", "see_effectsize_table", class(out)))
if ("CI" %in% colnames(out)) attr(out, "ci_method") <- list(method = "ncp", distribution = "F")
attr(out, "approximate") <- isTRUE(attr(out, "approximate", exact = TRUE))
Expand Down Expand Up @@ -294,7 +294,7 @@

es_name <- get_effectsize_name(colnames(res))
res[[es_name]] <- res[[es_name]] / (1 - res[[es_name]])
if (grepl("_partial", es_name)) {

Check warning on line 297 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=297,col=13,[fixed_regex_linter] Use "_partial" with fixed = TRUE here. This regular expression is static, i.e., its matches can be expressed as a fixed substring expression, which is faster to compute.
colnames(res)[colnames(res) == es_name] <- "Cohens_f2_partial"
} else {
colnames(res)[colnames(res) == es_name] <- "Cohens_f2"
Expand All @@ -316,7 +316,7 @@
if ("CI" %in% colnames(res)) attr(res, "ci_method") <- list(method = "ncp", distribution = "F")
class(res) <- unique(c("effectsize_anova", "effectsize_table", "see_effectsize_table", class(res)))
attr(res, "approximate") <- isTRUE(attr(res, "approximate", exact = TRUE))
attr(res, "table_footer") <- if (method != "eta") sprintf("Based on %s squared.", paste0(toupper(substring(method, 1, 1)), substring(method, 2)))

Check warning on line 319 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=319,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 147 characters.
res
}

Expand Down Expand Up @@ -430,7 +430,7 @@


# Estimate effect size ---
if (type == "eta") {

Check warning on line 433 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=433,col=3,[if_switch_linter] Prefer switch() statements over repeated if/else equality tests, e.g., switch(x, a = 1, b = 2) over if (x == "a") 1 else if (x == "b") 2.
if (isTRUE(generalized) || is.character(generalized)) {
## copied from afex
obs <- logical(nrow(aov_table))
Expand All @@ -448,7 +448,7 @@

aov_table$Eta2_generalized <- aov_table$Sum_Squares /
(aov_table$Sum_Squares + values$Sum_Squares_residuals + obs_SSn1 - obs_SSn2)
} else if (!isTRUE(partial)) {

Check warning on line 451 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=451,col=16,[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.
aov_table$Eta2 <- aov_table$Sum_Squares /
values$Sum_Squares_total
} else {
Expand All @@ -457,7 +457,7 @@
(aov_table$Sum_Squares + values$Sum_Squares_residuals)
}
} else if (type == "omega") {
if (!isTRUE(partial)) {

Check warning on line 460 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=460,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.
aov_table$Omega2 <-
(aov_table$Sum_Squares - aov_table$df * values$Mean_Square_residuals) /
(values$Sum_Squares_total + values$Mean_Square_residuals)
Expand All @@ -469,7 +469,7 @@
aov_table$Omega2_partial <- pmax(0, aov_table$Omega2_partial)
}
} else if (type == "epsilon") {
if (!isTRUE(partial)) {

Check warning on line 472 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=472,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.
aov_table$Epsilon2 <-
(aov_table$Sum_Squares - aov_table$df * values$Mean_Square_residuals) /
values$Sum_Squares_total
Expand All @@ -485,7 +485,7 @@
out <- aov_table

# Add CIs ---
if (!is.null(ci)) {

Check warning on line 488 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=488,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.
# based on MBESS::ci.R2
ES <- pmax(0, out[[ncol(out)]])
f <- (ES / out$df) / ((1 - ES) / df_error)
Expand Down Expand Up @@ -570,7 +570,7 @@


# Estimate effect size ---
if (type == "eta") {

Check warning on line 573 in R/eta_squared-main.R

View workflow job for this annotation

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

file=R/eta_squared-main.R,line=573,col=3,[if_switch_linter] Prefer switch() statements over repeated if/else equality tests, e.g., switch(x, a = 1, b = 2) over if (x == "a") 1 else if (x == "b") 2.
if (isTRUE(generalized) || is.character(generalized)) {
## copied from afex
obs <- logical(nrow(aov_table))
Expand Down Expand Up @@ -833,7 +833,7 @@
include_intercept = include_intercept
)

attr(out, "anova_type") <- tryCatch(attr(parameters::model_parameters(model, verbose = FALSE, effects = "fixed"), "anova_type"),
attr(out, "anova_type") <- tryCatch(attr(parameters::model_parameters(model, verbose = FALSE, effects = "fixed", effectsize_type = NULL), "anova_type"),
error = function(...) 1
)
attr(out, "approximate") <- TRUE
Expand Down Expand Up @@ -864,7 +864,7 @@

# TODO this should be in .anova_es.anvoa
# TODO the aoc method should convert to an anova table, then pass to anova
params <- parameters::model_parameters(model, verbose = verbose, effects = "fixed")
params <- parameters::model_parameters(model, verbose = verbose, effects = "fixed", effectsize_type = NULL)
out <- .es_aov_simple(as.data.frame(params),
type = type,
partial = partial, generalized = generalized,
Expand All @@ -890,7 +890,7 @@
verbose = TRUE,
include_intercept = FALSE,
...) {
params <- parameters::model_parameters(model, verbose = verbose, effects = "fixed")
params <- parameters::model_parameters(model, verbose = verbose, effects = "fixed", effectsize_type = NULL)
anova_type <- attr(params, "anova_type")
params <- as.data.frame(params)

Expand Down
2 changes: 1 addition & 1 deletion R/eta_squared-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
ci = 0.95, alternative = "greater",
verbose = TRUE,
...) {
params <- parameters::model_parameters(model, verbose = verbose, effects = "fixed")
params <- parameters::model_parameters(model, verbose = verbose, effects = "fixed", effectsize_type = NULL)
anova_type <- attr(params, "anova_type")

params <- split(params, factor(params$Response, levels = unique(params$Response))) # make sure row order is not changed
Expand Down
File renamed without changes.
Binary file added pkgdown/favicon/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
Loading