This shoul work: coxph(Surv(intx, status) ~ . + strata(sex) - sex, test1)
On Wed, Aug 11, 2010 at 1:54 PM, Mendolia, Franco <fmendo...@mcw.edu> wrote: > Hello! > > I have something like this: > > test1 <- data.frame(intx=c(4,3,1,1,2,2,3), > status=c(1,1,1,0,1,1,0), > x1=c(0,2,1,1,1,0,0), > x2=c(1,1,0,0,2,2,0), > sex=c(0,0,0,0,1,1,1)) > > and I can easily fit a cox model: > > library(survival) > coxph(Surv(intx,status) ~ x1 + x2 + strata(sex),test1) > > However, I want to write my own function, fit the model inside this > function and then do some further computations. > > f <- function(time, event, stratum, covar ) > { > > fit <- coxph(Surv(time,event) ~ covar[[1]] + covar[[2]] + strata(stratum)) > fit > #... do some other stuff > } > > attach(test1) > f(intx, status, sex, list(x1,x2)) > > This works fine when I have exactly two covariates. However, I would like > to have something that I can use with an arbitrary number of covariates. > More precisely, I need something more general than covar[[1]] + covar[[2]]. > > Any ideas? > > Thanks, > Franco > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.