r - coxph stratified by year -


i think should easy, can't quite head around it.

i have following code:

library(survival) cox <- coxph(surv(surv, dead)~year, data) summary(cox) 

but have result split down individual years.

here's spss syntax , solution like:

coxreg surv /status=dead(1) /contrast (year)=indicator(1)  /method=enter year /print=ci(95)  /criteria=pin(.05) pout(.10) iterate(20). execute. 

enter image description here

and same thing in stata:

xi: stcox i.year 

here's output of

str(data) 

enter image description here

you did not show str(data) or how construct reproducible example gave "data". suspect "year" turn out numeric vector. if had been factor variable have seen intercept , n-1 coefficients. interecpt coefficient have been same "year" , other coefficients have matched year(n) values. told spss engine "year" "indicator" didn't offer same courtesy r engine.

try this:

data$year.ind <- factor(data$year)  # equivalent of spss indicator                                     # or sas /class cox.mdl <- coxph(surv(surv, dead)~year, data) as.matrix(coef(coc.mdl) summary(cox.mdl) 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -