Skip to content
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: effectsize
Title: Indices of Effect Size
Version: 1.0.2
Version: 1.0.2.0000001
Authors@R:
c(person(given = "Mattan S.",
family = "Ben-Shachar",
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# effectsize 1.0.x

## Bug fixes

- `eta_squared(<afex> / <Anova.mlm>)` with partially overlapping factor names now return correct effect sizes ( #697 )

# effectsize 1.0.2

## New features
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 @@ -152,10 +152,10 @@
within_subj <- sapply(within_subj, paste, collapse = ":")
within_subj <- within_subj[order(ns)]
within_subj <- Filter(function(x) nzchar(x, keepNA = TRUE), within_subj)
l <- sapply(within_subj, grepl, x = aov_tab$Parameter, simplify = TRUE)
l <- sapply(paste0("\\b", within_subj, "\\b"), grepl, x = aov_tab$Parameter, simplify = TRUE)
l <- apply(l, 1, function(x) if (any(x)) max(which(x)) else 0)
l <- c(NA, within_subj)[l + 1]
l <- sapply(l, function(x) paste0(stats::na.omit(c(id, x)), collapse = ":"))

Check warning on line 158 in R/eta_squared-methods.R

View workflow job for this annotation

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

file=R/eta_squared-methods.R,line=158,col=32,[paste_linter] Use paste(), not paste0(), to collapse a character vector when sep= is not used.
aov_tab$Group <- l

aov_tab <- split(aov_tab, aov_tab$Group)
Expand Down
47 changes: 47 additions & 0 deletions tests/testthat/test-eta_squared.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("alternative = NULL", {
m <- aov(mpg ~ factor(cyl) + hp, mtcars)
expect_equal(

Check warning on line 3 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=3,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
eta_squared(m),
eta_squared(m, alternative = NULL)
)
Expand Down Expand Up @@ -93,8 +93,8 @@
c(1.360, 0.373, 0.036),
tolerance = 0.001
)
expect_equal(cohens_f(fit, squared = TRUE), cohens_f_squared(fit))

Check warning on line 96 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=96,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
expect_equal(cohens_f_squared(fit, squared = FALSE), cohens_f(fit))

Check warning on line 97 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=97,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.

#### One way-between
expect_message(eta_squared(aov(mpg ~ factor(gear), mtcars)))
Expand All @@ -104,10 +104,10 @@
m <<- aov(mpg ~ factor(gear) + am, mtcars)
et1 <- eta_squared(m)
et2 <- eta_squared(m, ci = 0.9, alternative = "two.sided")
expect_equal(et1$CI_low, et2$CI_low)

Check warning on line 107 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=107,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.

### parameters:
expect_equal(

Check warning on line 110 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=110,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
eta_squared(parameters::model_parameters(m)),
eta_squared(m)
)
Expand Down Expand Up @@ -149,7 +149,7 @@
tolerance = 0.001
)

expect_equal(

Check warning on line 152 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=152,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
eta_squared(parameters::model_parameters(model)),
eta_squared(model)
)
Expand Down Expand Up @@ -183,7 +183,7 @@
rownames(a1) <- a1$Parameter
rownames(a2) <- a2$Parameter

expect_equal(

Check warning on line 186 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=186,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
a1[a1$Parameter, "Eta2"],
a2[a1$Parameter, "Eta2"]
)
Expand All @@ -199,12 +199,12 @@
m1 <- lm(mpg ~ am_f * cyl_f, data = mtcars)
m2 <- lm(qsec ~ am_f * cyl_f, data = mtcars)

expect_equal(

Check warning on line 202 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=202,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
eta_squared(mod)$Eta2_partial[1:3],
eta_squared(m1)$Eta2_partial
)

expect_equal(

Check warning on line 207 in tests/testthat/test-eta_squared.R

View workflow job for this annotation

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

file=tests/testthat/test-eta_squared.R,line=207,col=3,[expect_identical_linter] Use expect_identical(x, y) by default; resort to expect_equal() only when needed, e.g. when setting ignore_attr= or tolerance=.
eta_squared(mod)$Eta2_partial[4:6],
eta_squared(m2)$Eta2_partial
)
Expand Down Expand Up @@ -779,6 +779,53 @@
expect_equal(A1[c(2:4, 6:7), ], A2[c(2:4, 6:7), -1], ignore_attr = TRUE)
})

test_that("Anova.mlm / afex | overlapping factor names", {
skip_if_not_installed("car")
skip_if_not_installed("afex")

data <- data.frame(
subject = c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 9L, 10L, 9L, 10L, 9L, 10L, 9L, 10L),
XBlock = factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), labels = c("a1", "a2")),
Block = factor(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), labels = c("aa1", "aa2")),
C = factor(c(1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), labels = c("C_c1", "C_c2")),
y = c(-0.09, -0.29, 0.13, 0.06, 0.17, -0.01, 0.07, 0.27, 0.05, -0.01, -0.07, -0.05, 0.15, 0.12, 0.09, 0.26)
)
contrasts(data$XBlock) <- contr.sum
data$X <- data$XBlock


# list partial eta_squared:
aov_overlap <- afex::aov_ez(
"subject", "y", data,
between = "XBlock",
within = c("Block", "C"),
anova_table = list(es = "pes")
)

aov_nooverlap <- afex::aov_ez(
"subject", "y", data,
between = "X",
within = c("Block", "C"),
anova_table = list(es = "pes")
)

expect_equal(
aov_overlap$anova_table$pes,
eta_squared(aov_overlap)$Eta2_partial
)

expect_equal(
eta_squared(aov_overlap)$Eta2_partial,
eta_squared(aov_nooverlap)$Eta2_partial
)

expect_equal(
eta_squared(aov_overlap)$Eta2_partial,
eta_squared(aov_overlap$Anova)$Eta2_partial
)
})


## merMod --------------------

test_that("merMod and lmerModLmerTest", {
Expand Down
Loading