Dear all, I'm working with Cox-regression, because data could be censored. But in this particular case not. Now I have a simple example: PRO and PRE are (0,1) coded. The response is not normal distributed. We are interested in a model which could describe interaction. But my results are depending strongly in the choose of the contrast option. It is clear that there is some dependence in the contrasts, but in this simple case I could get the vice versa effect. My R output:> options(contrasts = c(unordered = "contr.treatment", ordered "contr.poly")) > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE)))... coef exp(coef) se(coef) z p factor(PRO)1 0.6576 1.930 0.302 2.177 0.029 factor(PRE)1 0.0681 1.070 0.304 0.224 0.820 factor(PRO)1:factor(PRE)1 -0.7703 0.463 0.431 -1.789 0.074 ...> options(contrasts = c(unordered = "contr.SAS", ordered = "contr.poly")) > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE)))... coef exp(coef) se(coef) z p factor(PRO)0 0.113 1.119 0.304 0.370 0.710 factor(PRE)0 0.702 2.018 0.299 2.350 0.019 factor(PRO)0:factor(PRE)0 -0.770 0.463 0.431 -1.789 0.074 ... What would the experts recommend? Kind regards, Dominik Dominik Grathwohl Biostatistician Nestl? Research Center PO Box 44, CH-1000 Lausanne 26 Phone: + 41 21 785 8034 Fax: + 41 21 785 8556 e-mail: dominik.grathwohl at rdls.nestle.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Well, contr.SAS is part of nlme, and it would have been helpful to have told us so. As a general principle the interpretation of main effects in the presence of interactions depends on the coding except for a few special cases (least squares fitting, balance and true contrasts (e.g. not contr.treatment nor contr.SAS) spring to mind). So this not a question of `preferable contrasts' but understanding how coding works. One extreme view is never to look at the coefficients, only at predictions, and although a counsel of perfection it contains a lot of merit. Chapter 6 of MASS (any edition) comes highly recommended to those wishing to understand coding (and it's by WNV, not me). On Thu, 7 Nov 2002, Grathwohl,Dominik,LAUSANNE,NRC/NT wrote:> Dear all, > > I'm working with Cox-regression, because data could be censored. > But in this particular case not. > Now I have a simple example: PRO and PRE are (0,1) coded. > The response is not normal distributed. > We are interested in a model which could describe interaction. > But my results are depending strongly in the choose of the contrast option. > It is clear that there is some dependence in the contrasts, but in this > simple case > I could get the vice versa effect. > My R output: > > > options(contrasts = c(unordered = "contr.treatment", ordered > "contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) > ... > coef exp(coef) se(coef) z p > factor(PRO)1 0.6576 1.930 0.302 2.177 0.029 > factor(PRE)1 0.0681 1.070 0.304 0.224 0.820 > factor(PRO)1:factor(PRE)1 -0.7703 0.463 0.431 -1.789 0.074 > ... > > options(contrasts = c(unordered = "contr.SAS", ordered = "contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) > ... > coef exp(coef) se(coef) z p > factor(PRO)0 0.113 1.119 0.304 0.370 0.710 > factor(PRE)0 0.702 2.018 0.299 2.350 0.019 > factor(PRO)0:factor(PRE)0 -0.770 0.463 0.431 -1.789 0.074 > ... > > What would the experts recommend? > > Kind regards, > > Dominik > > Dominik Grathwohl > Biostatistician > Nestlé Research Center > PO Box 44, CH-1000 Lausanne 26 > Phone: + 41 21 785 8034 > Fax: + 41 21 785 8556 > e-mail: dominik.grathwohl at rdls.nestle.com > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Dominik, I'm not familiar with contr.SAS (where does it come from?), but from the output I'd guess that it simply sets a different baseline category for the contrasts -- the last category (in your, case, coded 1 apparently) rather than the first (i.e., coded 0), which is what contr.treatment does. Notice that you have the same estimate and standard error for the interaction in both cases, which is consistent with my guess. To verify the codings try contrasts(factor(PRO)) in each case. In general, you should interpret parameter estimates in conformity with the coding employed. When using 0/1 coding in a model with interactions, you shouldn't think of the the coefficients for factor(PRO) and factor(PRE) as "main effects." None of this is specific to the Cox regression model. I hope that this helps, John At 10:36 AM 11/7/2002 +0100, Grathwohl,Dominik,LAUSANNE,NRC/NT wrote:>I'm working with Cox-regression, because data could be censored. >But in this particular case not. >Now I have a simple example: PRO and PRE are (0,1) coded. >The response is not normal distributed. >We are interested in a model which could describe interaction. >But my results are depending strongly in the choose of the contrast option. >It is clear that there is some dependence in the contrasts, but in this >simple case >I could get the vice versa effect. >My R output: > > > options(contrasts = c(unordered = "contr.treatment", ordered >"contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) >... > coef exp(coef) se(coef) z p >factor(PRO)1 0.6576 1.930 0.302 2.177 0.029 >factor(PRE)1 0.0681 1.070 0.304 0.224 0.820 >factor(PRO)1:factor(PRE)1 -0.7703 0.463 0.431 -1.789 0.074 >... > > options(contrasts = c(unordered = "contr.SAS", ordered = "contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) >... > coef exp(coef) se(coef) z p >factor(PRO)0 0.113 1.119 0.304 0.370 0.710 >factor(PRE)0 0.702 2.018 0.299 2.350 0.019 >factor(PRO)0:factor(PRE)0 -0.770 0.463 0.431 -1.789 0.074 >... > >What would the experts recommend?----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 7 Nov 2002 10:36:50 +0100 "Grathwohl,Dominik,LAUSANNE,NRC/NT" <dominik.grathwohl at rdls.nestle.com> wrote:> Dear all, > > I'm working with Cox-regression, because data could be censored. > But in this particular case not. > Now I have a simple example: PRO and PRE are (0,1) coded. > The response is not normal distributed. > We are interested in a model which could describe interaction. > But my results are depending strongly in the choose of the contrast option. > It is clear that there is some dependence in the contrasts, but in this > simple case > I could get the vice versa effect. > My R output: > > > options(contrasts = c(unordered = "contr.treatment", ordered > "contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) > ... > coef exp(coef) se(coef) z p > factor(PRO)1 0.6576 1.930 0.302 2.177 0.029 > factor(PRE)1 0.0681 1.070 0.304 0.224 0.820 > factor(PRO)1:factor(PRE)1 -0.7703 0.463 0.431 -1.789 0.074 > ... > > options(contrasts = c(unordered = "contr.SAS", ordered = "contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) > ... > coef exp(coef) se(coef) z p > factor(PRO)0 0.113 1.119 0.304 0.370 0.710 > factor(PRE)0 0.702 2.018 0.299 2.350 0.019 > factor(PRO)0:factor(PRE)0 -0.770 0.463 0.431 -1.789 0.074 > ... > > What would the experts recommend? > > Kind regards, > > Dominik > > Dominik Grathwohl > Biostatistician > Nestl? Research Center > PO Box 44, CH-1000 Lausanne 26 > Phone: + 41 21 785 8034 > Fax: + 41 21 785 8556 > e-mail: dominik.grathwohl at rdls.nestle.comThink of what you want to estimate. I like to think of differences in predicted values (or the anti-log of such differences, i.e., hazard ratios). To make estimates independent of all coding decisions I wrote contrast.Design for the Design library. Here is an example: library(Design) # from http://hesweb1.med.virginia.edu/biostat/s/Design.html f <- cph(Surv(dtime,event) ~ PRO*PRE) # make PRO and PRE factors in the data frame contrast(f, list(PRO='somevalue',PRE='somevalue'), list(PRO='someothervalue',PRE='someothervalue')) The contrast compares predicted values for the two pairs of settings of (PRE,PRO). Frank -- Frank E Harrell Jr Prof. of Biostatistics & Statistics Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear experts, I would like to thank the experts for the fast and fruitful advises concerning my posted problem. Some would like to know where contr.SAS comes from. It is part of the NLME library and it could be found in the SASmixed library. However, I think it's not crucial where it comes from to present my problem. My problem was more of general nature about the impact of contrasts to the p-value of parameter estimates than to this special case of contr.SAS. I'm aware that there is some impact but it was surprising for me that I could choose whether PRO is significant or PRE is significant depending on contrasts. Now I would like to summarize the answers. Vito Muggio recommends using Likelihood Ratio Test instead.> 1-pchisq(2*pro.pre$loglik[2]-2*pre$loglik[2], df=1) # impact of pro[1] 0.1962388> 1-pchisq(2*pro.pre$loglik[2]-2*pro$loglik[2], df=1) # impact of pre[1] 0.1259392 PRO and PRE seems not to contribute in a significant way. Brian Ripley advice that the interpretation of main effects in the presence of interactions depends on the coding except for a few special cases (least squares fitting, balance and true contrasts (e.g. not contr.treatment nor contr.SAS) spring to mind). One extreme view is never to look at the coefficients, only at predictions, and although a counsel of perfection it contains a lot of merit. In addition, he refers to chapter 6 of MASS. John Fox writes that parameter estimates should interpret in conformity with the coding employed. When using 0/1 coding in a model with interactions, you shouldn't think of the coefficients for factor(PRO) and factor(PRE) as "main effects." Frank E. Harrell Jr. also recommend to predict values and pointed me to an example of his contrast.Design, part of the Design library.> contrast(f, list(PRO=1,PRE=0),list(PRO=0, PRE=0))PRE Contrast S.E. Lower Upper Z Pr(>|z|) 0 0.6576294 0.3020151 0.06569076 1.249568 2.18 0.0294> contrast(f, list(PRO=0,PRE=1),list(PRO=0, PRE=0))PRO Contrast S.E. Lower Upper Z Pr(>|z|) 0 0.0680866 0.3040376 -0.5278161 0.6639893 0.22 0.8228 Rising PRO by 1 seems to be a significant effect, PRE not. In summary, all experts point me to use something, which is independent of a certain contrast matrix. Personally, I would like to prefer the prediction rather than the LR-test, because I have really to spell out what I want to see. Thank you all, Dominik> -----Original Message----- > From: Grathwohl,Dominik,LAUSANNE,NRC/NT > Sent: jeudi, 7. novembre 2002 10:37 > To: r-help at stat.math.ethz.ch > Subject: [R] Preferable contrasts? > > > Dear all, > > I'm working with Cox-regression, because data could be censored. > But in this particular case not. > Now I have a simple example: PRO and PRE are (0,1) coded. > The response is not normal distributed. > We are interested in a model which could describe interaction. > But my results are depending strongly in the choose of the > contrast option. > It is clear that there is some dependence in the contrasts, > but in this > simple case > I could get the vice versa effect. > My R output: > > > options(contrasts = c(unordered = "contr.treatment", ordered > "contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) > ... > coef exp(coef) se(coef) z p > factor(PRO)1 0.6576 1.930 0.302 2.177 0.029 > factor(PRE)1 0.0681 1.070 0.304 0.224 0.820 > factor(PRO)1:factor(PRE)1 -0.7703 0.463 0.431 -1.789 0.074 > ... > > options(contrasts = c(unordered = "contr.SAS", ordered = > "contr.poly")) > > summary(coxph(Surv(ILOG, alive) ~ factor(PRO)*factor(PRE))) > ... > coef exp(coef) se(coef) z p > factor(PRO)0 0.113 1.119 0.304 0.370 0.710 > factor(PRE)0 0.702 2.018 0.299 2.350 0.019 > factor(PRO)0:factor(PRE)0 -0.770 0.463 0.431 -1.789 0.074 > ... > > What would the experts recommend? > > Kind regards, > > Dominik > > Dominik Grathwohl > Biostatistician > Nestl? Research Center > PO Box 44, CH-1000 Lausanne 26 > Phone: + 41 21 785 8034 > Fax: + 41 21 785 8556 > e-mail: dominik.grathwohl at rdls.nestle.com > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > -.-.-.-.-.-.-.-.- > r-help mailing list -- Readhttp://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._