[R] Trouble Computing Type III SS in a Cox Regression

Terry Therneau therneau at mayo.edu
Thu Apr 25 00:55:32 CEST 2013


I should hope that there is trouble, since "type III" is an undefined concept for a Cox 
model.  Since SAS Inc fostered the cult of type III they have recently added it as an 
option for phreg, but I am not able to find any hints in the phreg documentation of what 
exactly they are doing when you invoke it.  If you can unearth this information, then I 
will be happy to tell you whether
    a. using the test (whatever it is) makes any sense at all for your data set
    b. if "a" is true, how to get it out of R

I use the word "cult" on purpose -- an entire generation of users who believe in the 
efficacy of this incantation without having any idea what it actually does.  In many 
particular instances the SAS type III corresponds to a survey sampling question, i.e., 
reweight the data so that it is balanced wrt factor A and then test factor B in the new 
sample.  The three biggest problems with type III are that
1: the particular test has been hyped as "better" when in fact it sometimes is sensible 
and sometimes not, 2: SAS implemented it as a computational algorithm which unfortunately 
often works even when the underlying rationale does not hold and
3: they explain it using a notation that completely obscures the actual question.  This 
last leads to the nonsense phrase "test for main effects in the presence of interactions".

There is a "survey reweighted" approach for Cox models, very closely related to the work 
on causal inference ("marginal structural models"), but I'd bet dollars to donuts that 
this is not what SAS is doing.

(Per 2 -- type III was a particular order of operations of the sweep algorithm for linear 
models, and for backwards compatability that remains the core definition even as 
computational algorthims have left sweep behind.  But Cox models can't be computed using 
the sweep algorithm).

Terry Therneau


On 04/24/2013 12:41 PM, r-help-request at r-project.org wrote:
> 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")
>> >  coxCV
> Call:
> 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



More information about the R-help mailing list