[R] using pre-calculated coefficients and LP in coxph()?
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. 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using pre-calculated coefficients and LP in coxph()?
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. 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using pre-calculated coefficients and LP in coxph()?
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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using pre-calculated coefficients and LP in coxph()?
Thanks very much Dimitrius and David. I want to compute CPE using pre-calculated beta-model and linear.predictor using the following code. I hope it the code is OK. Let me know. I am also doing some sanity checks. testc$x - scores testc$y - Surv(testdata$time,testdata$status) testfit - coxph(y ~ x, testc, iter.max=0, init=1) cpe=phcpe(testfit) Thanks very much again. - On Sun, Mar 13, 2011 at 2:28 PM, David Winsemius dwinsem...@comcast.netwrote: 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 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using pre-calculated coefficients and LP in coxph()?
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: rvarad...@jhmi.edu - Original Message - From: David Winsemius dwinsem...@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.rizopou...@erasmusmc.nl Cc: r-help@r-project.org, Angel Russo angerusso1...@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@r-project.org mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using pre-calculated coefficients and LP in coxph()?
On 3/13/2011 7:43 PM, Ravi Varadhan wrote: 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. Yes, indeed, this is right. 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: Of course, indeed, I don't know what Angel has in mind, but there are some cases where you might want to compute the hessian matrix at specific values using vcov() (local approximation of the likelihood for sensitivity analysis), and in this case the `offset' approach will not work. 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 in fact both are the same, only in the first one they are centered, e.g., ans1$linear.predictors ans2$linear.predictors - mean(ans2$linear.predictors) 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: rvarad...@jhmi.edu - Original Message - From: David Winsemiusdwinsem...@comcast.net Date: Sunday, March 13, 2011 2:29 pm Subject: Re: [R] using pre-calculated coefficients and LP in coxph()? To: Dimitris Rizopoulosd.rizopou...@erasmusmc.nl Cc: r-help@r-project.org, Angel Russoangerusso1...@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@r-project.org mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using pre-calculated coefficients and LP in coxph()?
On Mar 13, 2011, at 2:43 PM, Ravi Varadhan wrote: 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'. I want to thank you, Ravi, for taking the next steps beyond my speculations. However, I did not mean to imply that I could see no point in using an offset with coxph(). I only meant to say that the OP had not yet provided a basis for doing so. If one were trying to test a pre-determined classification rule against a new or augmented candidate rule, then entering an offset term could be very desirable. An example in my domain of interest might be to use a set of life-table estimates for the effect of sex and age , then including other covariates, and even including a subject_age term to test whether there was a departure from the population expectations. I admit that I have not seen worked examples using coxph(), but Therneau has offered examples using Poisson models with glm() in his publications regarding expected survival both in Mayo Clinic Technical Reports and in his book with Grambsch, Modeling Survival Data. 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: rvarad...@jhmi.edu - Original Message - From: David Winsemius dwinsem...@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.rizopou...@erasmusmc.nl Cc: r-help@r-project.org, Angel Russo angerusso1...@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@r-project.org mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.