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

Feature/survival #323

Open
wants to merge 250 commits into
base: master
Choose a base branch
from
Open

Feature/survival #323

wants to merge 250 commits into from

Conversation

sambrilleman
Copy link
Collaborator

I think this is pretty much ready for a pull request.

R CMD check seems to passing without any obvious issues.

I've added the splines2 package to Imports, and the simsurv package to Suggests. I've commented out some stan_surv testthat tests to avoid adding more packages to Suggests.

There is quite a bit of overlap with stan_jm stuff, but I got into a mess trying to refactor all the stan_jm code, so for now they mostly use different workhorse and helper functions. One day I will try and refactor some of the stan_jm code to use more of the stan_surv helpers, since the stan_surv code is much neater I think.

I've not packaged surv.stan code into \#include statements since the code doesn't really overlap with other stan files. But I could do so if need be.

For stansurv objects, this allows plotfun to be a plot of the baseline hazard vs time (the default), or time-dependent hazard ratio(s) vs time, or otherwise plot.stanreg is called.
sambrilleman and others added 20 commits October 30, 2023 23:37
splines2 v0.5.0 made a breaking change, and the class was renamed from iSpline to ISpline, and the order of the class heirarchy was also changed. Same for their mSpline class, etc.
Copy behaviour from this commit 3c08d53
Bring feature/survival up to date with master
splines2 became stricter and raises an error for internal knots on the boundary. So instead of making the internal knot 5 (max event time), let's make it 4 in these tests.

Also a vector for qnodes makes no sense. So I'll remove this redundant test.
Same as #594. But must have missed the use of it in log_lik.R
@CWilhelm-Benartzi
Copy link

Dear all,
My compilation of the rstanarm survival extension fails:
I use the following code:

install.packages("rstanarm", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
devtools::install_github("stan-dev/rstanarm", ref = "feature/survival", build_vignettes = FALSE)

I am using R version 4.2 on a Windows 10 computer.
It runs until this point
:

C:/Users/wilhch00/AppData/Local/R/win-library/4.2/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits::type' {aka '__m128d'} [-Wignored-attributes]
"C:/PROGRA1/R/R-421.3/bin/x64/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/surv.stan

and then the error states that:

Error in rstan::stanc(file, allow_undefined = TRUE, obfuscate_model_name = FALSE) :
0
Semantic error in 'string', line 404, column 2 to line 411, column 3:
402: }
403:
404: vector quadrature_log_cdf(vector qwts, vector log_hazard, int qnodes, int N) {
^
405: int M = rows(log_hazard);
406: vector[M] hazard = exp(log_hazard);
Real return type required for probability functions ending in _log, _lpdf, _lupdf, _lpmf, _lupmf, _cdf, _lcdf, or _lccdf.
Calls: make_cc ->
Execution halted
make: *** [Makevars.win:28: stan_files/surv.cc] Error 1
rm stan_files/polr.cc stan_files/mvmer.cc stan_files/count.cc stan_files/lm.cc stan_files/jm.cc stan_files/bernoulli.cc stan_files/binomial.cc stan_files/continuous.cc
ERROR: compilation failed for package 'rstanarm'
removing 'C:/Users/wilhch00/AppData/Local/R/win-library/4.2/rstanarm'
restoring previous 'C:/Users/wilhch00/AppData/Local/R/win-library/4.2/rstanarm'
Warning messages:
1: In utils::untar(tarfile, ...) :
‘tar.exe -xf "C:\Users\wilhch00\AppData\Local\Temp\RtmpcphJws\file12c849956fc.tar.gz" -C "C:/Users/wilhch00/AppData/Local/Temp/RtmpcphJws/remotes12c83388f58"’ returned error code 1
2: In i.p(...) :
installation of package ‘C:/Users/wilhch00/AppData/Local/Temp/RtmpcphJws/file12c83b9a3c1e/rstanarm_2.26.1.tar.gz’ had non-zero exit status

I have tried to also download the survival extension and building the package from R studio as well.
But the same issue reoccurs.
Any help would be greatly appreciated
.
Charlotte

@andrjohns
Copy link
Contributor

@bgoodri and @jgabry would you be ok if I took the lead on getting this branch up-to-date and merged? There's a decent amount of demand for it, and it's something I could use for a project as well

@jgabry
Copy link
Member

jgabry commented Feb 9, 2024

That would be great! You could jump into the discussion in #570 to get the ball rolling if you want. Part of that discussion was about finding someone to do what you're proposing, so I'm guessing everyone would be in favor.

@CWilhelm-Benartzi
Copy link

Many thanks!

@sambrilleman
Copy link
Collaborator Author

That would be amazing if you had the time to do that @andrjohns! I'll post some thoughts in #570, since that seems to be where most of the discussion is happening.

@sambrilleman
Copy link
Collaborator Author

Looks like it no longer likes a function named _log_cdf returning a vector instead of a real. Maybe that is a recent change in Stan. Rather than changing the return type, I just changed the function name. But the build is still failing due to some compilation error. I can't easily see in the build log what though. 😞
image

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

Successfully merging this pull request may close these issues.

None yet

8 participants