stulacy / multistateutils

Utility funtions for parametric multi-state modelling in R
GNU General Public License v3.0
6 stars 2 forks source link

Example script crashes R on macOS High Sierra #5

Closed jenniferthompson closed 6 years ago

jenniferthompson commented 6 years ago

I'm on macOS 10.13.6 (High Sierra), running the code in the example vignette, and have consistently had R crash at the point in the vignette when predict_transitions() is first called. (Will include session info below.) I'm using the CRAN version of multistateutils - happy to try the development version if that would help, or stick to CRAN to help debug.

flexsurv::pmatrix.simfs() does work and gives the expected results per the vignette.

[run code in Example vignette up to this point]

> predict_transitions(models, newdata, tmat, times=365)

 *** caught illegal operation ***
address 0x10afd1a10, cause 'illegal opcode'

Traceback:
 1: desCpp(transitions, trans_mat, newdata_mat, start_times, start_states -     1, tcovs)
 2: data.table::as.data.table(desCpp(transitions, trans_mat, newdata_mat,     start_times, start_states - 1, tcovs))
 3: run_sim(transition_list, attr_mat, trans_mat, tcovs, start_times,     start_states)
 4: state_occupancy(models, trans_mat, newdata_ext, tcovs, initial_times,     start_states, ci, M, agelimit, agecol, agescale)
 5: predict_transitions(models, newdata, tmat, times = 365)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 

Session info:

> devtools::session_info()
Session info ----------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.0 (2018-04-23)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.1.453)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Chicago             
 date     2018-08-29                  

Packages --------------------------------------------------------------------------
 package         * version date       source         
 base            * 3.5.0   2018-04-24 local          
 compiler          3.5.0   2018-04-24 local          
 data.table        1.11.4  2018-05-27 CRAN (R 3.5.0) 
 datasets        * 3.5.0   2018-04-24 local          
 deSolve           1.21    2018-05-09 CRAN (R 3.5.0) 
 devtools          1.13.6  2018-06-27 CRAN (R 3.5.0) 
 digest            0.6.15  2018-01-28 CRAN (R 3.5.0) 
 flexsurv        * 1.1     2017-03-27 CRAN (R 3.5.0) 
 graphics        * 3.5.0   2018-04-24 local          
 grDevices       * 3.5.0   2018-04-24 local          
 grid              3.5.0   2018-04-24 local          
 lattice           0.20-35 2017-03-25 CRAN (R 3.5.0) 
 magrittr          1.5     2014-11-22 CRAN (R 3.5.0) 
 Matrix            1.2-14  2018-04-13 CRAN (R 3.5.0) 
 memoise           1.1.0   2017-04-21 CRAN (R 3.5.0) 
 methods         * 3.5.0   2018-04-24 local          
 mstate          * 0.2.11  2018-04-09 CRAN (R 3.5.0) 
 muhaz             1.2.6   2014-08-09 CRAN (R 3.5.0) 
 multistateutils * 1.2.0   2018-07-21 CRAN (R 3.5.0) 
 mvtnorm           1.0-8   2018-05-31 CRAN (R 3.5.0) 
 quadprog          1.5-5   2013-04-17 CRAN (R 3.5.0) 
 RColorBrewer      1.1-2   2014-12-07 CRAN (R 3.5.0) 
 Rcpp              0.12.18 2018-07-23 cran (@0.12.18)
 splines           3.5.0   2018-04-24 local          
 stats           * 3.5.0   2018-04-24 local          
 survival        * 2.41-3  2017-04-04 CRAN (R 3.5.0) 
 tools             3.5.0   2018-04-24 local          
 utils           * 3.5.0   2018-04-24 local          
 withr             2.1.2   2018-03-15 CRAN (R 3.5.0) 
 yaml              2.1.19  2018-05-01 CRAN (R 3.5.0) 
jenniferthompson commented 6 years ago

Gist of exact code I've been using (copied from vignette)

This works fine for me on Ubuntu 16.04.5, matching another reviewer's experience.

stulacy commented 6 years ago

Hmm that's odd. I'll have a quick look at that as it worked fine on the Mac check on CRAN

jenniferthompson commented 6 years ago

Let me know if I can help with detective work! It seemed to install fine on my machine, though I just reinstalled and noticed this warning:

clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2 -c simulation.cpp -o simulation.o
simulation.cpp:30:35: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
            nstate.add_transition(std::move(Transition::create_transition(trans_name, dest, as<List>(this_trans["coefs"]), tcovs)));
                                  ^
simulation.cpp:30:35: note: remove std::move call here
            nstate.add_transition(std::move(Transition::create_transition(trans_name, dest, as<List>(this_trans["coefs"]), tcovs)));
                                  ^~~~~~~~~~                                                                                     ~
1 warning generated.
stulacy commented 6 years ago

Can you try reinstalling from the CRAN development branch and see if that fixes it? If not, try reinstalling the data.table package as that could be partly causing it.

jenniferthompson commented 6 years ago

Installing the development branch seems to have done it! All the multistateutils functions in the Examples document run on my machine now. 🎉