[R] coxph() - unexpected result using Crawley's seedlings data (The R Book)

Ben Bolker bbolker at gmail.com
Tue Jun 28 20:42:01 CEST 2011


Jacob Brogren <jacob <at> brogren.nu> writes:

> 
> All,
> 
> I rerun once again and managed to reproduce the results from the text book. 
> Made no changes to the code. Could
> it be some problem with convergence?

  It is possible, but *extremely* unlikely, to get non-deterministic
results from R (i.e. running the same code twice from an identical
state and getting different answers [run from a clean R session to be
absolutely sure]) -- this only happens if there is a deep, C-level bug
in the internals of the code, which is unlikely in a piece of core
functionality like coxph().  It is slightly more likely, but still
unlikely, that running the code changes the state of the R session in
a subtle way that makes it run differently the second time in a row.
By far the most likely situation is that you have made some minor
change in the state (i.e. you redefined some variable) that allows
the code to reproduce the results in the book.  (I know I've done this
many times, even when I was initially fairly certain that I hadn't
changed anything.)

  In defense of Crawley: he's written a book that is very useful to
a lot of R users, even if advanced R users sometimes find it a bit
sloppy in places. I agree that he hasn't contributed much back
to the community (except for helping a large population
of beginning users to learn how to use R, which is non-trivial),
but I don't think he has gone out of his way to claim any kind of
official status (other than calling his book "The R Book").

  Ben Bolker



More information about the R-help mailing list