Build a survival formula safely via jmvcore::asFormula
Source:R/survival_utils.R
dot-asSurvivalFormula.RdWraps jmvcore::asFormula with the function allow-list extended to cover
common survival modelling helpers (Surv, strata, cluster, frailty,
tt, pspline, ns, bs, I, const, finegray). Use this instead of
base stats::as.formula() in survival / Cox / Fine-Gray paths so the formula
goes through jmvcore's allow-listed parser.
Usage
.asSurvivalFormula(x, env = parent.frame())Details
The returned formula's environment is set to the CALLER's frame. asFormula
otherwise leaves it pointing at its own evaluation frame, which does not hold
the caller's mydata. Model fitting still works, because coxph(fml, data=)
is handed the data directly — but any method that later re-evaluates the
model call does not get it. cox.zph() is the visible casualty: ticking
"Proportional hazards assumption" aborted the entire analysis with
"object 'mydata' not found", taking every other result down with it.