[Rd] specials and ::

peter dalgaard pd@|gd @end|ng |rom gm@||@com
Tue Aug 27 10:38:18 CEST 2024


In my view, that's just plain wrong, because strata() is not a function but a special operator in a model formula. Wouldn't it also blow up on stats::offset()?

Oh, yes it would:

> lm(y~x+offset(z))

Call:
lm(formula = y ~ x + offset(z))

Coefficients:
(Intercept)            x  
     0.7350       0.0719  

> lm(y~x+stats::offset(z))

Call:
lm(formula = y ~ x + stats::offset(z))

Coefficients:
     (Intercept)                 x  stats::offset(z)  
          0.6457            0.1078            0.8521  


Or, to be facetious:

> lm(y~base::"+"(x,z))

Call:
lm(formula = y ~ base::"+"(x, z))

Coefficients:
    (Intercept)  base::"+"(x, z)  
         0.4516           0.4383  



-pd

> On 26 Aug 2024, at 16:42 , Therneau, Terry M., Ph.D. via R-devel <r-devel using r-project.org> wrote:
> 
> The survival package makes significant use of the "specials" argument of terms(), before 
> calling model.frame; it is part of nearly every modeling function. The reason is that 
> strata argments simply have to be handled differently than other things on the right hand 
> side. Likewise for tt() and cluster(), though those are much less frequent.
> 
> I now get "bug reports" from the growing segment that believes one should put 
> packagename:: in front of every single instance.   For instance
>       fit <- survival::survdiff( survival::Surv(time, status) ~ ph.karno + 
> survival::strata(inst),  data= survival::lung)
> 
> This fails to give the correct answer because it fools terms(formula, specials= 
> "strata").    I've stood firm in my response of "that's your bug, not mine", but I begin 
> to believe I am swimming uphill.   One person responded that it was company policy to 
> qualify everything.
> 
> I don't see an easy way to fix survival, and even if I did it would be a tremendous amout 
> of work.   What are other's thoughts?
> 
> Terry
> 
> 
> 
> -- 
> 
> Terry M Therneau, PhD
> Department of Quantitative Health Sciences
> Mayo Clinic
> therneau using mayo.edu
> 
> "TERR-ree THUR-noh"
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com



More information about the R-devel mailing list