[Rd] Possible update to survival
Ivan Krylov
|kry|ov @end|ng |rom d|@root@org
Tue Sep 24 16:11:30 CEST 2024
В Sun, 15 Sep 2024 00:43:31 +0000
"Therneau, Terry M., Ph.D. via R-devel" <r-devel using r-project.org> пишет:
> 2. Before calling model.frame(), insert my copy of strata into the
> calling chain coxenv <- new.env(parent= environment(formula))
> assign("strata", survival::strata, envir= coxenv)
> environment(formula) <- coxenv
<...>
> For ultimate safety, I am thinking of extending the above to all of
> the internal survival functions that might be used in a formula:
> Surv, strata, pspline, cluster, ratetable (I think that_s all). An
> intitial limited test looks okay, but before anything migrates to
> CRAN I am looking for any feedback.
What do you think of the following approach?
When changing the environment of the formula, construct the following
environment chain:
1. Top: your 'coxenv' environment with the special survival functions
2. Enclosing environment: list2env(data)
3. Enclosing^2 environment: original environment(formula)
Since the environment chain constructed by eval() when called by
model.frame() looks different (top: data -> enclosure:
environment(formula)), someone truly determined to shoot themselves in
the foot could still sneak a 'strata' function inside their 'data'
argument.
Having said that, what you are planning to implement may be already
reliable enough.
--
Best regards,
Ivan
More information about the R-devel
mailing list