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. 
and same thing in stata:
xi: stcox i.year here's output of
str(data) 
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
Post a Comment