mclements / rstpm2

An R package for generalised survival models
28 stars 11 forks source link

Error with predict and log-normal frailty models #7

Closed ellessenne closed 6 years ago

ellessenne commented 7 years ago

Hi, I just updated to the new version released on CRAN and I cannot get predict to work when including a log-normal frailty in the model. Using the kidney data as an example:

library(rstpm2)
data(kidney)

A Gamma frailty model works fine:

fitg = stpm2(Surv(time, status) ~ age + sex, cluster = kidney$id, data = kidney, 
  RandDist = "Gamma")
invisible(predict(fitg))

Conversely, using a log-normal frailty:

fitln = stpm2(Surv(time, status) ~ age + sex, cluster = kidney$id, data = kidney, 
  RandDist = "LogN")
invisible(predict(fitln))
#> Error: $ operator is invalid for atomic vectors

With the previous version on CRAN the same code runs fine and predict works as expected. Is there any underlying change I am missing, or any idea on how to fix this?

My R session info:

sessionInfo()
#> R version 3.4.1 (2017-06-30)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: OS X El Capitan 10.11.6
#> 
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] splines   stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#> [1] rstpm2_1.4.0    survival_2.41-3
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_0.12.12      lattice_0.20-35   digest_0.6.12    
#>  [4] rprojroot_1.2     grid_3.4.1        nlme_3.1-131     
#>  [7] backports_1.1.0   stats4_3.4.1      formatR_1.5      
#> [10] magrittr_1.5      evaluate_0.10.1   stringi_1.1.5    
#> [13] Matrix_1.2-11     bbmle_1.0.19      rmarkdown_1.6    
#> [16] tools_3.4.1       stringr_1.2.0     numDeriv_2016.8-1
#> [19] yaml_2.1.14       compiler_3.4.1    mgcv_1.8-19      
#> [22] htmltools_0.3.6   fastGHQuad_0.2    knitr_1.17

Thanks! Best wishes,

Alessandro

mclements commented 7 years ago

Alessandro,

Good catch. I have now corrected this in the master and develop branches on GitHub.

I would prefer to wait for a week for any further bug reports before pushing to CRAN.

Sincerely, Mark.

On 09/01/2017 01:20 PM, Alessandro Gasparini wrote:

Hi, I just updated to the new version released on CRAN and I cannot get predict to work when including a log-normal frailty in the model. Using the kidney data as an example:

library(rstpm2) data(kidney)

A Gamma frailty model works fine:

fitg = stpm2(Surv(time, status) ~ age + sex, cluster = kidney$id, data = kidney, RandDist = "Gamma") invisible(predict(fitg))

Conversely, using a log-normal frailty:

fitln = stpm2(Surv(time, status) ~ age + sex, cluster = kidney$id, data = kidney, RandDist = "LogN") invisible(predict(fitln))

> Error: $ operator is invalid for atomic vectors

With the previous version on CRAN the same code runs fine and predict works as expected. Is there any underlying change I am missing, or any idea on how to fix this?

My R session info:

sessionInfo()

> R version 3.4.1 (2017-06-30)

> Platform: x86_64-apple-darwin15.6.0 (64-bit)

> Running under: OS X El Capitan 10.11.6

>

> Matrix products: default

> BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib

> LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

>

> locale:

> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

>

> attached base packages:

> [1] splines stats graphics grDevices utils datasets methods

> [8] base

>

> other attached packages:

> [1] rstpm2_1.4.0 survival_2.41-3

>

> loaded via a namespace (and not attached):

> [1] Rcpp_0.12.12 lattice_0.20-35 digest_0.6.12

> [4] rprojroot_1.2 grid_3.4.1 nlme_3.1-131

> [7] backports_1.1.0 stats4_3.4.1 formatR_1.5

> [10] magrittr_1.5 evaluate_0.10.1 stringi_1.1.5

> [13] Matrix_1.2-11 bbmle_1.0.19 rmarkdown_1.6

> [16] tools_3.4.1 stringr_1.2.0 numDeriv_2016.8-1

> [19] yaml_2.1.14 compiler_3.4.1 mgcv_1.8-19

> [22] htmltools_0.3.6 fastGHQuad_0.2 knitr_1.17

Thanks! Best wishes,

Alessandro

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/mclements/rstpm2/issues/7, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAiBCfqIopP0XwivU53s81pPkAbTxAtpks5sd-iGgaJpZM4PKBpH.

ellessenne commented 7 years ago

Thank you Mark! No problem, it makes sense to wait for other bug reports before pushing to CRAN. Best wishes,

Alessandro

mclements commented 6 years ago

Alessandro,

I have now pushed a bug fix to CRAN (version 1.4.1). Does this address your issue?

Thanks again for the bug report.

Kindly, Mark.

ellessenne commented 6 years ago

Hello Mark, Thanks for the update, it seems to be working fine now! Best wishes,

Alessandro