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: What is the best way to extract the original model function? #525

Closed billdenney closed 3 years ago

billdenney commented 3 years ago

When reporting, I want to provide a listing of the model used. For that, I would prefer to extract the model function from the model (rather than tracking which model function goes with which fit manually). The best way that I found to get the character listing of the model is below. Is there a better way?

# best_model_vehicle is the model that I fit
cat(as.character(attr(best_model_vehicle$uif$model, "srcref")), sep="\n")
mattfidler commented 3 years ago

Currently the full model function is not stored in the nlmixr fit object;

There is a reporting function that does something similar nmLst and nmDocx, I cannot recall how I handle it there.

mattfidler commented 3 years ago

One note, the code you are using requires keep.source is true. Therefore this solution doesn't work with batch mode

mattfidler commented 3 years ago

Hopefully this is good enough for now