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

model piping: unfix parameter value #586

Closed dzianismr closed 2 years ago

dzianismr commented 2 years ago

Model piping is a really nice feature, however I have difficulties "unfixing" a parameter. Let me show with the example from the model piping vignette.

A reference model: fit <- nlmixr(one.compartment, theo_sd, est="focei", control=list(print=0), table=list(npde=TRUE, cwres=TRUE)) Fixing a parameter works just fine: one.ka.0.5 <- fit %>% ini(tka=fix(0.5)) %>% nlmixr(est="focei", control=list(print=0), table=list(cwres=TRUE, npde=TRUE))

Lets say now I try to refit the model including tka. I tried the following syntax: one.unfixed1 <- one.ka.0.5 %>% ini(tka=0.5) %>% nlmixr(est="focei", control=list(print=0), table=list(cwres=TRUE, npde=TRUE)) or one.unfixed2 <- one.ka.0.5 %>% ini(tka=c(0.1,0.5,2)) %>% nlmixr(est="focei", control=list(print=0), table=list(cwres=TRUE, npde=TRUE)) There was no error generated, but tka remained fixed.

Is there syntax to unfix a parameter?

dzianismr commented 2 years ago

Thanks @mattfidler for taking this up!

A related piping question (or may be a feature request). Is it possible to delete a line with model piping? To make in more clear below is an example:

ini({ tCL1 <- log(1) ... }) model({ tCL2 = tCL1 some used of CL1 & CL2 in ode definition ... }) at some point I would like to have an independent CL2. In the first step I will set initial estimate for tCL2: fit %>% ini(tCL2=log(2)) %>% ... but how to remove line tCL2 = tCL1 in the model definition?

mattfidler commented 2 years ago

Currently it ins't possible. Nor is it possible to add (most) lines. You can add model properties like f(cmt), but otherwise not right now.

dzianismr commented 2 years ago

Thanks @mattfidler for taking this up as well. Looking forward to nlmixr2!