Skip to contents

survestimand 0.1.0

First release under the new name. It follows survkit 0.2.2, whose entries below keep the old names.

Breaking changes

  • The default method of survestimand() is "cox", which needs only survival. It was "weibull", which needs the suggested flexsurv.

    # before: a Weibull fit, or an error without flexsurv
    survestimand(Surv(time, status) ~ age, lung)
    # now: a Cox fit; ask for Weibull by name
    survestimand(Surv(time, status) ~ age, lung, method = "weibull")
  • The package is renamed from survkit to survestimand. survkit() is now survestimand(), and every other survkit_* function is now sest_* (for example sest_contrast(), sest_rmst()), as are as_sest_manifest(), is_sest_refusal() and the refusal classes (sest_refusal_<reason>). The old names are gone, with no aliases.

  • survkit_triangulate() is removed. In simulations with a misspecified model it flagged at most 6.5 % of replicates (0 % at the default threshold), so it did not detect misfit.

  • Every exported function checks its inputs and refuses malformed or degenerate ones with a typed condition: an argument of the wrong type or range, a response with infinite or negative times, data with no complete rows or no events, an unregistered method, a missing backend. An error raised inside a backend is signalled again as sest_refusal_backend_error and carries the backend’s message. ?sest_refusal lists the reason codes.

  • sest_curve() and sest_rmst() refuse competing-risk and recurrent-event fits, whose hazards do not integrate to a survival probability. sest_score() refuses frailty, interval-censored and recurrent-event fits.

