Skip to content

Commit

Permalink
Fix 349 again
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Sep 15, 2024
1 parent ff9c6d3 commit bf683a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
20 changes: 16 additions & 4 deletions R/rxsolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,10 @@ rxSolve.default <- function(object, params = NULL, events = NULL, inits = NULL,
.minfo(paste0("omega has too many items, ignored: '", paste(.ignore, collapse="', '"), "'"))
}
.ctl$omega <-.ctl$omega[.w, .w, drop=FALSE]
if (dim(.ctl$omega)[1] == 0) .ctl$omega <- NULL
if (dim(.ctl$omega)[1] == 0) {
.ctl$omega <- NULL
.ctl <- do.call(rxControl, .ctl)
}
.names <- c(.names, .col[.w])
} else if ( inherits(.ctl$omega, "character")) {
.extraNames <- c(.extraNames, .ctl$omega)
Expand All @@ -1798,7 +1801,10 @@ rxSolve.default <- function(object, params = NULL, events = NULL, inits = NULL,
.minfo(paste0("sigma has too many items, ignored: '", paste(.ignore, collapse="', '"), "'"))
}
.ctl$sigma <-.ctl$sigma[.w, .w, drop=FALSE]
if (dim(.ctl$sigma)[1] == 0) .ctl$sigma <- NULL
if (dim(.ctl$sigma)[1] == 0) {
.ctl$sigma <- NULL
.ctl <- do.call(rxControl, .ctl)
}
.names <- c(.names, .col[.w])
} else if ( inherits(.ctl$sigma, "character")) {
.extraNames <- c(.extraNames, .ctl$sigma)
Expand All @@ -1821,7 +1827,10 @@ rxSolve.default <- function(object, params = NULL, events = NULL, inits = NULL,
.minfo(paste0("thetaMat has too many items, ignored: '", paste(.ignore, collapse="', '"), "'"))
}
.ctl$thetaMat <-.ctl$thetaMat[.w, .w, drop=FALSE]
if (dim(.ctl$thetaMat)[1] == 0) .ctl$thetaMat <- NULL
if (dim(.ctl$thetaMat)[1] == 0) {
.ctl$thetaMat <- NULL
.ctl <- do.call(rxControl, .ctl)
}
.names <- c(.names, .col[.w])

# now look for zero diagonals
Expand All @@ -1831,7 +1840,10 @@ rxSolve.default <- function(object, params = NULL, events = NULL, inits = NULL,
if (length(.w) > 0) {
.minfo(paste0("thetaMat has zero diagonal items, ignored: '", paste(.col[.w], collapse="', '"), "'"))
.ctl$thetaMat <-.ctl$thetaMat[-.w, -.w, drop=FALSE]
if (dim(.ctl$thetaMat)[1] == 0) .ctl$thetaMat <- NULL
if (dim(.ctl$thetaMat)[1] == 0) {
.ctl$thetaMat <- NULL
.ctl <- do.call(rxControl, .ctl)
}
.names <- c(.names, .col[-.w])
}
}
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-rxode-issue-349.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
rxTest({
test_that("Zero variances; RxODE#299", {

mod <- rxode2({
eff(0) <- 1
C2 <- centr / V2
C3 <- peri / V3
CL <- TCl * exp(eta.Cl) ## This is coded as a variable in the model
d / dt(depot) <- -KA * depot
d / dt(centr) <- KA * depot - CL * C2 - Q * C2 + Q * C3
d / dt(peri) <- Q * C2 - Q * C3
d / dt(eff) <- Kin - Kout * (1 - C2 / (EC50 + C2)) * eff
d/dt(depot) <- -KA * depot
d/dt(centr) <- KA * depot - CL * C2 - Q * C2 + Q * C3
d/dt(peri) <- Q * C2 - Q * C3
d/dt(eff) <- Kin - Kout * (1 - C2 / (EC50 + C2)) * eff
e <- eff + eff.err
cp <- centr * (1 + cp.err)
})
Expand Down

0 comments on commit bf683a0

Please sign in to comment.