Skip to content

Commit

Permalink
break tidy_stable_computable tests into two parts with lnorm-lnorm se…
Browse files Browse the repository at this point in the history
…parate
  • Loading branch information
joethorley committed Sep 23, 2024
1 parent d187237 commit bcdf395
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
17 changes: 6 additions & 11 deletions tests/testthat/_snaps/fit/tidy_stable_computable.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
dist,term,est,se
lgumbel,locationlog,0.011,NA
lgumbel,scalelog,0.0337,NA
llogis,locationlog,0.012,0.278
llogis,scalelog,0.0109,0.253
lnorm,meanlog,0.0233,1.41
lnorm,sdlog,0.0346,2.1
lnorm_lnorm,meanlog1,0.032,NA
lnorm_lnorm,meanlog2,-3.48e-4,0.0186
lnorm_lnorm,pmix,0.893,NA
lnorm_lnorm,sdlog1,0.0408,1.73
lnorm_lnorm,sdlog2,0.00519,NA
lgumbel,locationlog,0.0110209,NA
lgumbel,scalelog,0.0337459,NA
llogis,locationlog,0.0119926,0.278196
llogis,scalelog,0.0109175,0.253246
lnorm,meanlog,0.0233306,1.41354
lnorm,sdlog,0.0345919,2.09585
6 changes: 6 additions & 0 deletions tests/testthat/_snaps/lnorm-lnorm/lnorm_lnorm_no_se.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist,term,est,se
lnorm_lnorm,meanlog1,0.032,NA
lnorm_lnorm,meanlog2,-3.48e-4,0.0186
lnorm_lnorm,pmix,0.893,NA
lnorm_lnorm,sdlog1,0.0408,1.73
lnorm_lnorm,sdlog2,0.00519,NA
4 changes: 2 additions & 2 deletions tests/testthat/test-fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ test_that("ssd_fit_dists computable = TRUE allows for fits without standard erro
)

set.seed(102)
fits <- ssd_fit_dists(data, right = "Other", dists = c("lgumbel", "llogis", "lnorm", "lnorm_lnorm"), rescale = FALSE, at_boundary_ok = TRUE)
fits <- ssd_fit_dists(data, right = "Other", dists = c("lgumbel", "llogis", "lnorm"), rescale = FALSE, at_boundary_ok = TRUE)

tidy <- tidy(fits)
expect_s3_class(tidy, "tbl")
expect_snapshot_data(tidy, "tidy_stable_computable", digits = 3)
expect_snapshot_data(tidy, "tidy_stable_computable", digits = 6)
})

test_that("ssd_fit_dists works with slightly censored data", {
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-hc.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ test_that("ssd_hc works with fully left censored data", {

set.seed(100)
fits <- ssd_fit_dists(data, dists = "lnorm", right = "right")
hc <- ssd_hc(fits, ci = TRUE, nboot = 10, average = FALSE)
expect_warning(hc <- ssd_hc(fits, ci = TRUE, nboot = 10, average = FALSE),
"^Parametric CIs cannot be calculated for censored data\\.$")
expect_snapshot_data(hc, "partialeftfull")
})

Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-lnorm-lnorm.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ test_that("lnorm_lnorm positive q with extreme large distribution", {
meanlog2 = 100.39362, sdlog2 = 2.583824, pmix = 0.1308133
), 1.41684268426224e+46)
})

test_that("ssd_fit_dists allows for fits without standard errors lnorm_lnorm", {
data <- ssddata::ccme_boron
data$Other <- data$Conc
data$Conc <- data$Conc / max(data$Conc)

set.seed(102)
fits <- ssd_fit_dists(data, right = "Other", dists = c("lnorm_lnorm"))

tidy <- tidy(fits)
expect_s3_class(tidy, "tbl")
expect_snapshot_data(tidy, "lnorm_lnorm_no_se", digits = 3)
})

0 comments on commit bcdf395

Please sign in to comment.