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

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

 <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.

  [snip]

   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

  therefore

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)
pchisq(abs(diff(a1$"-2*LL")),df=abs(a1$Df[2]),lower.tail=FALSE)

[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



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel 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 https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.