How do you get the design matrix R used when calculating ANOVA? -- View this message in context: http://www.nabble.com/how-to-get-design-matrix--tp23464638p23464638.html Sent from the R help mailing list archive at Nabble.com.
If I was doing an ANOVA analysis how can I get the design matrix R used? -- View this message in context: http://www.nabble.com/how-to-get-design-matrix--tp23466549p23466549.html Sent from the R help mailing list archive at Nabble.com.
Got code? On May 9, 2009, at 10:29 PM, linakpl wrote:> > If I was doing an ANOVA analysis how can I get the design matrix R > used? > --David Winsemius, MD Heritage Laboratories West Hartford, CT
John Sorkin
2009-May-10 03:44 UTC
[R] Comparing COXPH models, one with age as a continuous variable, one with age as a three-level factor
Windows XP R 2.8.1 I am trying to use anova(fitCont,fitCat) to compare two Cox models (coxph) one in which age is entered as a continuous variable, and a second where age is entered as a three-level factor (young, middle, old). The Analysis of Deviance Table produced by anova does not give a p value. Is there any way to get anova to produce p values? Thank you, John Sorkin ANOVA results are pasted below:> anova(fitCont,fitCat)Analysis of Deviance Table Model 1: Surv(Time30, Died) ~ Rx + Age Model 2: Surv(Time30, Died) ~ Rx + AgeGrp Resid. Df Resid. Dev Df Deviance 1 62 147.38 2 61 142.38 1 5.00 The entire program including the original coxph models follows:> fitCont<-coxph(Surv(Time30,Died)~Rx+Age,data=GVHDdata)> summary(fitCont)Call: coxph(formula = Surv(Time30, Died) ~ Rx + Age, data = GVHDdata) n= 64 coef exp(coef) se(coef) z p Rx 1.375 3.96 0.5318 2.59 0.0097 Age 0.055 1.06 0.0252 2.19 0.0290 exp(coef) exp(-coef) lower .95 upper .95 Rx 3.96 0.253 1.40 11.22 Age 1.06 0.946 1.01 1.11 Rsquare= 0.154 (max possible= 0.915 ) Likelihood ratio test= 10.7 on 2 df, p=0.00483 Wald test = 9.46 on 2 df, p=0.0088 Score (logrank) test = 10.2 on 2 df, p=0.00626> fitCat<-coxph(Surv(Time30,Died)~Rx+AgeGrp,data=GVHDdata)> summary(fitCat)Call: coxph(formula = Surv(Time30, Died) ~ Rx + AgeGrp, data = GVHDdata) n= 64 coef exp(coef) se(coef) z p Rx 1.19 3.27 0.525 2.26 0.024 AgeGrp[T.(15,25]] 1.98 7.26 0.771 2.57 0.010 AgeGrp[T.(25,45]] 1.61 5.02 0.806 2.00 0.045 exp(coef) exp(-coef) lower .95 upper .95 Rx 3.27 0.306 1.17 9.16 AgeGrp[T.(15,25]] 7.26 0.138 1.60 32.88 AgeGrp[T.(25,45]] 5.02 0.199 1.04 24.38 Rsquare= 0.217 (max possible= 0.915 ) Likelihood ratio test= 15.7 on 3 df, p=0.00133 Wald test = 12.0 on 3 df, p=0.0075 Score (logrank) test = 14.5 on 3 df, p=0.00232> anova(fitCont,fitCat)Analysis of Deviance Table Model 1: Surv(Time30, Died) ~ Rx + Age Model 2: Surv(Time30, Died) ~ Rx + AgeGrp Resid. Df Resid. Dev Df Deviance 1 62 147.38 2 61 142.38 1 5.00 John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
stephenb
2010-Sep-02 14:48 UTC
[R] Comparing COXPH models, one with age as a continuous variable, one with age as a three-level factor
sorry to bump in late, but I am doing similar things now and was browsing. IMHO anova is not appropriate here. it applies when the richer model has p more variables than the simpler model. this is not the case here. the competing models use different variables. you are left with IC. by transforming a continuous variable into categorical you are smoothing, which is the idea of GAM. if you look at what is offered in GAMs you may find better approximations f(age) as well as tools for testing among different f(age) transformations. regards. S. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-design-matrix-tp891987p2524289.html Sent from the R help mailing list archive at Nabble.com.