FelicienLL / mapbayr

Easy Maximum A Posteriori Bayesian Estimation of PK parameters in R.
21 stars 2 forks source link

Providing two or more concentration for BF #216

Open yahoff opened 10 months ago

yahoff commented 10 months ago

I am using mapbayr to perform Bayesian forecasting with a Shiny application. The user imputes a time point with a concentration, and provides a time point for which IPRED is calculated. Now I would like to allow, to provide more than one historical trough concentration. However, when I implement this, it does not work anymore. I sticked to the code provided here. In this example, two concentration were provided to predict subsequent concentration.

My code looks like this: UI:

h6("Historical Exposure"),

                    fluidRow(
                              column(width = 6, HTML("<strong>Time [POD]</strong>")),
                              column(width = 6, HTML("<strong>Exposure [ng/ml]</strong>")),
                              # Add more columns as needed for additional doses
                    ),
                    fluidRow(

                              column(width = 6, numericInput("timepoint1", "", value = 2), step = 0.5),
                              column(width = 6, numericInput("timepoint_exposure1", "", value = 5, step = 0.1))
                    ),
                    fluidRow(

                              column(width = 6, numericInput("timepoint2", "", value = 3), step = 0.5),
                              column(width = 6, numericInput("timepoint_exposure2", "", value = 6.2, step = 0.1))
                    )

                    ,
                    fluidRow(

                              column(width = 6, numericInput("timepoint3", "", value = 4), step = 0.5),
                              column(width = 6, numericInput("timepoint_exposure3", "", value = 6.9, step = 0.1))
                    )

                    ,

                    h6("To Predict"),
                    fluidRow(

                              column(width = 6, numericInput("timepoint4", "", value = 5, step = 0.5)),

                    )

Server:

my_model <- adm_rows(time = 0, cmt = 1, amt = input$amt*1000, ii = input$ii, addl = input$addl) %>%

                              obs_lines(time = (input$timepoint1), DV = input$timepoint_exposure1) %>%
                              obs_lines(time = (input$timepoint2), DV = input$timepoint_exposure2) %>%
                              obs_lines(time = (input$timepoint3), DV = input$timepoint_exposure3) %>%

                              obs_lines(time = (input$timepoint4), DV = NA_real_, mdv = 1) %>%
                              add_covariates(covariates = list_cov) %>%
                              get_data()

The output is a table for time 0, time 2, and time 3. I don't quite understand why the output for time 4 (the requested prediction) is not shown. Apparently I miss something. As mentioned above, the code works when I run the calculation for providing one concentration, but when I include more, it doesn't work anymore.

Has someone a suggestion to improve the code?

Kind regards, Yannick

FelicienLL commented 8 months ago

Hi Yannick, First of all sorry for the delay on this. Did you try to set up the creation of your dataset outside of the Shiny app? This would be easier for you to understand what is working and what is not. But in your code I can see you do not define a compartment for observations, and you apply get_data() in the end. Did you miss to start the pipe chain with the model? Best regards