Calvagone / campsis

A generic PK/PD simulation platform based on rxode2 and mrgsolve engines.
https://calvagone.github.io/
GNU General Public License v3.0
8 stars 3 forks source link

Easy management of scenarios #47

Closed luyckxn closed 3 years ago

luyckxn commented 3 years ago

Add a argument 'scenarios' to the simulate method.

Write scenarios as you write CAMPSIS events.

Writing a scenario could be achieved as follows: Scenario(name (optional), model, dataset)

Argument model could be a CAMPSIS model or a function/lambda formula to apply on the original model. Argument dataset could be a CAMPSIS dataset or a function/lambda formula to apply on the original dataset

Thanks to the new generic functions find(), contains(), delete() and replace(), updating a model/dataset is easy.

Example 1: test several values of THETA KA:

scenarios <- Scenarios() %>%
   add(Scenario()))) %>% # Original model and dataset
   add(Scenario(model=~.x %>% replace(Theta("KA", value=X)))) %>%
   add(Scenario(model=~.x %>% replace(Theta("KA", value=Y)))) %>%
   add(Scenario(model=~.x %>% replace(Theta("KA", value=Z))))

Example 2: test different distributions for covariate WT:

scenarios <- Scenarios() %>% 
   add(Scenario(dataset=~.x %>% replace(Covariate("WT", 70))))
   add(Scenario(dataset=~.x %>% replace(Covariate("WT", NormalDistribution(mean, sd))))) %>%
   add(Scenario(dataset=~.x %>% replace(Covariate("WT", UniformDistribution(min, max))))

I think this is an elegant solution as many elements of the model and the dataset can already be retrieved/adapted at this stage.