[R] Problems with coxph and survfit in a stratified model, with interactions

rm rm at wippies.se
Mon Oct 15 00:59:39 CEST 2012


Many thanks for your very quick reply!  I tried replacing ”~ strata(cov1) +
cov1:cov2 ” with  ”~ strata(cov1):cov2 ”. As a result, I get an error
message saying that ”object 'cov1' not found”. I guess R refers to the data
frame. Any idea how to fix the error? Complete code follows.

Best regards,
Roland



require(survival) 
data(lung) 
# 
lung$cov1 <- as.factor(lung$ph.ecog) 
lung$cov2 <- as.factor(lung$sex) 
levels(lung$cov1)[levels(lung$cov1)==0] <- "zero" 
levels(lung$cov1)[levels(lung$cov1)==1] <- "one" 
levels(lung$cov1)[levels(lung$cov1)==2] <- "two" 
levels(lung$cov1)[levels(lung$cov1)==3] <- "three" 
levels(lung$cov2)[levels(lung$cov2)==1] <- "male" 
levels(lung$cov2)[levels(lung$cov2)==2] <- "female" 
# 
df <- data.frame( 
  cov2=factor("female", levels = levels(lung$cov2)) 
) 
sCox <- coxph(Surv(time, status) ~ strata(cov1):cov2, data=lung) 
sfCox <- survfit(sCox,newdata=df) 



--
View this message in context: http://r.789695.n4.nabble.com/Re-Problems-with-coxph-and-survfit-in-a-stratified-model-with-interactions-tp4646171p4646183.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list