Paul Miller
2013-Apr-24 17:17 UTC
[R] Trouble Computing Type III SS in a Cox Regression using drop1 and Anova
Hello All, Am having some trouble computing Type III SS in a Cox Regression using either drop1 or Anova from the car package. Am hoping that people will take a look to see if they can tell what's going on. Here is my R code: cox3grp <- subset(survData, Treatment %in% c("DC", "DA", "DO"), c("PTNO", "Treatment", "PFS_CENSORED", "PFS_MONTHS", "AGE", "PS2")) cox3grp <- droplevels(cox3grp) str(cox3grp) coxCV <- coxph(Surv(PFS_MONTHS, PFS_CENSORED == 1) ~ AGE + PS2, data=cox3grp, method = "efron") coxCV drop1(coxCV, test="Chisq") require(car) Anova(coxCV, type="III") And here are my results: cox3grp <- subset(survData, + Treatment %in% c("DC", "DA", "DO"), + c("PTNO", "Treatment", "PFS_CENSORED", "PFS_MONTHS", "AGE", "PS2"))> cox3grp <- droplevels(cox3grp) > str(cox3grp)'data.frame': 227 obs. of 6 variables: $ PTNO : int 1195997 104625 106646 1277507 220506 525343 789119 817160 824224 82632 ... $ Treatment : Factor w/ 3 levels "DC","DA","DO": 1 1 1 1 1 1 1 1 1 1 ... $ PFS_CENSORED: int 1 1 1 0 1 1 1 1 0 1 ... $ PFS_MONTHS : num 1.12 8.16 6.08 1.35 9.54 ... $ AGE : num 72 71 80 65 72 60 63 61 71 70 ... $ PS2 : Ord.factor w/ 2 levels "Yes"<"No": 2 2 2 2 2 2 2 2 2 2 ...> > coxCV <- coxph(Surv(PFS_MONTHS, PFS_CENSORED == 1) ~ AGE + PS2, data=cox3grp, method = "efron") > coxCVCall: coxph(formula = Surv(PFS_MONTHS, PFS_CENSORED == 1) ~ AGE + PS2, data = cox3grp, method = "efron") coef exp(coef) se(coef) z p AGE 0.00492 1.005 0.00789 0.624 0.530 PS2.L -0.34523 0.708 0.14315 -2.412 0.016 Likelihood ratio test=5.66 on 2 df, p=0.0591 n= 227, number of events= 198> > drop1(coxCV, test="Chisq")Single term deletions Model: Surv(PFS_MONTHS, PFS_CENSORED == 1) ~ AGE + PS2 Df AIC LRT Pr(>Chi) <none> 1755.2 AGE 1 1753.6 0.3915 0.53151 PS2 1 1758.4 5.2364 0.02212 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1> > require(car) > Anova(coxCV, type="III")Analysis of Deviance Table (Type III tests) LR Chisq Df Pr(>Chisq) AGE 0.3915 1 0.53151 PS2 5.2364 1 0.02212 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1>Both drop1 and Anova give me a different p-value than I get from coxph for both my two-level ps2 variable and for age. This is not what I would expect based on experience using SAS to conduct similar analyses. Indeed SAS consistently produces the same p-values. Namely the ones I get from coxph. My sense is that I'm probably misusing R in some way but I'm not sure what I'm likely to be doing wrong. SAS prodcues Wald Chi-Square results for its type III tests. Maybe that has something to do with it. Ideally, I'd like to get type III values that match those from coxph. If anyone could help me understand better, that would be greatly appreciated. Thanks, Paul
John Fox
2013-Apr-24 18:31 UTC
[R] Trouble Computing Type III SS in a Cox Regression using drop1 and Anova
Dear Paul,> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Paul Miller > Sent: Wednesday, April 24, 2013 1:18 PM > To: r-help at r-project.org > Subject: [R] Trouble Computing Type III SS in a Cox Regression using > drop1 and Anova > > Hello All, > > Am having some trouble computing Type III SS in a Cox Regression using > either drop1 or Anova from the car package. Am hoping that people will > take a look to see if they can tell what's going on. > > Here is my R code: >. . .> > Both drop1 and Anova give me a different p-value than I get from coxph > for both my two-level ps2 variable and for age. This is not what I > would expect based on experience using SAS to conduct similar analyses. > Indeed SAS consistently produces the same p-values. Namely the ones I > get from coxph. > > My sense is that I'm probably misusing R in some way but I'm not sure > what I'm likely to be doing wrong. SAS prodcues Wald Chi-Square results > for its type III tests. Maybe that has something to do with it. > Ideally, I'd like to get type III values that match those from coxph. > If anyone could help me understand better, that would be greatly > appreciated.You've answered your own question: The summary() output gives you Wald tests, and drop1() and Anova() give you LR tests. From ?Anova: "test.statistic: ... for a Cox model, whether to calculate "LR" (partial-likelihood ratio) or "Wald" tests; ..." Thus, if you want the Wald test, you can ask for it (though it escapes me why you prefer it to the LR test). I hope this helps, John ----------------------------------------------- John Fox Senator McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada
Possibly Parallel Threads
- Trouble Computing Type III SS in a Cox Regression
- Survival curve mean adjusted for covariate: NEED TO DO IN NEXT 2 HOURS, PLEASE HELP
- Survival analysis extrapolation
- Extracting sentences with combinations of target words/terms from cancer patient text medical records
- How do I overlay two trellis plots of lme fitted lines produced by plot.augPred?