nlmixrdevelopment / nlmixr

nlmixr: an R package for population PKPD modeling
https://nlmixrdevelopment.github.io/nlmixr/
GNU General Public License v2.0
114 stars 45 forks source link

Question about #84 Simulating models with uncertainty that have covariates  #619

Open Chickenlover0908 opened 1 year ago

Chickenlover0908 commented 1 year ago

Hello, nlmixr team, thank you for solved my many questions before. I have fitted my model after your help, and have known more about this great package. Now I am simulating different dose with my model, but i have included one covariate “AGE”, which increase the difficulty of dose simulation. #84 has given a good method, but when I use “rxSolve”, there is one error --Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column. I did not know how to solve the error, i need your help. Here is my syntax, I have tried two form:

sim.day4 <- rxSolve(fit1801, events = day4ev_75ppm, nSub = 100, iCov = data.frame(AGE = 1))

Compiling model...done
Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

“fit1801” is my nlmixr fit result and my event table is below:

day4ev_75ppm <- eventTable(amount.units = "mg/L", time.units = "hours") %>%
  add.dosing(dose = 75, nbr.doses = 5, start.time = 0, dosing.interval = 24, 
             dosing.to = "depot", dur = 24) %>%
  add.sampling(96:120) 

And when i use your syntax, there still this error:

> fit1801 %>% 
>   et(amt=75,ii=5,until=96) %>% 
>   rxSolve(nSub=100, iCov=data.frame(AGE=1))
>             confint() %>%
>             plot() 
> Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

How can I solve this error? Thank you very much!!!!

mattfidler commented 1 year ago

I would add it to the events data frame directly.

I'm unsure if you are having an issue with the rxSolve(), confint() or plot() function.

Chickenlover0908 commented 1 year ago

Thank you, I have tried to add "age“ in event table, simulation works very smooth.

mattfidler commented 1 year ago

Great!