Skip to content

Commit

Permalink
Updating missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
gowerc committed Oct 7, 2024
1 parent ae2860a commit 1037961
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tests/testthat/test-mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ compute_n_params <- function(cov_struct, nv) {
"adh" = 2 * nv - 1,
"ar1" = 2,
"ar1h" = nv + 1,
"cs" = nv + 1,
"cs" = 2,
"csh" = nv + 1,
"toep" = nv,
"toeph" = 2* nv - 1,
"toeph" = 2 * nv - 1,
"us" = nv * (nv + 1) / 2
)
return(n_params)
Expand All @@ -31,13 +31,6 @@ is.formula <- function(x) {

expect_valid_fit_object <- function(fit, cov_struct, nv, same_cov) {

n_params <- compute_n_params(cov_struct, nv)

if (!same_cov) {
n_params <- 2 * n_params
}


expect_type(fit, "list")
expect_length(fit, 3)

Expand Down Expand Up @@ -254,11 +247,13 @@ test_that("MMRM model fit has expected output structure",{
fit <- do.call(fit_mmrm, args = args)
expect_valid_fit_object(fit, struct, 3, TRUE)


mod <- mmrm::mmrm(
formula = as.formula(sprintf("outcome ~ sex + age + visit * group + %s(visit | id)", struct)),
data = dat,
reml = TRUE
)
expect_equal(length(mod$theta_est), compute_n_params(struct, 3))
expect_equal(fit$beta, coef(mod), ignore_attr = TRUE)
expect_equal(fit$sigma[[1]], VarCorr(mod), ignore_attr = TRUE)

Expand All @@ -274,6 +269,7 @@ test_that("MMRM model fit has expected output structure",{
data = dat,
reml = TRUE
)
expect_equal(length(mod$theta_est), compute_n_params(struct, 3) * 2)
expect_equal(fit$beta, coef(mod), ignore_attr = TRUE)
expect_equal(fit$sigma, VarCorr(mod), ignore_attr = TRUE)
}
Expand Down

0 comments on commit 1037961

Please sign in to comment.