nlmixrdevelopment / nlmixr

nlmixr: an R package for population PKPD modeling
https://nlmixrdevelopment.github.io/nlmixr/
GNU General Public License v2.0
114 stars 45 forks source link

ERROR: matrix multiplication: problem with matrix inverse; suggest to use solve() instead #649

Open Danielsite opened 4 months ago

Danielsite commented 4 months ago

Hi Mattfidler,

I found this error when I deploy my R shiny app with shinyproxy. I was Ok when I run my app in local. Could you please help me with this issues?

image

mattfidler commented 3 months ago

Hi @Danielsite

There isn't enough information for me to help.

If this is in ShinyMixR, you can ask there.

Also @RichardHooijmaijers has alot of experience with Shiny and nlmixr2 he may be able to help or have seen this before.

https://github.com/RichardHooijmaijers/shinyMixR

Danielsite commented 3 months ago

Hi @RichardHooijmaijers @mattfidler,

When I used nlmixr2 version 2.0.9 I would not get this error (but the running time is too slow). However once I used the latest nlmixr2 (2.1.1), the error popped up. matrix multiplication: problem with matrix inverse; suggest to use solve() instead

I think the main reason is the BLAS system.

Below is my sessionInfo:

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0

Below is my Poppk model, I think the syntax should be ok. "model.2cpt.ode.lag <- function() { ini({ tka <- log(0.5) # log(ka) tcl <- log(25) # log(CL) tv2 <- log(500) # log(V2) tv3 <- log(1000) # log(V3) tq <- log(55) # log(Q) tlag <- log(0.5) tclwtbl <- log(2) tclsubtp <- log(1.8) tv2wtbl <- log(2) tv2subtp <- log(3) tv3alpbl <- log(0.6) eta.ka ~ 0.1 # IIV on ka eta.cl ~ 0.1 # IIV on CL eta.v2 ~ 0.1 # IIV on V2 eta.v3 ~ 0.1 # IIV on V3 eta.q ~ 0.1 # IIV on Q eta.tlag ~ 0.1 # IIV on lagtime prop.err <- 0.1

                         })
                         model({
                           ka <- exp(tka + eta.ka)
                           cl <- exp(tcl + eta.cl+ log(WTBL)*tclwtbl + tclsubtp * (2-SUBJTYP))
                           v2 <- exp(tv2 + eta.v2+ log(WTBL)*tv2wtbl + tv2subtp * (2-SUBJTYP))
                           v3 <- exp(tv3 + eta.v3+ log(ALPBL)*tv3alpbl)
                           q <- exp(tq + eta.q)
                           d/dt(depot) = -ka * depot
                           d/dt(center) = ka * depot - cl / v2 * center + q/v3 * periph - q/v2 * center
                           d/dt(periph) = q/v2 * center - q/v3 * periph
                           lag(center) = exp(tlag + eta.tlag)
                           cp = center / v2
                           cp ~ prop(prop.err)
                         })
                       }"

I would be appreciated if you can help me figure out the issue! Thank you!

mattfidler commented 3 months ago

Hi Danelle,

Thank you for providing the model. Unfortunately the model alone does not allow me to reproduce the issue.

Probably, the most robust way to reproduce something I can use is to use the reprex package:

https://reprex.tidyverse.org/

Once you have a way to reproduce the matrix multiplication issue, I could help more with this particular issue .