harrelfe / Hmisc

Harrell Miscellaneous
Other
208 stars 81 forks source link

Using strat() in cph fit.mult.impute formula #53

Closed Zus closed 7 years ago

Zus commented 7 years ago
data(lung)
ddist <- datadist(lung)
options("datadist" = "ddist")
lung_im <- mice(lung)
fit <- fit.mult.impute(Surv(time, status==2) ~ strat(sex),cph, xtrans = lung_im)

Throws an "Error in vcov.rms(...) fit does not have a variance covariance matrix" while using coxph doesn't for instance. Is this a bug or am I misspecifying something?

harrelfe commented 7 years ago

Your model does not have any of the usual types of covariates so there is no basis for multiple imputation.

In addition tomice, take a look at aregImpute (although this will not address your issue).

Zus commented 7 years ago

Thanks for the reply. I think I may don't have the correct expectations from the risk table - I seem to have to specify a strat() variable if I want the table according to factor levels. This is not limited to imputation.

For instance-

fit_strat <- cph(Surv(time, status==2) ~ strat(sex),data = lung,surv = TRUE,x=TRUE,y=TRUE)
survplot(fit_strat, n.risk=TRUE)

But when I want to use as a (non-stratified) covariate

fit_strat <- cph(Surv(time, status==2) ~ sex,data = lung,surv = TRUE,x=TRUE,y=TRUE)
survplot(fit_strat, n.risk=TRUE)

The risk table displays two equal levels. Shouldn't it display a single line, or - same behaviour as stratified. Using npsurv instead works (but won't accept a cox fit as an arguments, so I couldn't use aregImpute or mice if I needed to)

Thanks alot for your time.

harrelfe commented 7 years ago

This issue is related to the rms package, not the Hmisc package.

With non-stratified variables, survival curve estimation borrows information across categories of the covariate. S(t) takes a jump at each event time no matter which group the subject is in. So the number at risk is also shared between the categories, when strat() is not used.