Closed billdenney closed 9 months ago
With a quick additional test, it seems like this only has an effect when nStud = 1
(the default) and not when nStud = 1000
.
d_sim$TRTG
will be modified since there are dosing records that will be inserted and interpolations that will be performed.
But there should be no effects on the source data.
library(rxode2)
#> rxode2 2.0.14.9000 using 8 threads (see ?getRxThreads)
#> no cache: create with `rxCreateCache()`
one.compartment <- function() {
ini({
tka <- 0.45; label("Ka")
tcl <- 1; label("Cl")
tv <- 3.45; label("V")
eta.ka ~ 0.6
eta.cl ~ 0.3
eta.v ~ 0.1
add.sd <- 0.7
})
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
cp = center / v
cp ~ add(add.sd)
})
}
d_sim <- nlmixr2data::theo_sd
d_sim$TRTG <- ordered(ifelse(nlmixr2data::theo_sd$WT < median(nlmixr2data::theo_sd$WT), "Low", "High"))
summary(d_sim$TRTG)
#> High Low
#> 84 60
fit <- rxSolve(one.compartment, d_sim, keep="TRTG")
summary(d_sim$TRTG)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.000 1.000 1.000 1.417 2.000 2.000
Created on 2023-12-04 with reprex v2.0.2
This is because your factor is an ordered factor. I'm unsure if I will allow them to be kept or not. I can't support every different type of data since it actually isn't kept and merged at the end.
We already tried an approach where we merged back the data and it didn't successfully run (I remember you tried it).
So currently in keep
:
Any sort of attributes will be dropped (maybe should have some sort of warning but would need to explicitly check for attributes).
Could additionally support ordered
factors
d_sim$TRTG
should not be modified, but in the first pass where it is part ofkeep
, it is. (My guess is that this will end up being an rxode2 issue, but I'm not sure exactly wherekeep
has its effects at the moment, and I want to put the reprex into the record.)Created on 2023-09-25 with reprex v2.0.2