Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M3 method #163

Open
pchelle opened this issue Oct 20, 2022 · 4 comments
Open

M3 method #163

pchelle opened this issue Oct 20, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@pchelle
Copy link

pchelle commented Oct 20, 2022

I wanted to perform some Bayesian estimation that included BLQ data and tried to implement the M3 method for this.

The following tweak seems to work, but it may be better if it can be implemented in a cleaner way within the package (through fixing issue #107 maybe).

  • Within my dataset, I have set DV<0 as BLQ flag so that the ofv_kang function could directly understand BLQs are directly the negative values of the obs variable.

I also kept BLQ and LLOQ columns for the .cpp model

  • Then, within my .cpp model, I have used the following code chunks to implement the method
$PLUGIN Rcpp

$PARAM @annotated
SIGMA_PROP : xx
SIGMA_ADD : yy
LLOQ: zz
BLQ: 0

$SIGMA
xx yy

$TABLE 
// Usual calculation for observed values
double CP = (CENTRAL / V1) ;
double DV = CP * (1 + EPS(1)) + EPS(2); 

// M3 Method for BLQs leveraging Rcpp plugin
double CP_SD = sqrt(SIGMA_ADD + CP*CP*SIGMA_PROP); 
double DV_BLQ = R::pnorm(LLOQ, CP, CP_SD, 1, 0);

if(BLQ>0){DV = DV_BLQ;}
  • Then, I have updated the ofv_kang function to use negative obs as directly likelihood values
ofv_kang <- function(obs, pred, eta, var, omega_inv){
eta <- unlist(eta)
sum(log(var[obs>=0]) + (obs[obs>=0] - pred[obs>=0])^2/var[obs>=0]) - 
sum(2*log(pred[obs<0])) + 
diag(matrix(eta, nrow = 1) %*% omega_inv %*% matrix(eta, ncol = 1))
}
@pchelle
Copy link
Author

pchelle commented Oct 20, 2022

FYI: I have tested the method for a dataset that included 1343 subjects / 5447 observations including 436 BLQs

26% of the subjects included at least a BLQ value

I compared the results against the Nonmem version of the PopPK model.
Turns out Performance was excellent in 99% of cases and Acceptable in the remaining 1%

@FelicienLL
Copy link
Owner

Hello @pchelle ,
Thanks for your interest in mapbayr. Yes, I'm totally in favour of implementing the M3 method inside the package, and thanks for coming with the bit of code. It will be a pleasure to have a look into it and give it a try. It is great that you already validated it against NONMEM too.
In order to facilitate the implementation, could I ask you to set up a small test please? With a minimal model and one patient with BLQ and non-BLQ values, so that I make sure that we obtain the same results with your trick on the one hand, and my attempts to implement it on the other hand? This would really be helpful to me.
Many thanks in advance
Félicien

@pchelle
Copy link
Author

pchelle commented Oct 20, 2022

M3-test.zip

@FelicienLL
Copy link
Owner

Hi @pchelle, I opened a pull request based on your solution. You don't even have to modify the model code now, all is internal as long as BLQ and LLOQ are in the dataset. If you want to re-run the estimations on your clinical data from this new branch, we would make sure everything is perfect, that would be amazing. Otherwise I plan to add a LLOQ argument to mapbayest() so that the users do not have to manually change the dataset and everything. The release may take some time however.
I want to thank you again for this valuable contribution, if you have any other suggestion that could make life easier about dealing with LLOQ/BLQ data (or something else), please do not hesitate.
Félicien

@FelicienLL FelicienLL added the enhancement New feature or request label Oct 20, 2022
@FelicienLL FelicienLL linked a pull request Oct 20, 2022 that will close this issue
@FelicienLL FelicienLL removed a link to a pull request Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants