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

Certain nlmixr fits crash the R session in current R-devel under Windows #596

Open
jranke opened this issue Mar 5, 2022 · 7 comments
Open

Comments

@jranke
Copy link
Contributor

jranke commented Mar 5, 2022

When I run the first example in the nlmixr help page:

  f_ode <- function(){
         ini({
             lCl <- 1.6      #log Cl (L/hr)
             lVc <- log(80)   #log Vc (L)
             lKA <- 0.3      #log Ka (1/hr)
             prop.err <- c(0, 0.2, 1)
             eta.Cl ~ 0.3 ## BSV Cl
             eta.Vc ~ 0.2 ## BSV Vc
             eta.KA ~ 0.1 ## BSV Ka
         })
         model({
             ## First parameters are defined in terms of the initial estimates
             ## parameter names.
             Cl <- exp(lCl + eta.Cl)
             Vc = exp(lVc + eta.Vc)
             KA <- exp(lKA + eta.KA)
             ## After the differential equations are defined
             kel <- Cl / Vc;
             d/dt(depot)    = -KA*depot;
             d/dt(centr)  =  KA*depot-kel*centr;
             ## And the concentration is then calculated
             cp = centr / Vc;
             ## Last, nlmixr is told that the plasma concentration follows
             ## a proportional error (estimated by the parameter prop.err)
             cp ~ prop(prop.err)
         })
     }
     
     # Use nlme algorithm
     fit_linCmt_nlme <- try(nlmixr(f_ode, Oral_1CPT, est="nlme",
                    control=nlmeControl(maxstepsOde = 50000, pnlsTol=0.4)))

My R session consistently crashes when using R-devel (r81847 ucrt) under Windows. The crash occurs after a couple of minutes on my system. When I turn off buffered output, I can see that the crash occurs after the message "calculating Jacobian".

I came across this problem trying to find out why my test setup script crashes Winbuilder for R-devel and rhub/r-devel-windows.

> sessionInfo()
R Under development (unstable) (2022-03-03 r81847 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
[1] LC_COLLATE=English_United Kingdom.utf8 
[2] LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] nlmixr_2.0.6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8          pillar_1.7.0        compiler_4.2.0     
 [4] PreciseSums_0.4     tools_4.2.0         sys_3.4            
 [7] qs_0.25.3           lattice_0.20-45     nlme_3.1-155       
[10] memoise_2.0.1       lifecycle_1.0.1     tibble_3.1.6       
[13] gtable_0.3.0        checkmate_2.0.0     pkgconfig_2.0.3    
[16] rlang_1.0.1         cli_3.2.0           parallel_4.2.0     
[19] fastmap_1.1.0       n1qn1_6.0.1-10      dplyr_1.0.8        
[22] generics_0.1.2      vctrs_0.3.8         grid_4.2.0         
[25] tidyselect_1.1.2    glue_1.6.2          RApiSerialize_0.1.0
[28] R6_2.5.1            fansi_1.0.2         ggplot2_3.3.5      
[31] purrr_0.3.4         magrittr_2.0.2      lbfgsb3c_2020-3.2  
[34] backports_1.4.1     scales_1.1.1        ellipsis_0.3.2     
[37] RxODE_1.1.4         colorspace_2.0-3    brew_1.0-7         
[40] utf8_1.2.2          stringfish_0.15.5   lotri_0.3.1        
[43] RcppParallel_5.1.5  munsell_0.5.0       cachem_1.0.6       
[46] crayon_1.5.0       
@mattfidler
Copy link
Contributor

Thank you for reporting this. We found a few memory issues that we have fixed and will be pushing in the new rxode2/nlmixr2. Unfortunately, windows is the most difficult platform to track down an issue like this.

@jranke
Copy link
Contributor Author

jranke commented Mar 6, 2022

OK, thanks for the feedback! nlmixr2 looks promising, so I will have a look. From the github README it really seems to be ready to use, can you give me a hint on the status?

@jranke
Copy link
Contributor Author

jranke commented Mar 6, 2022

On second thought, this really sounds like I should abandon my nlmixr backend for mkin, as I do not see how I could be able to push it to CRAN... Would you recommend that I switch to nlmixr2 already and wait with a CRAN release of the nlmixr(2) backend for nlmixr2 to be released to CRAN?

@mattfidler
Copy link
Contributor

I am hoping to release soon, as always it is up to you. I need to move vignettes around and put some assertions in as well as track down any bugs.

From a function point of view the code should be the same between nlmixr and nlmixr2 in most cases. The controls will be slightly different (ie foceiControl(), saemControl(), and nlmixControl()/nlmixrNlmeControl() have been aligned and now check to make sure that the right types of values are supplied.

@mattfidler
Copy link
Contributor

Also, it seems that nlme performs a little worse for the theo_sd dataset. For me, I am unsure if it is because of a rewritten nlme engine (I could have changed residual weights for normal/additive error)

@mattfidler
Copy link
Contributor

Since you are not calling the foceiControl and saemControl but using nlmixr_model it should work in both versions.

@jranke
Copy link
Contributor Author

jranke commented Mar 7, 2022

OK, thanks a lot for your feedback!

jranke added a commit to jranke/mkin that referenced this issue Mar 7, 2022
I am postponing my attempts to get the nlmixr interface to CRAN, given
some problems with nlmixr using R-devel under Windows, see
nlmixrdevelopment/nlmixr#596
and
r-hub/rhub#512,
which is fixed by the removal of nlmixr from the testsuite.

For the tests to be more platform independent, the biphasic mixed
effects models test dataset was defined in a way that fitting
should be more robust (less ill-defined).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants