From 96c418c0a504cc0593bd3d36b342bce61f08cf52 Mon Sep 17 00:00:00 2001 From: Kyle Bittinger Date: Fri, 6 Mar 2026 08:27:07 -0500 Subject: [PATCH 1/6] Remove betareg fits from tests --- tests/testthat/test-simulations.R | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/testthat/test-simulations.R b/tests/testthat/test-simulations.R index 926ae56..2fc067e 100755 --- a/tests/testthat/test-simulations.R +++ b/tests/testthat/test-simulations.R @@ -14,16 +14,6 @@ expected_bre_fit <- list( test_that("simulate_beta_data works", { beta_data <- simulate_beta_random_effect_data() - - # betareg can not fit random effect model so set the s2 to a small value (small random effect) - tdata <- data.frame(Y = beta_data$Y, beta_data$Z, SID = beta_data$subject_ind) - gy <- betareg::betareg(beta_data$Y ~ log.Time + as.factor(Treatment), data = tdata, type = "ML") - #print(summary(gy)) - gy <- betareg::betareg(beta_data$Y ~ log.Time + as.factor(Treatment), data = tdata, type = "BC") - #print(summary(gy)) - gy <- betareg::betareg(beta_data$Y ~ log.Time + as.factor(Treatment), data = tdata, type = "BR") - #print(summary(gy)) - res <- fit_beta_random_effect(Z = beta_data$Z, Y = beta_data$Y, subject.ind = beta_data$subject_ind, From 756caa6d1dda83f2a74b06e952c2d58c71ad5e80 Mon Sep 17 00:00:00 2001 From: Kyle Bittinger Date: Fri, 6 Mar 2026 08:27:48 -0500 Subject: [PATCH 2/6] Remove dput from test --- tests/testthat/test-simulations.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/testthat/test-simulations.R b/tests/testthat/test-simulations.R index 2fc067e..0b1fcb6 100755 --- a/tests/testthat/test-simulations.R +++ b/tests/testthat/test-simulations.R @@ -49,7 +49,5 @@ test_that("simulate_logistic_data works", { Y = logistic_data$Y, subject.ind = logistic_data$subject_ind, time.ind = logistic_data$time_ind) - dput(res) - expect_equal(res, expected_lre_fit, tolerance = 1e-3) }) From 677965a4e0a4322997c625dd624fc7767398500c Mon Sep 17 00:00:00 2001 From: Kyle Bittinger Date: Fri, 6 Mar 2026 08:31:10 -0500 Subject: [PATCH 3/6] Build matrix output with matrix() --- tests/testthat/test-simulations.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-simulations.R b/tests/testthat/test-simulations.R index 0b1fcb6..378ae9d 100755 --- a/tests/testthat/test-simulations.R +++ b/tests/testthat/test-simulations.R @@ -1,9 +1,9 @@ expected_bre_fit <- list( - est.table = structure( + est.table = matrix( c(-0.60955243747617, -0.443501946207444, 0.736943004541776, 0.0104576873063189, 0.000414042620671129, 0.0123799088684966), - .Dim = 3:2, - .Dimnames = list( + nrow = 3, + dimnames = list( c("intersept", "log.Time", "Treatment"), c("Estimate", "Pvalue") ) @@ -25,11 +25,11 @@ test_that("simulate_beta_data works", { }) expected_lre_fit <- list( - est.table = structure( + est.table = matrix( c(0.306795205483351, 0.280454254105502, -0.667159092633291, 0.431194361789462, 0.266160176079596, 0.123214729652536), - .Dim = 3:2, - .Dimnames = list(c("intersept", "log.Time", "Treatment"), c("Estimate", "Pvalue")) + nrow = 3, + dimnames = list(c("intersept", "log.Time", "Treatment"), c("Estimate", "Pvalue")) ), s1.est = 1.12114408844058 ) From 952d2a1f0b01b80b8e6bc47b87a4027b2674cc30 Mon Sep 17 00:00:00 2001 From: Kyle Bittinger Date: Fri, 6 Mar 2026 08:36:30 -0500 Subject: [PATCH 4/6] Build matrix output with matrix() in zibr tests --- tests/testthat/test-zibr.R | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/testthat/test-zibr.R b/tests/testthat/test-zibr.R index f2efa6d..ca000e4 100755 --- a/tests/testthat/test-zibr.R +++ b/tests/testthat/test-zibr.R @@ -1,17 +1,17 @@ real_expected <- list( - logistic_est_table = structure( + logistic_est_table = matrix( c(2.69732340911363, 0.200018071642455, 6.17105397782147e-06, 0.887710710500198), - .Dim = c(2L, 2L), - .Dimnames = list( + nrow = 2, + dimnames = list( c("intersept", "Treatment"), c("Estimate", "Pvalue") ) ), logistic_s1_est = 3.27876357265477, - beta_est_table = structure( + beta_est_table = matrix( c(-2.78605402671509, -0.32334269957996, 0, 0.206300170582503), - .Dim = c(2L, 2L), - .Dimnames = list( + nrow = 2, + dimnames = list( c("intersept", "Treatment"), c("Estimate", "Pvalue") ) @@ -55,19 +55,19 @@ sim <- simulate_zero_inflated_beta_random_effect_data( ) sim_expected <- list( - logistic_est_table = structure( + logistic_est_table = matrix( c(-0.571900346260645, 0.828072571379781, 0.0069577928092327, 0.00547006539016526), - .Dim = c(2L, 2L), - .Dimnames = list( + nrow = 2, + dimnames = list( c("intersept", "var1"), c("Estimate", "Pvalue") ) ), logistic_s1_est = 1.06801391077711, - beta_est_table = structure( + beta_est_table = matrix( c(-0.593090577296489, 0.591745582740125, 4.18162741963046e-05, 0.00169945318503251), - .Dim = c(2L, 2L), - .Dimnames = list( + nrow = 2, + dimnames = list( c("intersept", "var1"), c("Estimate", "Pvalue") ) @@ -79,19 +79,19 @@ sim_expected <- list( ) sim_expected_cov <- list( - logistic_est_table = structure( + logistic_est_table = matrix( c(-0.571900346260645, 0.828072571379781, 0.0069577928092327, 0.00547006539016526), - .Dim = c(2L, 2L), - .Dimnames = list( + nrow = 2, + dimnames = list( c("intersept", "var1"), c("Estimate", "Pvalue") ) ), logistic_s1_est = 1.06801391077711, - beta_est_table = structure( + beta_est_table = matrix( c(-0.593090577296489, 0.591745582740125, 4.18162741963046e-05, 0.00169945318503251), - .Dim = c(2L, 2L), - .Dimnames = list( + nrow = 2, + dimnames = list( c("intersept", "var1"), c("Estimate", "Pvalue") ) From dd8a824854325676ca5781cede40a3e3660dd772 Mon Sep 17 00:00:00 2001 From: Kyle Bittinger Date: Fri, 6 Mar 2026 08:41:52 -0500 Subject: [PATCH 5/6] Reformat test code with styler --- tests/testthat/test-simulations.R | 52 +++++++++++++++++++------------ tests/testthat/test-zibr.R | 44 +++++++++++++++----------- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/tests/testthat/test-simulations.R b/tests/testthat/test-simulations.R index 378ae9d..026f191 100755 --- a/tests/testthat/test-simulations.R +++ b/tests/testthat/test-simulations.R @@ -1,7 +1,9 @@ expected_bre_fit <- list( est.table = matrix( - c(-0.60955243747617, -0.443501946207444, 0.736943004541776, - 0.0104576873063189, 0.000414042620671129, 0.0123799088684966), + c( + -0.60955243747617, -0.443501946207444, 0.736943004541776, + 0.0104576873063189, 0.000414042620671129, 0.0123799088684966 + ), nrow = 3, dimnames = list( c("intersept", "log.Time", "Treatment"), @@ -14,20 +16,24 @@ expected_bre_fit <- list( test_that("simulate_beta_data works", { beta_data <- simulate_beta_random_effect_data() - res <- fit_beta_random_effect(Z = beta_data$Z, - Y = beta_data$Y, - subject.ind = beta_data$subject_ind, - time.ind = beta_data$time_ind, - quad.n = 30, - verbose = FALSE) + res <- fit_beta_random_effect( + Z = beta_data$Z, + Y = beta_data$Y, + subject.ind = beta_data$subject_ind, + time.ind = beta_data$time_ind, + quad.n = 30, + verbose = FALSE + ) expect_equal(res, expected_bre_fit, tolerance = 1e-3) }) expected_lre_fit <- list( est.table = matrix( - c(0.306795205483351, 0.280454254105502, - -0.667159092633291, 0.431194361789462, 0.266160176079596, 0.123214729652536), + c( + 0.306795205483351, 0.280454254105502, + -0.667159092633291, 0.431194361789462, 0.266160176079596, 0.123214729652536 + ), nrow = 3, dimnames = list(c("intersept", "log.Time", "Treatment"), c("Estimate", "Pvalue")) ), @@ -37,17 +43,23 @@ expected_lre_fit <- list( test_that("simulate_logistic_data works", { logistic_data <- simulate_logistic_data() - tdata <- data.frame(Y = logistic_data$Y, logistic_data$X, SID = logistic_data$subject_ind) - lme.fit <- lme4::glmer(as.factor(logistic_data$Y) ~ log.Time + as.factor(Treatment) + (1 | SID), - data = tdata, - family = binomial, - control = lme4::glmerControl(optimizer = "bobyqa"), - nAGQ = 10) + tdata <- data.frame( + Y = logistic_data$Y, logistic_data$X, SID = logistic_data$subject_ind + ) + lme.fit <- lme4::glmer( + as.factor(logistic_data$Y) ~ log.Time + as.factor(Treatment) + (1 | SID), + data = tdata, + family = binomial, + control = lme4::glmerControl(optimizer = "bobyqa"), + nAGQ = 10 + ) summary(lme.fit) - res <- fit_logistic_random_effect(X = logistic_data$X, - Y = logistic_data$Y, - subject.ind = logistic_data$subject_ind, - time.ind = logistic_data$time_ind) + res <- fit_logistic_random_effect( + X = logistic_data$X, + Y = logistic_data$Y, + subject.ind = logistic_data$subject_ind, + time.ind = logistic_data$time_ind + ) expect_equal(res, expected_lre_fit, tolerance = 1e-3) }) diff --git a/tests/testthat/test-zibr.R b/tests/testthat/test-zibr.R index ca000e4..dead8a3 100755 --- a/tests/testthat/test-zibr.R +++ b/tests/testthat/test-zibr.R @@ -30,13 +30,15 @@ test_that("zibr main function works on package data", { time_ind = ibd$Time ) - expected_names <- c("logistic_est_table", - "logistic_s1_est", - "beta_est_table", - "beta_s2_est", - "beta_v_est", - "loglikelihood", - "joint_p") + expected_names <- c( + "logistic_est_table", + "logistic_s1_est", + "beta_est_table", + "beta_s2_est", + "beta_v_est", + "loglikelihood", + "joint_p" + ) expect_equal(names(zibr_fit), expected_names) expect_equal(zibr_fit, real_expected, tolerance = 1e-3) }) @@ -66,8 +68,8 @@ sim_expected <- list( logistic_s1_est = 1.06801391077711, beta_est_table = matrix( c(-0.593090577296489, 0.591745582740125, 4.18162741963046e-05, 0.00169945318503251), - nrow = 2, - dimnames = list( + nrow = 2, + dimnames = list( c("intersept", "var1"), c("Estimate", "Pvalue") ) @@ -103,21 +105,25 @@ sim_expected_cov <- list( ) test_that("zibr main function works on simulated data", { - zibr_fit <- zibr(logistic_cov = sim$X, - beta_cov = sim$Z, - Y = sim$Y, - subject_ind = sim$subject_ind, - time_ind = sim$time_ind) + zibr_fit <- zibr( + logistic_cov = sim$X, + beta_cov = sim$Z, + Y = sim$Y, + subject_ind = sim$subject_ind, + time_ind = sim$time_ind + ) expect_equal(zibr_fit, sim_expected, tolerance = 1e-3) }) test_that("zibr main function works on simulated data with same covariates", { - zibr_fit <- zibr(logistic_cov = sim$X, - beta_cov = sim$X, - Y = sim$Y, - subject_ind = sim$subject_ind, - time_ind = sim$time_ind) + zibr_fit <- zibr( + logistic_cov = sim$X, + beta_cov = sim$X, + Y = sim$Y, + subject_ind = sim$subject_ind, + time_ind = sim$time_ind + ) expect_equal(zibr_fit, sim_expected_cov, tolerance = 1e-3) }) From d35dfacfb03d68a63cf9b0dbdfd782f43388bb6b Mon Sep 17 00:00:00 2001 From: Kyle Bittinger Date: Fri, 6 Mar 2026 09:38:03 -0500 Subject: [PATCH 6/6] Update version of upload-artifact in workflow --- .github/workflows/test-coverage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 2c5bb50..f190d51 100755 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -44,7 +44,7 @@ jobs: - name: Upload test results if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-test-failures path: ${{ runner.temp }}/package