Skip to content

Commit

Permalink
fix nnt bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb committed Nov 8, 2023
1 parent 3efc17e commit 8fdbfad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
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: 0.8.6.2
Version: 0.8.6.3
Authors@R:
c(person(given = "Mattan S.",
family = "Ben-Shachar",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- `repeated_measures_d()` to compute standardized mean differences (SMD) for repeated measures data.
- Also supported in `effectsize(<t.test(paired = TRUE)>)`

## Bug fixes

- `nnt()` now properly accepts the `y` argument.

# effectsize 0.8.7

Expand Down
2 changes: 1 addition & 1 deletion R/xtab_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ nnt <- function(x, y = NULL, ci = 0.95, alternative = "two.sided", ...) {
return(effectsize(x, type = "nnt", ci = ci, ...))
}

out <- arr(x, y = t, ci = ci, alternative = alternative2, ...)
out <- arr(x, y = y, ci = ci, alternative = alternative2, ...)
out[[1]] <- 1 / out[[1]]
colnames(out)[1] <- "NNT"

Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-xtab.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ test_that("oddsratio & riskratio", {
expect_equal(ARR[[1]], -0.4891775, tolerance = 0.001)
expect_equal(ARR$CI_low, -0.8092576, tolerance = 0.001)
expect_equal(ARR$CI_high, -0.1690974, tolerance = 0.001)

# fix
set.seed(111)
x <- rbinom(10, 1, 0.5)
y <- rbinom(10, 1, 0.5)

expect_no_error(NNT <- nnt(x, y))
expect_equal(NNT[[1]], arr_to_nnt(arr(x, y)[[1]]))
})


Expand Down

0 comments on commit 8fdbfad

Please sign in to comment.