From 44bdae98fb7b64a24b57e520937f247492d3eb5b Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Tue, 5 May 2026 13:44:21 +0800 Subject: [PATCH 1/5] add reprex test --- tests/testthat/test-CMHtest.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/testthat/test-CMHtest.R b/tests/testthat/test-CMHtest.R index 60a0cecb..88b60276 100644 --- a/tests/testthat/test-CMHtest.R +++ b/tests/testthat/test-CMHtest.R @@ -168,3 +168,10 @@ test_that("5x3x3 schema, ordinal variables", { expected <- get_sas_results(6L) expect_equal(result, expected, tolerance = 1e-3) }) + +test_that("CMHTest based on xtabs() can give overall df and p-value", { + ord_tab <- xtabs(~ TRTP + SEX + AGEGR1, data = data) + result <- CMHtest(ord_tab, types = "rmeans", overall = TRUE) + expect_true(is.finite(result$ALL$table["rmeans", "Df", drop = TRUE][[1]])) + expect_true(is.finite(result$ALL$table["rmeans", "Prob", drop = TRUE][[1]])) +}) From 9c612571d3fd053186b217bed0470c9ecf4e14a9 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Tue, 5 May 2026 13:46:13 +0800 Subject: [PATCH 2/5] update pkgdown ... not sure what exactly it is but ok --- docs/reference/logseries.html | 203 ++-------------------------------- 1 file changed, 7 insertions(+), 196 deletions(-) diff --git a/docs/reference/logseries.html b/docs/reference/logseries.html index f9174227..49cf04cb 100644 --- a/docs/reference/logseries.html +++ b/docs/reference/logseries.html @@ -1,197 +1,8 @@ - -The Logarithmic Series Distribution — dlogseries • vcdExtra - Skip to contents - - -
-
-
- -
-

The logarithmic series distribution is a long-tailed distribution introduced -by Fisher etal. (1943) in connection with data on the abundance of -individuals classified by species.

-
- -
-

Usage

-
dlogseries(x, prob = 0.5, log = FALSE)
-
-plogseries(q, prob = 0.5, lower.tail = TRUE, log.p = FALSE)
-
-qlogseries(p, prob = 0.5, lower.tail = TRUE, log.p = FALSE, max.value = 10000)
-
-rlogseries(n, prob = 0.5)
-
- -
-

Arguments

- - -
x, q
-

vector of quantiles representing the number of events.

- - -
prob
-

parameter for the distribution, 0 < prob < 1

- - -
log, log.p
-

logical; if TRUE, probabilities p are given as log(p)

- - -
lower.tail
-

logical; if TRUE (default), probabilities are \(P[X \le x]\), otherwise, \(P[X > x]\).

- - -
p
-

vector of probabilities

- - -
max.value
-

maximum value returned by qlogseries

- - -
n
-

number of observations for rlogseries

- -
-
-

Value

-

dlogseries gives the density, -plogseries gives the cumulative distribution function, -qlogseries gives the quantile function, and -rlogseries generates random deviates.

-
-
-

Details

-

These functions provide the density, distribution function, quantile -function and random generation for the logarithmic series distribution with -parameter prob.

-

The logarithmic series distribution with prob = \(p\) has density -$$ p ( x ) = \alpha p^x / x $$ for \(x = 1, 2, \dots\), -where -\(\alpha= -1 / \log(1 - p)\) and \(0 < p < 1\). -% Note that counts x==2 cannot occur.

-
-
-

References

-

https://en.wikipedia.org/wiki/Logarithmic_distribution

-

Fisher, R. A. and Corbet, A. S. and Williams, C. B. (1943). The relation -between the number of species and the number of individuals Journal of -Animal Ecology, 12, 42-58.

-
-
-

See also

- -
-
-

Author

-

Michael Friendly, using original code modified from the -gmlss.dist package by Mikis Stasinopoulos.

-
- -
-

Examples

-

-XL <-expand.grid(x=1:5, p=c(0.33, 0.66, 0.99))
-lgs.df <- data.frame(XL, prob=dlogseries(XL[,"x"], XL[,"p"]))
-lgs.df$p = factor(lgs.df$p)
-str(lgs.df)
-#> 'data.frame':	15 obs. of  3 variables:
-#>  $ x   : int  1 2 3 4 5 1 2 3 4 5 ...
-#>  $ p   : Factor w/ 3 levels "0.33","0.66",..: 1 1 1 1 1 2 2 2 2 2 ...
-#>  $ prob: num  0.82402 0.13596 0.02991 0.0074 0.00195 ...
-
-require(lattice)
-#> Loading required package: lattice
-#> 
-#> Attaching package: ‘lattice’
-#> The following object is masked from ‘package:seriation’:
-#> 
-#>     panel.lines
-#> The following object is masked from ‘package:gnm’:
-#> 
-#>     barley
-mycol <- palette()[2:4]
-xyplot( prob ~ x, data=lgs.df, groups=p,
-  xlab=list('Number of events (k)', cex=1.25),
-  ylab=list('Probability',  cex=1.25),
-  type='b', pch=15:17, lwd=2, cex=1.25, col=mycol,
-  key = list(
-          title = 'p',
-          points = list(pch=15:17, col=mycol, cex=1.25),
-          lines = list(lwd=2, col=mycol),
-          text = list(levels(lgs.df$p)),
-          x=0.9, y=0.98, corner=c(x=1, y=1)
-          )
-  )
-
-
-
-# random numbers
-hist(rlogseries(200, prob=.4), xlab='x')
-
-hist(rlogseries(200, prob=.8), xlab='x')
-
-
-
-
-
-
-
- - -
- - - -
- - - - - - + + + + + + + From 01eb081faa866425c6e31b1fa8080e692dd8b154 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Tue, 5 May 2026 14:14:37 +0800 Subject: [PATCH 3/5] make sure that Df has names of the types in CMHtest3 --- R/CMHtest.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/CMHtest.R b/R/CMHtest.R index f49dd332..782d3d4c 100644 --- a/R/CMHtest.R +++ b/R/CMHtest.R @@ -486,7 +486,12 @@ CMHtest3 <- function(object, types = c("cor", "rmeans", "cmeans", "general")) { V.list <- lapply(object, function(s) s$V) A.list <- lapply(object, function(s) s$A) nt <- sapply(lapply(object, function(s) s$n), sum) - Df <- object[[1]]$table[, "Df"] + + tab1 <- object[[1]]$table + Df <- stats::setNames( + tab1[, "Df"], + rownames(tab1) + ) if (length(types) == 1 && types == "ALL") { types <- c("general", "rmeans", "cmeans", "cor") From 0534e7697a16e04acaa1adb010a236f69d47256c Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Tue, 5 May 2026 14:16:50 +0800 Subject: [PATCH 4/5] add another test with multiple types --- tests/testthat/test-CMHtest.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/testthat/test-CMHtest.R b/tests/testthat/test-CMHtest.R index 88b60276..82bf5926 100644 --- a/tests/testthat/test-CMHtest.R +++ b/tests/testthat/test-CMHtest.R @@ -175,3 +175,10 @@ test_that("CMHTest based on xtabs() can give overall df and p-value", { expect_true(is.finite(result$ALL$table["rmeans", "Df", drop = TRUE][[1]])) expect_true(is.finite(result$ALL$table["rmeans", "Prob", drop = TRUE][[1]])) }) + +test_that("CMHTest can give overall df and p-value with multiple types", { + ord_tab <- xtabs(~ TRTP + SEX + AGEGR1, data = data) + result <- CMHtest(ord_tab, types = c("rmeans", "cmeans"), overall = TRUE) + expect_true(all(is.finite(unlist(result$ALL$table[, "Df", drop = TRUE])))) + expect_true(all(is.finite(unlist(result$ALL$table[, "Prob", drop = TRUE])))) +}) From 57e82638bae45774dbb2abc80dccfd4998342b30 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Tue, 5 May 2026 14:20:45 +0800 Subject: [PATCH 5/5] added news entry --- DESCRIPTION | 3 ++- NEWS.md | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e5040043..32b4ef6c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,8 @@ Authors@R: c( email = "d.firth@warwick.ac.uk"), person(given = "Daniel", family = "Sabanes Bove", role="ctb", - email = "daniel.sabanesbove@gmail.com"), + email = "daniel@rconis.com", + comment = c(ORCID = "0000-0002-0176-9239")), person(given = "Matt", family = "Kumar", role="ctb"), person(given = "Shuguang", family = "Sun", role="ctb"), person(given = "Gavin", family = "Klorfine", role = "aut") diff --git a/NEWS.md b/NEWS.md index 308b95c4..0550e149 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +## Version 0.9.6 + +* Fixed bug in `CMHtest` which previously suppressed `Df` and `Prob` (p-value) for the overall population results. + ## Version 0.9.5 This is a major release of the package, completing work on a sizeable collection of tidy tools