aov-related segfault (PR#382)

Prof Brian D Ripley ripley@stats.ox.ac.uk
Wed, 22 Dec 1999 14:44:39 +0000 (GMT)


On Wed, 22 Dec 1999, Prof Brian Ripley wrote:

> On Mon, 20 Dec 1999 pd@butterfly.kubism.ku.dk wrote:
> 
> > This crashes the development version, but apparently also earlier versions
> > (a typo of course, but still shouldn't happen)
> > 
> > response<-rnorm(60)
> > dag<-gl(3,2,60) 
> > rep<-gl(2,1,60)
> > person<-gl(10,6,60)
> > aov(response~dag+Error(person/dag/response)) # error from model.matrix.default
> > gc() # *poof*...
> 
> 

Right, nailed it.  The problem is the do_modelmatrix attempts to remove the
response if it occurs on the rhs by declaring it to generate zero columns.
Thus all interactions including the response were declared to have zero
columns too, but they were being generated.

As far as I can see the prototype drops the response if it occurs on its
own as a main effect, but keeps in all interactions.  I've altered
R's code to do the same. The results are not the same in this example
as they interpret the interaction differently: I think R's is probably
right, but as this is not a real example the important thing is to
self-consistent.

> Progress report!
> 
> 1) This is nothing specific to aov. It can be repoduced by
> 
> response <- rnorm(60)
> dag <- gl(3,2,60) 
> model.matrix(formula = response ~ dag/response)
> 
> 2) The crash occurs because a 60x3 (rather than 60x6) matrix is allocated,
> so lots of writing outside the matrix occurs.
> 
> 3) model.matrix(~ dag + response:dag) works, but has a slightly different
> terms structure.
> 
> 4) S generates a 60x5 matrix, which looks wrong to me.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._