Closed Philip-Cooney closed 2 years ago
Thank you, @Philip-Cooney. Which version of survHE
are you on? Also, to simplify/speed up things, can you point out more directly to what issues you have encountered (and what error message has been thrown out)?
I'll look into these ASAP, but it'd help to focus on exactly what is wrong and your suggested solution...
Thanks
Hi @giabaio. I am on version 1.1.2 (CRAN).
Hopefully this makes things clearer.
Let me know if you require any further clarifications.
Philip
packageVersion("survHE")
#‘1.1.2’
mods <- c( "gamma", "rps")
formula <- Surv(time, censored) ~ 1
m1 <- fit.models(formula = formula, data = data, distr = mods, k = 1, method = "hmc")
#Issue 1: Not an error actually; gamma doesn't display correctly; 3 rows instead of 2
print(m1, mod = 1)
#Issue 2: Not an error actually; rps doesn't display correctly; 4 rows instead of 3
print(m1, mod = 2)
#compare with flexsurvreg
flexsurv::flexsurvspline(formula, data = data, k = 1)
#issue 3: Actual error "Error in -ncol(beta) : invalid argument to unary operator"
plot(m1)
Thank you, @Philip-Cooney. I think these have been fixed now in the devel
version. Note that there's been a major restructuring of the package, so that now, the CRAN version of survHE
is in fact split in three packages. You can get the main structure and all the basic functions by installing the devel
branch
remotes::install_github("giabaio/survHE",ref="devel")
This basically loads up the main frequentist facilities (based on flexsurv
) and the functions that allows the computation to be extended to either INLA or HMC. However, in order to be able to run Bayesian models, you need to separately install either or both the two other branches (ref="hmc"
and ref="inla"
), which you can do using, for instance
remotes::install_github("giabaio/survHE",ref="hmc")
Installing the hmc
branch is a lot longer than the simplest devel
(and, in fact, the inla
) branch, so this helps streamline and simplify the package.
If you install devel
and hmc
, the code below
library(survHE)
mods <- c( "gamma", "rps")
formula <- Surv(time, censored) ~ 1
m1 <- fit.models(formula = formula, data = data, distr = mods, k = 1, method = "hmc")
loads up in the background the hmc
module (which contains the functions to run Stan in the background). Then
print(m1,mod=1)
gives
Model fit for the Gamma model, obtained using Stan (Bayesian inference via
Hamiltonian Monte Carlo). Running time: 6.5852 seconds
mean se L95% U95%
shape 2.30141 0.2234237 1.890047 2.769696
rate 0.20283 0.0263161 0.155552 0.258184
Model fitting summaries
Akaike Information Criterion (AIC)....: 1218.476
Bayesian Information Criterion (BIC)..: 1230.192
Deviance Information Criterion (DIC)..: 1216.601
and
print(m1,mod=2)
gives
Model fit for the Royston & Parmar splines model, obtained using Stan (Bayesian inference via
Hamiltonian Monte Carlo). Running time: 35.426 seconds
mean se L95% U95%
gamma0 -4.7372313 0.4008544 -5.568327 -3.996486
gamma1 2.1074918 0.3412200 1.483785 2.799519
gamma2 0.0550641 0.0519523 -0.043094 0.154634
Model fitting summaries
Akaike Information Criterion (AIC)....: 1218.381
Bayesian Information Criterion (BIC)..: 1230.097
Deviance Information Criterion (DIC)..: 1238.130
--- so both work now. If you also do
plot(m1)
you get the correct graph so all these issues should have been fixed now!
Thanks for pointing them out and please do shout if anything is unclear/you find other bugs!
Great, Thank for the clarification @giabaio. Philip
I just noticed three small bugs in the package that can be fixed with the code below:
If you try and print out the Gamma model it will not work because of a typo.
Secondly the Royston-Parmar model does not display correctly when no covariates are included for the reason indicated in the code.
Another issue with the Royston-Parmar with no covariates is that it will not plot the survival due to an error in this code: