[R] Plot is lost when fitting block as error

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Mar 7 09:37:39 CET 2004


You second fit is of class c("aov", "lm"), the first of class "aovlist".
There is no way to plot a series of aov fits in different strata, but you
can plot aspects of the individual fits: there is an example in (MASS4,
p.284).

In your case there is only one stratum of interest and
plot(model[["Within"]]) ought to work, but for some reason plot.lm calls
predict() to get the fitted values.  I am not sure that the lm method for
plot is appropriate for aov fits, though: in particular leverage (and
hence Cook's distance) is not usually of interest.

On Sun, 7 Mar 2004, Don Driscoll wrote:

> G'day,
> 
> Plot doesn't seem to work when I specify block as an error term, but does 
> if I load block into the model as the first factor (see code below).
> 
> Is there some way to make plot work with the fancier model specification?
> 
> Also, if anyone knows how to get SEDs for this model I would really like to 
> know.

SEDs are what?

> response<-c(rnorm(5,5,2),rnorm(5,12,2),rnorm(5,18,2),rnorm(5,12,2))
> factor1<-factor(rep(c(1,2),each=10))
> factor2 <- factor(rep(rep(c(1,2),each=5),2))
> block<-gl(5,1,20)
> model<-aov(response~factor1*factor2+Error(block))
> plot(model)
> 
> 
> #THE RESULT IS:
> 
> Error in plot.window(xlim, ylim, log, asp, ...) :
>          need finite xlim values
> 
> BUT IF YOU SPECIFY THE MODEL AS
> 
> model<-aov(response~block+factor1*factor2)
> 
> THEN PLOT(MODEL) WORKS AS EXPECTED.

Does it?  It is not what I think is sensible.

-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list