Skip to content
Prev 307988 / 398503 Next

Problems with coxph and survfit in a stratified model with interactions

rm wrote
Adding the main effect of cov2 allows the model to run

library(survival)

lung$cov1 <- factor(lung$ph.ecog, 0:3, c("zero","one","two","three"))
lung$cov2 <- factor(lung$sex, 1:2, c("male","female"))

sCox <- coxph(Surv(time, status) ~ strata(cov1) + cov2 + cov1:cov2,
data=lung)

df <- data.frame(
  cov1=factor(0:3, 0:3, c("zero","one","two","three"))[1],
  cov2=factor(1:2, 1:2, c("male","female"))[1]
)
df

sfCox <- survfit(sCox, newdata=df)

plot(sfCox[1], conf=FALSE)
lines(sfCox[2], col=2)
lines(sfCox[3], col=3)
lines(sfCox[4], col=4)



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