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
methodofsurvestimand()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 nowsurvestimand(), and every othersurvkit_*function is nowsest_*(for examplesest_contrast(),sest_rmst()), as areas_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_errorand carries the backend’s message.?sest_refusallists the reason codes.sest_curve()andsest_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 bytrtat 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 ofnewdatathey are for, and labels the curves of a Kaplan-Meier fit by a variable with agroupcolumn. Every curve was labelledprofile = 1. - A fit records the values of the backend arguments it was given (for example
k,theta,ties), so a bootstrap refit insest_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()refusesdatawhose 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()gainscause: for a multi-state response it counts the events of that cause, andsurvestimand()passes thecauseof afine_grayfit. The gate gave"unknown"for every competing-risks response, sofine_graynever warned or abstained. A multi-state response withoutcausewarns that the gate did not run. -
sest_simulate()refuses areferencethat is not a level of the arm andtimesthat are not positive and finite. It returned truths for an arm that did not exist and ran withtimes = -1. - Survival curves, restricted means, scores and contrasts are computed from the class of the backend object (flexsurv,
coxphorsurvfit), not from the method’skind, and a registered method on any other backend is refused withsest_refusal_not_supported. A"parametric"method onsurvival::survreg(), as in thesest_register()example, ended in errors without a refusal class.sest_register()checkskind. -
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 formethod = "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 examplelog(shape)andlogit(theta). The log-scale estimates were reported under the plain namesshapeandscale. -
sest_rmst()refuses ataupast 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 withties = "exact"withsest_refusal_not_supported; it stopped with a plain error. The power-gate refusal carries the classsest_refusal_underpowered, like every other refusal. -
sest_ic()andlogLik()count the degrees of freedom the backend reports, so acox_ridgeorfrailtyfit 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 thereferenceof a numeric arm as a number or a string;"2"ended in a plain contrasts error. -
clusterandistateare evaluated indataand passed to the backend, likeweightsandid.cluster = instended in “object not found”. -
sest_split()numbers.idby the row ofdata, not by the row among the complete rows, and refuses a time of 0, whose row it dropped.sest_from_hazard_draws()checkscuts,arm,dataandformulafirst; unsorted cuts ended in a base R error. - The help of
sest_curve()andsest_rmst()says what the default profile is: the covariate means, which for a 1/2 arm is 1.5. -
sest_rmst()gainsconf_leveland returns the same columns for every kind of fit:profile(the row ofnewdata, or the group) andgroup(the group label of a Kaplan-Meier fit, otherwiseNA). It returnedgrouporprofiledepending on the fit and always a 95 % interval. -
sest_contrast()andsest_cr_contrast()refuse ann_bootthat 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
subsetis refused. - The default
n_mcofsest_simulate()is1e5. At1e6the 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. -
weightsandidare evaluated indataand passed to every method. Andersen-Gill no longer picks up an unrelated column calledid. -
subsetis applied before the power check. -
method = "cure"acceptsweights.method = "fine_gray"stops with an error when givenweightsorid. - Bootstrap intervals from
sest_contrast()refit each replicate with the original weights, splinekand ridgetheta, 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 anid. 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()andsest_score()work on formulas withstrata()orcluster()without attaching survival. Previously the power check returned “unknown” andsest_score()failed on stratified Cox fits. -
sest_rmst()for parametric fits gains aseedargument 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()andsest_score()on competing-risk fits,sest_ph_check()on fits with a clustered (robust) variance,sest_rmst()andsest_curve()on frailty and interval-censored fits, andweights,idorsubsetpassed tosest_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 returnedNA. -
sest_simulate()refuses an effect named for a transition the model does not have, which it ignored, and a non-positiven_mc.
Other changes
- DESCRIPTION drops
Remotes:. orchestraManifest, a suggested package, installs from https://max578.r-universe.dev, which DESCRIPTION lists underAdditional_repositories.
