Skip to content
Prev 5465 / 398502 Next

Variable names in model formula

On Tue, 2 May 2000, Bill Venables wrote:

            
A related idea, which doesn't require you to know the structure of formula
object, but will be slower, is

covnames <- names(...)
for(nam in covnames) {
	form<-substitute(Surv(time,status)~dummy,list(dummy=nam))
	survout<-coxph(form,data=dataname)
	print(summary(survfit(survout, newdata), t0))
}

This method also works if you want to loop over different time and status
variables.

	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._