Skip to content

Commit

Permalink
Fix get_data()
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Apr 26, 2024
1 parent 63d8646 commit 197ccfd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: insight
Title: Easy Access to Model Information for Various Model Objects
Version: 0.19.10.1
Version: 0.19.10.2
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ S3method(get_data,clm2)
S3method(get_data,clmm)
S3method(get_data,clmm2)
S3method(get_data,complmrob)
S3method(get_data,coxme)
S3method(get_data,coxph)
S3method(get_data,cpglmm)
S3method(get_data,data.frame)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* More informative error message for `get_varcov()` when the requested
`vcov`-function failed.

## Bug fixes

* Fixed issue with `get_data()` for `coxme` models when `source`was set to
`"modelframe"`.

# insight 0.19.10

## Bug fixes
Expand Down
3 changes: 3 additions & 0 deletions R/get_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,9 @@ get_data.coxph <- function(x, source = "environment", verbose = TRUE, ...) {
dat
}

#' @export
get_data.coxme <- get_data.coxph


#' @export
get_data.BGGM <- function(x, ...) {
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-coxme.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,21 @@ withr::with_environment(
expect_identical(find_statistic(m1), "z-statistic")
expect_identical(find_statistic(m2), "z-statistic")
})

# get_data() works with this example
test_that("get_data works with mf", {
data(eortc, package = "coxme")
d <- eortc
d$surv <- survival::Surv(d$y, d$uncens)
mcoxme <- coxme::coxme(surv ~ trt + (1 | center), data = d)
# environment
out <- get_data(mcoxme)
expect_identical(nrow(out), 2323L)
expect_named(out, c("surv", "trt", "center"))
# modelframe
out <- get_data(mcoxme, source = "mf")
expect_identical(nrow(out), 2323L)
expect_named(out, c("y", "uncens", "center", "trt", "surv"))
})
}
)

0 comments on commit 197ccfd

Please sign in to comment.