[R] Problem With Model.Tables Function

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Mar 10 22:53:06 CET 2001


I believe that these are correct, but you haven't told us why you think
they are wrong.  In the unbalanced case you need to understand carefully
what to expect: your expected answer is definitely wrong, which suggests
that R's might well be right.

For the record, these R results agree with S-PLUS on your examples.
But they are not much documented in the unbalanced case, so perhaps
`for experts only'.

The FAQ says:

9.1 What is a bug?

....

If a command does the wrong thing, that is a bug.  But be sure you know for
certain what it ought to have done.  If you aren't familiar with the
command, or don't know for certain how the command is supposed to work,
then it might actually be working right.  Rather than jumping to
conclusions, show the problem to someone who knows for certain.


On Sat, 10 Mar 2001, Gary Whysong wrote:

[...]

> > blocks2<-factor(c(1,2,3,4,1,2,4,1,2,3))
> > trtmts2<-factor(c(1,1,1,1,2,2,2,3,3,3,))
> > data2<-c(10,12,9,11,13,15,16,18,22,17)
> > unbalanced<-aov(data2~blocks2+trtmts2)
> > summary(unbalanced)
>             Df  Sum Sq Mean Sq F value    Pr(>F)
> blocks2      3  18.267   6.089  7.4341 0.0410993 *
> trtmts2      2 126.557  63.279 77.2587 0.0006367 ***
> Residuals    4   3.276   0.819
> ---
> Signif. codes:  0  `***'  0.001  `**'  0.01  `*'  0.05  `.'  0.1  ` '  1
> > model.tables(unbalanced,"means")
> Tables of means
> Grand mean
>
> 14.3
>
>  blocks2
>         1     2  3    4
>     13.67 16.33 13 13.5
> rep  3.00  3.00  2  2.0
>
>  trtmts2
>         1     2     3
>     10.68 14.47 18.97
> rep  4.00  3.00  3.00
>
> We find that the treatment means (trtmts2) are incorrect although the
> number of replications indicated are correct. Block means (blocks2) are
> correct.
>
> The treatment means should be: 10.5, 14.67, and 19.0, respectively.

Why?  These are *model*.tables not *data*.tables. You have to
adjust for block effects, and they are unbalanced.  Blocks 3 and 4 have
lower responses than 1 and 2, and they are missing for treatments 2 and 3.
Seems to adjust correctly to me.

Note the order of terms matters in unbalanced models.

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list