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

Output keep dosing with evid=4 and reset seems to be missing some evid=1 with!is.na(amt) #732

Open
mattfidler opened this issue Jul 23, 2024 · 0 comments

Comments

@mattfidler
Copy link
Member

# This is an example to simulate and estimate dual first order
# and zero order absorption

library(nlmixr2)
#> Warning: package 'nlmixr2' was built under R version 4.3.3
#> Loading required package: nlmixr2data
#> Warning: package 'nlmixr2data' was built under R version 4.3.3
library(rxode2)
#> Warning: package 'rxode2' was built under R version 4.3.3
#> rxode2 2.1.3 using 4 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`
set.seed(123)
rxSetSeed(123)

# Setup the rxode2 event table
eventTable <- et(amt=320, evid=1, cmt=1, time = 0) %>% # nolint: object_name_linter.
   et(amt =  320, evid=1, cmt=2, time = 0) %>%
   et(list(c(0.1, 0.4), # sampling windows for first profile
        c(0.3, 0.9),
        c(0.7, 1.5),
        c(1.5, 2.5),
        c(2.5, 4),
        c(4, 6),
        c(6, 8.5),
        c(8.75, 10),
        c( 10, 12),
        c(23, 27))) %>%
    et(amt=320, evid=4, time=72, cmt=1) %>% # reset & dose
    et(amt=320, evid=1, time=72, cmt=2) %>% # dose afterward
    et(list(c(72.1, 72.4),
        c(72.3, 72.9),
        c(72.7, 73.5),
        c(73.5, 74.5),
        c(74.5, 78.5),
        c(76, 78),
        c(78, 80.5),
        c(80.75, 82),
        c(82, 84),
        c(95, 100))) %>%
    et(id=1:14) # Number of subjects to sample


# Now define the nlmixr2/rxode2 model used for both estimation and simulation
mod <- function() {
  # Parameters
   ini({
    tka <- 0.45; label("Ka (first order absorption)")
    trate <- 0.4 ; label("Zero order rate")
    tcl <- 1; label("Cl")
    tv <- 3.45; label("V")
    fDepot <- logit(0.5) ; label("amount of dose in first order absorption")
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    add.sd <- 0.7
  })
  # and a model block with the error specification and model specification
  model({
    ka <- exp(tka + eta.ka)
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    d/dt(depot) = -ka * depot
    d/dt(center) = ka * depot - cl / v * center

    f(depot) <- expit(fDepot)
    f(center) <- 1-expit(fDepot)
    rate(center) <- exp(trate)

    cp = center / v
    cp ~ add(add.sd)
  })
}

mod <- mod()

# Simulate the data
d <- nlmixr2(mod, eventTable, "rxSolve", control = rxControl(addDosing = TRUE))

d %>%
filter(evid==1)
#> Error: object 'evid' not found

Created on 2024-07-22 with reprex v2.1.0

@mattfidler mattfidler changed the title Output keep dosing with evid=4 and reset seems to be giving some wrong values Output keep dosing with evid=4 and reset seems to be missing some evid=1 with`!is.na(amt Jul 23, 2024
@mattfidler mattfidler changed the title Output keep dosing with evid=4 and reset seems to be missing some evid=1 with`!is.na(amt Output keep dosing with evid=4 and reset seems to be missing some evid=1 with!is.na(amt) Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant