[R] coxph and remaing events
David Winsemius
dwinsemius at comcast.net
Tue Jun 15 20:24:18 CEST 2010
On Jun 15, 2010, at 1:34 PM, Federico Calboli wrote:
> Hi everyone,
>
> I'm running a cox ph model on a dataset with a number of variables.
> Each variable has a different number of missing data, so that
> coxph() drops the individuals who are missing data at one or more
> variables. Because of this dropping (totally fine btw) I want to
> know how many events I am left with in the model. Is there a way of
> extracting them from the coxph() fit? or in any other reasonably
> efficient way?
Ideas:
a) This is perhaps "cheating", but I use Harrell's rms function cph()
which reports that number (as well as the number of missing from each
variable) by default as part of the print()-ed version of the cph-
object.
b) I would have thought that summing events after applying
complete.cases() to a subset containing just the variables of interest
would have done the job, if you wanted to remain "true" to "survival".
c) Or you could look at the older version of Harrell's work in the
Design package to see how he extracted the event count, since I
believe it made a call to cph().
d) Using the cph second example I seem to be getting success with
assigning the results of coxph call to cox.obj and doing:
> sum(cox.obj$y[,3])
[1] 7
>
> Best,
>
> Federico
>
>
> --
> Federico C. F. Calboli
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list