[R] using pre-calculated coefficients and LP in coxph()?
Ravi Varadhan
rvaradhan at jhmi.edu
Sun Mar 13 19:43:34 CET 2011
Like David, I too thought that `offset' is the way to do this. I was actually in the midst of testing the differences between using `offset' and `init' when David's email came.
Here is what I could figure out so far:
1. If you want to fix only a subset of regressors, but let others be estimated, then you must use `offset'. The `init' approach will not work.
2. Even when all the regressors are fixed (I have to admit that I do not see the point of this, like David said), there seems to be a difference in using `init' and `offset'. First of all, we cannot interpret or use the standard errors, CIs, abd p-values when iter.max=0. Secondly, there is major disagreement in the predictions between `offset' and `init' with no iterations. You can run the following code to verify this:
ans1 <- coxph(Surv(time, status) ~ age + ph.karno, data = lung, init = c(0.05, -0.05), iter.max = 0)
ans2 <- coxph(Surv(time, status) ~ offset(0.05*age) + offset(-0.05*ph.karno), data = lung)
lp1 <- predict(ans1, type="lp")
lp2 <- predict(ans2, type="lp")
all.equal(lp1, lp2)
> all.equal(lp1, lp2)
[1] "Mean relative difference: 1.463598"
The results from `offset' are correct, i.e. lp2 can be readily verified to be equal to 0.05 * (age - ph.karno). I don't know how lp1 is computed.
Ravi.
____________________________________________________________________
Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University
Ph. (410) 502-2619
email: rvaradhan at jhmi.edu
----- Original Message -----
From: David Winsemius <dwinsemius at comcast.net>
Date: Sunday, March 13, 2011 2:29 pm
Subject: Re: [R] using pre-calculated coefficients and LP in coxph()?
To: Dimitris Rizopoulos <d.rizopoulos at erasmusmc.nl>
Cc: r-help at r-project.org, Angel Russo <angerusso1980 at gmail.com>
> On Mar 13, 2011, at 1:32 PM, Dimitris Rizopoulos wrote:
>
> >probably you want to use the 'init' argument and 'iter.max'
> control-argument of coxph(). For example, for the Lung dataset, we fix
> the coefficients of age and ph.karno at 0.05 and -0.05, respectively:
> >
> >library(survival)
> >
> >coxph(Surv(time, status) ~ age + ph.karno, data = lung,
> > init = c(0.05, -0.05), iter.max = 0)
>
> >
> >
> >I hope it helps.
> >
> >Best,
> >Dimitris
> >
> >
> >On 3/13/2011 6:08 PM, Angel Russo wrote:
> >>I need to force a coxph() function in R to use a pre-calculated set
> of beta
> >>coefficients of a gene signature consisting of xx genes and the gene
> >>expression is also provided of those xx genes.
>
> I would have guessed (and that is all one can do without an example
> and better description of what the setting and goal might be) that the
> use of the offset capablity in coxph might be needed.
>
> --
> David.
> >>
> >>If I try to use "coxph()" function in R using just the gene
> expression data
> >>alone, the beta coefficients and coxph$linear.predictors will
> change and I
> >>need to use the pre-calcuated linear predictor not re-computed
> using coxph()
> >>function. The reason is I need to compute a quantity that uses as
> it's input
> >>the coxph() output but I need this output to be pre-calculated
> >>beta-coefficients and linear.predictor.
> >>
> >>Any one can show me how to do this in R?
> >>
> >>Thanks a lot.
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
>
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list