Bug fixes

  • sest_score() on a Kaplan-Meier fit with groups scores each subject on its own group’s curve. It spread the stacked group curves over the rows in turn, so the C-index and Brier score were wrong (veteran by trt at day 100: C 0.497, own-arm 0.525).
  • sest_score() drops rows with a missing response or covariate before it predicts, as it already did for the response. It stopped with a plain “differing number of rows” error on such data.
  • sest_score() estimates the censoring distribution with events before censoring at a tied time and weights a death by the censoring survival just before it, so the Brier score and IPA equal those of riskRegression. They differed in the fourth decimal place on data with tied times.
  • sest_curve() numbers the curves of a parametric, spline or cure fit by the row of newdata they are for, and labels the curves of a Kaplan-Meier fit by a variable with a group column. Every curve was labelled profile = 1.
  • A fit records the values of the backend arguments it was given (for example k, theta, ties), so a bootstrap refit in sest_contrast() reuses them. The refit evaluated their expressions again in the formula’s environment and could pick up another object of the same name.
  • sest_contrast() refuses data whose complete rows differ from the fit’s in number or in events (sest_refusal_different_data). It standardised over whatever data it was given and refitted the bootstrap on it.
  • sest_power() gains cause: for a multi-state response it counts the events of that cause, and survestimand() passes the cause of a fine_gray fit. The gate gave "unknown" for every competing-risks response, so fine_gray never warned or abstained. A multi-state response without cause warns that the gate did not run.
  • sest_simulate() refuses a reference that is not a level of the arm and times that are not positive and finite. It returned truths for an arm that did not exist and ran with times = -1.
  • Survival curves, restricted means, scores and contrasts are computed from the class of the backend object (flexsurv, coxph or survfit), not from the method’s kind, and a registered method on any other backend is refused with sest_refusal_not_supported. A "parametric" method on survival::survreg(), as in the sest_register() example, ended in errors without a refusal class. sest_register() checks kind.
  • sest_tidy() reports a ratio only for hazard, time and odds ratios. It exponentiated probit-scale spline coefficients and the coefficients of a fit that declared no ratio type (an intercept of 1261 read as a ratio).
  • sest_tidy() reports no ratio for method = "gamma". flexsurv puts its covariates on the rate, so exp(coefficient) is the inverse of a time ratio; it was labelled a time ratio (lung, sex: 0.65 for a time ratio of about 1.54).
  • as_sest_manifest() draws the coefficients from their covariance with base R, and refuses a fit without a finite covariance matrix (sest_refusal_no_covariance). Without MASS it drew independent normals that ignored the covariance, and without a covariance it drew with unit variance, in both cases silently.
  • sest_tidy() names a flexsurv baseline parameter by the scale of its estimate, for example log(shape) and logit(theta). The log-scale estimates were reported under the plain names shape and scale.
  • sest_rmst() refuses a tau past the last observed time (sest_refusal_horizon_beyond_data) and a Cox fit with a (start, stop] response. It extended the last value of the curve past follow-up.
  • sest_ph_check() refuses a fit with ties = "exact" with sest_refusal_not_supported; it stopped with a plain error. The power-gate refusal carries the class sest_refusal_underpowered, like every other refusal.
  • sest_ic() and logLik() count the degrees of freedom the backend reports, so a cox_ridge or frailty fit uses its effective degrees of freedom. They counted the coefficients.
  • sest_cr_contrast(method = "aalen_johansen") refuses a formula with variables besides the arm, which it ignored. The contrast functions take the reference of a numeric arm as a number or a string; "2" ended in a plain contrasts error.
  • cluster and istate are evaluated in data and passed to the backend, like weights and id. cluster = inst ended in “object not found”.
  • sest_split() numbers .id by the row of data, not by the row among the complete rows, and refuses a time of 0, whose row it dropped. sest_from_hazard_draws() checks cuts, arm, data and formula first; unsorted cuts ended in a base R error.
  • The help of sest_curve() and sest_rmst() says what the default profile is: the covariate means, which for a 1/2 arm is 1.5.
  • sest_rmst() gains conf_level and returns the same columns for every kind of fit: profile (the row of newdata, or the group) and group (the group label of a Kaplan-Meier fit, otherwise NA). It returned group or profile depending on the fit and always a 95 % interval.
  • sest_contrast() and sest_cr_contrast() refuse an n_boot that is not a whole number.
  • Refusals name a likely cause and a remedy: a horizon past follow-up, a failed bootstrap, fits on different rows, a model with nothing to estimate, and disagreeing simulation truths. A character subset is refused.
  • The default n_mc of sest_simulate() is 1e5. At 1e6 the two-arm help example peaked about 330 MB higher.
  • method = "cox_ridge" codes factors as treatment-contrast dummies. Previously a factor was penalised as a single numeric column.
  • weights and id are evaluated in data and passed to every method. Andersen-Gill no longer picks up an unrelated column called id.
  • subset is applied before the power check.
  • method = "cure" accepts weights. method = "fine_gray" stops with an error when given weights or id.
  • Bootstrap intervals from sest_contrast() refit each replicate with the original weights, spline k and ridge theta, which were previously ignored.
  • sest_contrast() uses the fit’s weights for both Kaplan-Meier and standardised model contrasts, and bootstraps by subject when the fit has an id. It stops with an error for counting-process (start, stop] responses and for Kaplan-Meier fits stratified by anything other than the arm.
  • sest_power() counts model parameters, not formula terms: a 4-level factor counts 3.
  • sest_power() and sest_score() work on formulas with strata() or cluster() without attaching survival. Previously the power check returned “unknown” and sest_score() failed on stratified Cox fits.
  • sest_rmst() for parametric fits gains a seed argument and returns a standard error.
  • as_sest_manifest(seed = ) no longer changes the global random-number state.
  • These cases now stop with a classed error instead of returning a wrong result or the backend’s own error: sest_rmst() and sest_score() on competing-risk fits, sest_ph_check() on fits with a clustered (robust) variance, sest_rmst() and sest_curve() on frailty and interval-censored fits, and weights, id or subset passed to sest_cr_contrast().
  • Interval-censored fits record the backend’s log-likelihood, so sest_ic() gives them an AIC. It was missing.
  • sest_score() stops with an error when the concordance cannot be computed. It returned NA.
  • sest_simulate() refuses an effect named for a transition the model does not have, which it ignored, and a non-positive n_mc.

Other changes

  • DESCRIPTION drops Remotes:. orchestraManifest, a suggested package, installs from https://max578.r-universe.dev, which DESCRIPTION lists under Additional_repositories.