FelicienLL / mapbayr

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

extract the data generated by plot.mapbayests(my_est(), delta = .1) #220

Open ZG-W opened 1 month ago

ZG-W commented 1 month ago

Hi @FelicienLL, nice work!

I am using the default plot.mapbayests() function to plot the predicted conc vs time profile. I wonder if there is a way to extract the dataset generated by _plot.mapbayests(myest(), delta = .1). With that dataset available, we can have more flexibility for graphical visualization of the model predictions.

A bit more background why I am asking this: my model has two types of DVs and is incorporated as PAR and MET under the current nomenclaturent of mapbayr. The PAR was on normal scale while MET was ln-transformed both side. With the default plot.mapbayests() function, the MET profile was ln-transformed, and I can't transform the MET value back to its original scale.

Many thanks for your help! Zhigang

FelicienLL commented 1 month ago

Hello, plot() calls augment() to make predictions. augment() adds an $aug_tab (ie basically the table of predictions) to your mapbayest object. That you can extract. Hope it helps! Félicien

FelicienLL commented 1 month ago

Of note, I have not tested it, but I am pretty convinced that mapbayr cannot support the estimation from PAR in the normal scale and MET in the log scale. It should be one or another. If so, your parameter estimates might be wrong.

ZG-W commented 1 month ago

Hi @FelicienLL, thank you for your kind response. The _as.data.frame(augment(myest()) returned the same table as using _as.data.frame(myest()). The problem is that the exported table only has time points with a dosing/observation event. How can we extract the full dataset used for plot(), which has the IPRED and PRED continuously over time with a time delta of 0.1?

You are right about the ln-transformation. I switched to the method of using exponential ETA instead of ln-transform the data.

Many thanks, Zhigang

FelicienLL commented 1 month ago

Sorry to be unclear. You can try the following:

x <- augment(x) # x= result of mapbayest()
x$aug_tab