fit.models() (MLE): user-defined initial values can now
be passed to flexsurv through the option inits
(PRs #65 and #66). For a single distribution, inits can be
a numeric vector or a list with one numeric vector. For several
distributions, it must be a list with one element per distribution (in
the same order as distr); each element is a numeric vector
or NULL (to use the flexsurv default for that
model). Initial values are on the natural scale of the parameters, in
the order used by flexsurv; covariate effects that are not
given are initialised at 0 (thanks to @yansi5 for this).inits also works for the Royston-Parmar model
(distr="rps"), where it is passed to
flexsurv::flexsurvspline.runMLE(): for
distr="rps", the option timescale was read
from scale, so a user-specified timescale was
ignored.fit.models(): the list of
available distributions now matches load_availables()
(adding "rps" for MLE, "weibullPH" for INLA
and "rps" and "polyweibull" for HMC) and the
MLE-specific options (inits, weights,
subset and the "rps" options k,
knots, bknots, scale and
timescale) are now described.make.surv() (MLE): all covariate profiles now use the
same draws of the model parameters, so the simulations are paired across
profiles, as needed for PSA (PR #68). Previously, when
newdata was given, each profile had its own call to
normboot.flexsurvreg(), so the parameter draws were
independent across profiles. In addition, the sub-sampling of
nsim draws picked different rows for each profile, which
broke the pairing even when newdata was not given. Now
there is a single call to normboot.flexsurvreg() with all
the profiles and one set of sampled rows, shared by all profiles (thanks
to @bitowaqr for
this).make_state_occupancy(): the computation of the state
occupancy now restarts from start at the beginning of each
simulation (PR #70). Previously it only restarted when
profile changed; thus, with a single profile and
nsim>1, each simulation carried on from the last row of
the previous one, rather than from start. With several
profiles the bug was hidden, because the profile changes at each
simulation boundary (thanks to @bitowaqr for this).make_data_multi_state(): deaths without progression
(transition 2, Pre-progression -> Death) are now identified by
death==1 & prog==0 (PR #72). Previously the condition
was death==1 & prog_t==0, which never happens in
typical data (e.g. for TA174 it gives 0 direct deaths instead of 48);
thus, the Pre-progression -> Death hazard was badly wrong. The
documentation of prog_t and death_t now
explains that they contain the censoring time (or, for
prog_t, the death time) when the event has not happened
(thanks to @bitowaqr
for this).survHEinla too).
Specifically, adds the gam support in the hidden function
load_availables(). It also adds the function
rescale_stats_inla_gam(), which takes care of the rescaling
for the print method.survHE:::make_surv_curve_plot – replaces size
with linewidth in a call to geom_line. This
avoids a warning.survHE:::load_availables() has been modified
accordingly.dplyr and adds id
to the global functions.print method, so that the
original=TRUE option can also be compounded with an
additional option print_priors=TRUE. For HMC models, this
also adds to the table of results a summary of the prior modelling
assumptions.ggplot theme theme_survHE to be
used with combined plots (eg for a survextrap element)ggplot2, which is now transitioning to S7 class (see here)survHEinla and survHEhmcselect(!contains("(Intercept)")) instead of
select(-matches("Intercept"),everything()) in several parts
of the code. This was previously used to determine the names of the
strata, used to plot the survival curvesNEWS.md file to track changes to the package
(to replace the old .Rd version).October 2024
Patch code in support of plotting
(R/utils_fit_models.R)
make_surv_curve_plot replacegeom_step(data = datakm, aes(x = time, y = S, group=as.factor(strata)),
color="darkgrey") +
geom_ribbon(data = datakm,
aes(x = time, y = S, ymin=lower, ymax=upper, group=as.factor(strata)),
alpha = 0.2)
with
geom_step(data = datakm, aes(x = time, y = S, group=as.factor(strata:object_name)),
color="darkgrey") +
geom_ribbon(data = datakm,
aes(x = time, y = S, ymin=lower, ymax=upper, group=as.factor(strata:object_name)),
alpha = 0.2)
This means that when plotting two or more survHE
objects, the KM is added and displayed correctly
make_newdata that can be used
to generate profiles of covariates, to then plot specific groups of
individuals’ survival or hazard curves.September 2024
November 2022
April 2022
January 2022
Contribution by Andrew Jones to update compatibility with the newer version of stan. Changes on StanHeaders + stan models to avoid complaints by the compiler because of declared variables with the same name of a function that was being defined. None of these are directly “visible” to the final user, though…
Changes to ‘.Rbuildignore’ to allow ‘rstantool’ to automatically configuring on package install. Also improves compatibility across versions of ‘rstan’. See https://github.com/giabaio/survHE/pull/42
September 2021
Adds an option ‘what’ to plot so that ‘survival’, ‘hazard’ and ‘cumhazard’ can be specified (and the plot is modified to the various different scales)
Updates the Gamma, GenGamma and GenF models in HMC to include for the possibility that the data contain no censoring. Also fix a small typo in the print method for Gamma/HMC models.
Updates in INLA means now the Gompertz model is also available for survival modelling. fit.models(), make.surv() and print() have now been updated so that the Gompertz model can be run under ‘survHE’. In order to run the Gompertz model using INLA, the testing version (>=21.03.21) needs to be installed (see instructions here: https://www.r-inla.org/download-install).
Related to this, to improve computational stability, all the INLA models are now run by ‘survHE’ using the following trick: first the times are rescaled (on the fly) in the interval [0-1] (by simply recomputing ‘time=time/max(time’). The resulting models are not directly comparable to other inferential engines (because they are fitted to different data), but ‘survHE’ automatically rescales the estimates and model fitting statistics (eg *ICs) so that the ‘plot’ and ‘print’ methods give the correct answers. make.surv() has also been updated to reflect this.
There are also changes to make.transition.probs(), which has been updated and streamlined to compute transition probabilities off the survival curves fitted in a ‘survHE’ object. The computation is quicker and now based on the more robust relationship between the cumulative hazard function and the transition probabilities.
A new function make_data_multi_state() to create a dataset in the format required to analyse data in a multi-state framework.
A new function three_state_mm() added to fit a standard 3-states Markov model, based on survival curves that are then mapped onto transition probabilities (this function is under testing, though).
Adds two new datasets (TA174 and msmdata), both from the MDM paper by Williams et al (2017) that can be used for analysis of multi-state data.
June 2021