Skip to content

Commit 3bfce0c

Browse files
authored
Add tests for estimate_grouplevel.coxme (#553)
* Add tests for estimate_grouplevel.coxme * fix * fix warning
1 parent 1d13ee2 commit 3bfce0c

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: modelbased
33
Title: Estimation of Model-Based Predictions, Contrasts and Means
4-
Version: 0.12.0.14
4+
Version: 0.12.0.15
55
Authors@R:
66
c(person(given = "Dominique",
77
family = "Makowski",
@@ -58,6 +58,7 @@ Suggests:
5858
coda,
5959
collapse,
6060
correlation,
61+
coxme,
6162
curl,
6263
discovr,
6364
easystats,
@@ -113,4 +114,4 @@ Roxygen: list(markdown = TRUE)
113114
Config/Needs/check: stan-dev/cmdstanr
114115
Config/Needs/website: easystats/easystatstemplate
115116
LazyData: true
116-
Remotes: easystats/insight
117+
Remotes: easystats/insight, easystats/parameters

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* `estimate_expectation()` and `estimate_relation()` now support objects of
3030
class `htest`.
3131

32+
* `estimate_grouplevel()` now supports models from package *coxme*.
33+
3234
* Documentation of the `display()` method for *modelbased* objects has been
3335
added.
3436

inst/WORDLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ conditionspeed
102102
counterfactuals
103103
confounder
104104
confounders
105+
coxme
105106
d'être
106107
d’être
107108
dat

tests/testthat/test-estimate_grouplevel.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,38 @@ test_that("estimate_grouplevel - Bayesian, rstanarm", {
140140
expect_identical(dim(out), c(3L, 4L))
141141
expect_named(out, c("Group", "Level", "Parameter", "Coefficient"))
142142
})
143+
144+
145+
skip_if_not_installed("withr")
146+
147+
withr::with_environment(
148+
new.env(),
149+
test_that("estimate_grouplevel, coxme", {
150+
skip_on_cran()
151+
skip_if_not_installed("coxme")
152+
skip_if_not_installed("survival")
153+
154+
Surv <- survival::Surv
155+
rats <- survival::rats
156+
lung <- survival::lung
157+
158+
set.seed(1234)
159+
rats$grp <- sample(letters[1:3], nrow(rats), replace = TRUE)
160+
161+
data(eortc, package = "coxme")
162+
d <<- coxme::eortc
163+
d2 <<- rats
164+
d3 <<- lung
165+
166+
m1 <- coxme::coxme(Surv(y, uncens) ~ trt + (1 | center), data = d)
167+
m2 <- coxme::coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), d3)
168+
m3 <- coxme::coxme(Surv(time, status) ~ rx + (1 + rx | litter) + (1 | grp), d2)
169+
170+
out <- estimate_grouplevel(m1)
171+
expect_identical(dim(out), c(37L, 5L))
172+
out <- estimate_grouplevel(m2)
173+
expect_identical(dim(out), c(18L, 5L))
174+
out <- estimate_grouplevel(m3)
175+
expect_identical(dim(out), c(203L, 5L))
176+
})
177+
)

0 commit comments

Comments
 (0)