[Rd] anova tables in survreg (PR#9806)

Ben Bolker bolker at ufl.edu
Wed Jul 25 21:36:13 CEST 2007

 <a.manners <at> sib.uq.edu.au> writes:

> To whom it may concern,
> I'm trying to get an ANOVA table within survreg but it always 
> produces NA's in
> the p-value, regardless of the data set. 


   The problem is fairly clear, but not knowing the larger context
I don't know the best way to fix it.

  survival:::anova.survreg passes the following table to stat.anova():

     Df Deviance Resid. Df   -2*LL
NULL                    28 311.363
x    -1   22.773        27 288.590

stat.anova figures out where to look for the deviance
(dev.col is 2 here) and pulls out the difference
in degrees of freedom (dfs = c(NA,-1))
It then uses

vals <- table[, dev.col]/scale * sign(dfs)

  which comes out negative because sign(dfs)
is negative but the deviance is calculated as positive


pchisq(vals, abs(dfs), lower.tail = FALSE))

  comes out as NA since vals is < 0.

  In the short term you could do:

a1 = anova(mot.sreg)

[1] 1.822632e-06

  In the longer term it looks like someone (??) should
figure out why anova.survreg and stat.anova are disagreeing
about the appropriate signs of df and deviance, and how to fix it ...

  Ben Bolker

More information about the R-devel mailing list