nanhung / pksensi

An R package for applying global sensitivity analysis in physiologically based kinetic modeling
https://nanhung.github.io/pksensi/
GNU Lesser General Public License v3.0
5 stars 3 forks source link

missing values and NaN #6

Closed Kokomole closed 3 years ago

Kokomole commented 3 years ago

Dear Nan-Hung,

I tried to use pksensi for sensitivity analysis for two parameters in my model but a strange error occurred.

Here is my code:

TMDDQE <- function(t, state, parameters) {
  with(as.list(c(state, parameters)), {
    ksyn = 0.438*0.235 
    Ctotal = Drug/2.77
    Cub = 0.5*((Ctotal-Receptor-KD)+sqrt((Ctotal-Receptor-KD)^2+4*KD*Ctotal))
    Aub = Cub*2.77
    Conc = Drug / 2.77
    dAbsorption = - 0.152/24*Absorption
    dDrug = 0.152/24*Absorption - 0.775/24/2.77*Aub - kint*(Drug-Aub)
    dReceptor = ksyn - 0.235*Receptor - (kint-0.235)*(Ctotal-Cub);
    list(c(dAbsorption, dDrug, dReceptor),
         "Conc" = Conc)
  })
}

initState <- c(Absorption = 500, Drug = 0, Receptor = 0.438)

params <- c("kint", "KD")
q <- c("qunif", "qunif")
q.arg <- list(list(min = 0.03 * 0.75, max = 0.03 * 2),
              list(min = 0.18 * 0.75, max = 0.18 * 2))

t <- seq(from = 0, to = 700, by = 10)

set.seed(1234)
x <- rfast99(params, q = q, q.arg = q.arg, n = 200, rep = 5)

outputs <- c("Conc")
out1 <- solve_fun(x, time = t, func = TMDDQE, initState = initState, outnames = outputs)

The error is :

Starting time: 2021-02-08 16:21:32
Error in quantile.default(newX[, i], ...) : 
  missing values and NaN's not allowed if 'na.rm' is FALSE

Could you find out the reason and solve the problem?

Many thanks, Min Zhu

Kokomole commented 3 years ago

Dear Nan-Hung,

I setted replicate as 1 and the error disappeared. You can delete the issue. Thank you.

nanhung commented 3 years ago

Thanks for report this issue. The error message occurs when the NA generate in the output. The current solution is to modify the parameter range or revise the set.seed(). Setting the replication to 1 is one of the solutions, but you will not able to check the convergence.