Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Snapshot tests #360

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
CMDSTAN=/root/.cmdstan
CMDSTAN_PATH=/root/.cmdstan
CMDSTANR_NO_VER_CHECK=true
NOT_CRAN=TRUE
### Temporarily removed due to cache bug (#345)
# JMPOST_CACHE_DIR=${{ github.workspace }}/.cache
# additional-caches: |
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/JointModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Weibull-PH Survival Model with parameters:
sm_weibull_ph_lambda ~ gamma(alpha = 2, beta = 0.5)
sm_weibull_ph_gamma ~ gamma(alpha = 2, beta = 0.5)
beta_os_cov ~ normal(mu = 0, sigma = 5)
beta_os_cov ~ normal(mu = 0, sigma = 2)

Longitudinal:
Random Slope Longitudinal Model with parameters:
Expand Down Expand Up @@ -40,7 +40,7 @@
Weibull-PH Survival Model with parameters:
sm_weibull_ph_lambda ~ gamma(alpha = 2, beta = 0.5)
sm_weibull_ph_gamma ~ gamma(alpha = 2, beta = 0.5)
beta_os_cov ~ normal(mu = 0, sigma = 5)
beta_os_cov ~ normal(mu = 0, sigma = 2)

Longitudinal:
Random Slope Longitudinal Model with parameters:
Expand Down Expand Up @@ -68,7 +68,7 @@
Weibull-PH Survival Model with parameters:
sm_weibull_ph_lambda ~ gamma(alpha = 2, beta = 0.5)
sm_weibull_ph_gamma ~ gamma(alpha = 2, beta = 0.5)
beta_os_cov ~ normal(mu = 0, sigma = 5)
beta_os_cov ~ normal(mu = 0, sigma = 2)

Longitudinal:
Not Specified
Expand Down Expand Up @@ -121,7 +121,7 @@
Weibull-PH Survival Model with parameters:
sm_weibull_ph_lambda ~ gamma(alpha = 2, beta = 0.5)
sm_weibull_ph_gamma ~ gamma(alpha = 2, beta = 0.5)
beta_os_cov ~ normal(mu = 0, sigma = 5)
beta_os_cov ~ normal(mu = 0, sigma = 2)

Longitudinal:
Random Slope Longitudinal Model with parameters:
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/SurvivalExponential.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Exponential Survival Model with parameters:
sm_exp_lambda ~ gamma(alpha = 2, beta = 5)
beta_os_cov ~ normal(mu = 0, sigma = 5)
beta_os_cov ~ normal(mu = 0, sigma = 2)


---
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/SurvivalLoglogistic.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Log-Logistic Survival Model with parameters:
sm_loglogis_a ~ lognormal(mu = -2.30259, sigma = 5)
sm_loglogis_b ~ gamma(alpha = 2, beta = 5)
beta_os_cov ~ normal(mu = 0, sigma = 5)
beta_os_cov ~ normal(mu = 0, sigma = 2)


---
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/SurvivalWeibullPH.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Weibull-PH Survival Model with parameters:
sm_weibull_ph_lambda ~ gamma(alpha = 2, beta = 0.5)
sm_weibull_ph_gamma ~ gamma(alpha = 2, beta = 0.5)
beta_os_cov ~ normal(mu = 0, sigma = 5)
beta_os_cov ~ normal(mu = 0, sigma = 2)


---
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-LongitudinalRandomSlope.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ test_that("Random Slope Model left-censoring works as expected", {
sampleStanModel(
jm,
data = jdat,
iter_sampling = 200,
iter_sampling = 300,
iter_warmup = 400,
chains = 1,
refresh = 0,
Expand Down
14 changes: 8 additions & 6 deletions tests/testthat/test-SurvivalQuantities.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,29 @@ test_that("SurvivalQuantities and autoplot.SurvivalQuantities works as expected"

# Check that the relationship between the quantitites is preservered e.g.
# that `surv = exp(-cumhaz)`
time_vec <- c(0, 1, 10, 30, 40, 200, 300, 400)
preds1 <- SurvivalQuantities(
test_data_1$jsamples,
grid = GridFixed(subjects = "subject_0001", times = c(200, 300))
grid = GridFixed(subjects = "subject_0001", times = time_vec)
) |> summary()
preds2 <- SurvivalQuantities(
test_data_1$jsamples,
grid = GridFixed(subjects = "subject_0001", times = c(200, 300)),
grid = GridFixed(subjects = "subject_0001", times = time_vec),
type = "cumhaz"
) |> summary()
preds3 <- SurvivalQuantities(
test_data_1$jsamples,
grid = GridFixed(subjects = "subject_0001", times = c(200, 300)),
grid = GridFixed(subjects = "subject_0001", times = time_vec),
type = "haz"
) |> summary()
preds4 <- SurvivalQuantities(
test_data_1$jsamples,
grid = GridFixed(subjects = "subject_0001", times = c(200, 300)),
grid = GridFixed(subjects = "subject_0001", times = time_vec),
type = "loghaz"
) |> summary()
expect_equal(round(preds1$median, 5), round(exp(-preds2$median), 5))
expect_equal(round(preds3$median, 5), round(exp(preds4$median), 5))

expect_equal(preds1$median, exp(-preds2$median), tolerance = 0.00001)
expect_equal(preds3$median, exp(preds4$median), tolerance = 0.00001)
expect_true(all(preds1$median != preds3$median))
})

Expand Down
Loading