Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jun 24, 2024
1 parent 8ceb530 commit 4c888ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions R/rank_ANOVA.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ kendalls_w <- function(x, groups, blocks, data = NULL,
.reta <- function(data) {
model <- suppressWarnings(stats::kruskal.test(data$x, data$groups))

k <- length(levels(data$groups))
k <- nlevels(data$groups)
n <- nrow(data)
E <- model$statistic

Expand All @@ -244,7 +244,10 @@ kendalls_w <- function(x, groups, blocks, data = NULL,
R <- colSums(rankings)

no_ties <- apply(rankings, 1, function(x) length(x) == insight::n_unique(x))
if (!all(no_ties)) {
if (all(no_ties)) {
S <- stats::var(R) * (n - 1)
W <- (12 * S) / (m^2 * (n^3 - n))
} else {
if (verbose) {
insight::format_warning(
sprintf(
Expand All @@ -264,10 +267,6 @@ kendalls_w <- function(x, groups, blocks, data = NULL,

W <- (12 * sum(R^2) - 3 * (m^2) * n * ((n + 1)^2)) /
(m^2 * (n^3 - n) - m * Tj)
} else {
S <- stats::var(R) * (n - 1)
W <- (12 * S) /
(m^2 * (n^3 - n))
}
W
}
Expand Down
8 changes: 4 additions & 4 deletions R/rank_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ rank_biserial <- function(x, y = NULL, data = NULL,

alpha <- 1 - ci.level

rf <- atanh(r_rbs)
rank_f <- atanh(r_rbs)
if (is_paired_or_onesample) {
nd <- sum((x - mu) != 0)
maxw <- (nd^2 + nd) / 2
Expand Down Expand Up @@ -185,9 +185,9 @@ rank_biserial <- function(x, y = NULL, data = NULL,
rfSE <- sqrt((n1 + n2 + 1) / (3 * n1 * n2))
}

confint <- tanh(rf + c(-1, 1) * stats::qnorm(1 - alpha / 2) * rfSE)
out$CI_low <- confint[1]
out$CI_high <- confint[2]
conf_int <- tanh(rank_f + c(-1, 1) * stats::qnorm(1 - alpha / 2) * rfSE)
out$CI_low <- conf_int[1]
out$CI_high <- conf_int[2]
ci_method <- list(method = "normal")
out <- .limit_ci(out, alternative, -1, 1)
} else {
Expand Down

0 comments on commit 4c888ea

Please sign in to comment.