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

From: Ben Bolker <>
Date: Wed, 25 Jul 2007 19:36:13 +0000 (UTC)

 <a.manners <at>> 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 mailing list Received on Wed 25 Jul 2007 - 19:39:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 25 Jul 2007 - 20:38:46 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.