[R] coxph linear.predictors

Bond, Stephen Stephen.Bond at cibc.com
Thu Oct 28 16:52:45 CEST 2010


To close the issue:

> S.ave <- survfit(fit) # this is average survival
> S.1 <- (S.ave$surv)^exp(fit$linear.predictors[1]) # get subject 1
> S.1
 [1] 0.848450223861993 0.696973203043377 0.530604282995790 0.391136296063732 0.228370373409774 0.132991279576665 0.071742127376216
 [8] 0.030988671457923 0.012340713882587 0.004553665545169 0.000865566322530 0.000135746409544

> survfit(fit,new=ovarian[1,])$surv   # subject 1 from survfit
 [1] 0.848450223861993 0.696973203043377 0.530604282995791 0.391136296063732 0.228370373409774 0.132991279576665 0.071742127376216
 [8] 0.030988671457923 0.012340713882587 0.004553665545169 0.000865566322530 0.000135746409544

A single call to survfit will suffice for thousands of subjects, avoiding the iterative loop calculations inside survfit.

Stephen Bond 

-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: Wednesday, October 27, 2010 1:15 PM
To: Bond, Stephen
Cc: r-help at r-project.org
Subject: Re: [R] coxph linear.predictors


On Oct 27, 2010, at 12:12 PM, Bond, Stephen wrote:

> I would like to be able to construct hazard rates (or unconditional  
> death prob)

Hazards are not probabilities (since probabilities are constrained to  
the range [0,1] and hazards are unbounded upward.)

> for many subjects from a given survfit.
>
> This will involve adjusting the ( n.event/n.risk)
> with (coxph object )$linear.predictors
> I must be having another silly day as I cannot reproduce the linear  
> predictor:
>
> fit <- coxph(Surv(futime, fustat) ~ age, data = ovarian)
> fit$linear.predictors[1]
> [1] 2.612756

That's the linear predictor (the beta*X) and that particular number  
only applies to the first case.

>
> coef(fit)*model.matrix(fit)[1,1]
>     age
> 11.69021
>

I don't know what that might be and you are not telling us what you  
think it is.


> The above is based on the help listing for coxph.object
> coefficients: the coefficients of the linear predictor, which multiply
>          the columns of the model matrix.  If the model is
>          over-determined there will be missing values in the vector
>          corresponding to the redundant columns in the model matrix.
>
> Also, please comment whether n.event/n.risk

The Nelson-Aalen estimator of the cumulative hazard as a function of  
intervals prior to t is sum( n-event(t)/ n.risk(t))

> gives the baseline hazard exp(alpha) ?

No. The "baseline hazard", as you are calling this, would be an  
estimate for persons with all covariates = 0, so in this case is for  
women of age=0. (Not a particularly interpretable result in many  
situations. The baseline hazard following treated ovarian cancer for  
neonates is not medically sensible.)

What is the purpose of this request? Is someone telling you you need  
to provide estimates for instantaneous hazards?


-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list