diff --git a/vignettes/articles/handling_LOQ.Rmd b/vignettes/articles/handling_LOQ.Rmd index dabd5e2..4bd258a 100644 --- a/vignettes/articles/handling_LOQ.Rmd +++ b/vignettes/articles/handling_LOQ.Rmd @@ -41,15 +41,17 @@ knitr::opts_chunk$set( run_optimizations <- FALSE ``` -```{r libs} -library(PopED) -packageVersion("PopED") -``` + # Define a model Here we define, as an example, a one-compartment pharmacokinetic model with linear absorption (analytic solution) in PopED [@Nyberg2012a]. +```{r libs} +library(PopED) +packageVersion("PopED") +``` + ```{r} ff <- function(model_switch,xt,parameters,poped.db){ with(as.list(parameters),{ @@ -73,9 +75,7 @@ We will use an additive and proportional residual unexplained variability (RUV) # Define an initial design and design space -Now we define the model parameter values, the initial design and design space for optimization. - -We define model parameters similar to the Warfarin example from the software comparison in @nyberg2015 and an arbitrary design of two groups of 20 individuals. +Now we define the model parameter values, the initial design and design space for optimization. We define model parameters similar to the Warfarin example from the software comparison in @nyberg2015 and an arbitrary design of one group of 32 individuals. ```{r} poped_db <- @@ -99,7 +99,7 @@ poped_db <- # Simulation -First it may make sense to check your model and design to make sure you get what you expect when simulating data. Here we plot the model typical values for the two groups: +First it may make sense to check the model and design to make sure we get what we expect when simulating data. Here we plot the model typical value and a 95% prediction interval (PI) for the intial design: ```{r simulate_without_BSV} plot_model_prediction(poped_db, model_num_points = 500,facet_scales = "free",PI=T) ``` @@ -107,15 +107,11 @@ plot_model_prediction(poped_db, model_num_points = 500,facet_scales = "free",PI= # Design evaluation Next, we evaluate the initial design. -```{r} +```{r,results='hide'} eval_full <- evaluate_design(poped_db) round(eval_full$rse) ``` - -We see that the relative standard error of the parameters (in percent) are relatively well estimated with this initial design except for the proportional RUV parameter (`sig_prop`). - - -```{r,echo=FALSE,eval=FALSE} +```{r,echo=FALSE} kable( data.frame("RSE"=round(eval_full$rse)), booktabs = TRUE#, @@ -123,6 +119,7 @@ kable( ) %>% kable_styling("striped",full_width = F) ``` +We see that the relative standard error of the parameters (in percent) are relatively well estimated with this initial design except for the between subject variability parameter for volume of distribution (`d_V`) and the proportional RUV parameter (`sig_prop`). # LOQ handling @@ -133,10 +130,19 @@ plot_model_prediction(poped_db, model_num_points = 500,facet_scales = "free",PI= geom_hline(yintercept = 2,color="red",linetype="dotted",linewidth=1) ``` +To evaluate the designs we use the design evaluation criteria based on the "integration and FIM scaling" method (`loq_method=1` which is the default) and the "omit observations where PRED% kable_styling("striped",full_width = F) ``` # Design optimization -We can then optimize the design using the different methods of computing the FIM. Here we optimize only using lower LOQ. +Next, we optimize the design using the different methods of computing the FIM. Here we optimize only using the lower LOQ. ```{r,eval=run_optimizations,results="hide"} optim_D6 <- poped_optim(poped_db, opt_xt = TRUE, parallel=T, @@ -268,10 +277,10 @@ optim_D2 <- readRDS(file = file.path("handling_LOQ_data","optim_D2.rds")) optim_full <- readRDS(file = file.path("handling_LOQ_data","optim_full.rds")) ``` -All designs together in one plot show how the different handling of BLQ data results in different optimal designs. -```{r,fig.cap="Design points for the apraoch ignoring LOQ, using the D2 method, and using the D6 method",echo=FALSE} +All designs points shown together in one plot to demonstrate how the different handling of BLQ data results in different optimal designs. The "full" design, ignoring LOQ, places a design point at the end of the sampling space, which will results in many observations below LOQ. Both the D2 and D6 methods push the design points to regions where fewer LOQ observations will occur. +```{r,echo=FALSE} p1 <- plot_model_prediction(optim_full$poped.db,sample.times = F,PI=T,PI_alpha = 0.1) -p1 <- p1 + geom_hline(yintercept = 2,color="red",linetype="dotted") +p1 <- p1 + geom_hline(yintercept = 2,color="red",linetype="dotted",linewidth=1) df_d2 <- model_prediction(optim_D2$poped.db) df_d2$Type="D2" @@ -293,7 +302,7 @@ p1 <- p1 + p1 ``` -Predictions using the D6 method from each of the optimizations shows the expected %RSE of the parameters if each design is used and the LOQ is at 2 concentration units. We see that D2 may be a reasonable strategy to optimize designs that are "good enough" if the D6 method is too slow for optimization. +To compare the effects of these different designs on parameter precision, we evaluate each of the optimal designs above using the D6 method. ```{r} optim_full_D6<- with(optim_full, evaluate_design(poped.db, @@ -309,15 +318,19 @@ optim_D6_D6<- with(optim_D6, ``` -```{r,echo=FALSE} +The expected %RSE of the parameters is shown below. We see that the D6 optimized design gives, on average, the best parameter precision. The D2 optimal design stragetgy may be a reasonable obtain designs that are "good enough" if the D6 method is too slow for optimization. +```{r,results='hide'} optim_rse_D6 <- tibble::tibble("Parameter"=names(eval_full$rse), "No LOQ"=round(optim_full_D6$rse), "D6"=round(optim_D6_D6$rse), "D2"=round(optim_D2_D6$rse)) +optim_rse_D6 +``` +```{r,echo=FALSE} knitr::kable( optim_rse_D6, booktabs = TRUE, - caption = 'RSE (in %) for the optimized designs evaluated using the D6 method.' + #caption = 'RSE (in %) for the optimized designs evaluated using the D6 method.' ) %>% kable_styling("striped",full_width = F) ```