[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: yscale in anovaplot

From   David Airey <>
Subject   Re: st: RE: yscale in anovaplot
Date   Mon, 27 Apr 2009 07:04:13 -0500


Wow. And to think I have been using methods on that page rather than - anovaplot-? What a dummy. Tsk.

Awesome and thanks Nick! Now maybe -anovaplot- will rival your - stripplot- as my favorite graphic command.


On Apr 27, 2009, at 4:55 AM, Nick Cox wrote:

That's a very helpful reference to keep questions clear and specific.

That web page gives two graphs, and (modulo cosmetic details) both are
obtainable directly via -anovaplot-. The only twist is that the - anova-
to precede it is simpler than the -anova- used as example.

use, clear
anova y a b a*b
anovaplot, scatter(ms(none))
anovaplot b a
anovaplot b a, scatter(ms(none))

The moral that the plots you want may pertain to a simpler ANOVA than
that you fit is valuable, and I'll build this example into the next
revision of the help for -anovaplot-.


David Airey

Typical plots in the context of a split plot design are here:

On Apr 26, 2009, at 1:19 PM, David Airey wrote:

In the simplest within subject design, the paired ttest, it makes
sense to plot the data by subject, a line per subject. Or if you
measure subjects repeatedly over time, it also makes sense to keep
the graphic by subject. Or if you measure two groups, pre and post,
it makes sense to plot either two groups of different colored lines
(one line per subject) or ignore subject and make a profile plot as
other software does. As far as I can tell, none of the permutations
of the factors does this, and that is why I said anovaplot is for
between subjects designs only, or as the help says with maybe one
covariate. My query was as much to Diego, who seemed satisfied with
his use of -anovaplot- in a repeated measures context. I was just
curious what his final plot looked like and from what model.

On Apr 26, 2009, at 12:14 PM, Nick Cox wrote:

You use it the way you expect to be most fruitful.

I'm not minded to go upstream and find out what the example is
about, or
learn enough about the subject-matter to make a guess at what
should be
most helpful.

But the default -anovaplot- has no inbuilt intelligence. It's likely
that some permutation of the factors improves on the default plot,

anovaplot s a b

A simple but important issue is that whenever identifiers are quite
arbitrary, putting them on one axis may not yield a clear picture. It
may be worth re-labelling identifiers to make structure clearer.

David Airey

I always use it for between subjects ANOVAs. Perfect for that.

The key thing in my response is that _I_ have not been satisfied with
my use in within subject designs or mixed models.

Maybe I was not using it correctly. Let's use an example from UCLA
ATS, so that I can get it as correctly intended.


just focusing on the ANOVA aspects of the page, let's do:

use, clear
anova y a / s|a b a*b /, repeated(b)

How do you use -anovaplot- here?

On Apr 26, 2009, at 11:26 AM, Nick Cox wrote:

2.1.1 is the latest publicly available version.

-anovaplot- plots observed and fitted values after -anova- in
terms of
predictor levels.

It's a bit surprising to hear that you never found that useful. What
you do instead?

A while back I went carefully through various classic texts on ANOVA from the 1950s. As I recall none of them included any plots based on

David Airey

I never found -anovaplot- useful for anything but between subject
designs. I'd be curious to see the repeated measures plots using -

Is the version on SSC not the latest?

I have

. which anovaplot
/Users/dairey/Library/Application Support/Stata/ado/plus/a/
*! 2.1.1 NJC 6 November 2004

On Apr 26, 2009, at 10:52 AM, Nick Cox wrote:

Thanks to Diego for this interesting question and to Thomas for
answering it so fully.

To fill in a gap and to fill out the implicitly needed discussion:

-anovaplot- is a program in the -modeldiag- package written up in
Stata Journal within

SJ-4-4  gr0009  . . . . . . . . . . Speaking Stata: Graphing model
   . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
   (help anovaplot, indexplot, modeldiag, ofrtplot, ovfplot,
   qfrplot, racplot, rdplot, regplot, rhetplot, rvfplot2,
   rvlrplot, rvpplot2 if installed)
   Q4/04   SJ 4(4):449--475
   plotting diagnostic information calculated from residuals
   and fitted values from regression models with continuous

There's also an equivalent package on SSC that includes older
of these programs.

The paper is accessible to all via

-anovaplot- is described on p.458. I add this comment, which is
to Diego's question:

"It is curious that analysis-of-variance people typically draw
interaction plots but suppress the data, whereas regression people
prefer to draw scatterplots showing both observed and fitted
Admittedly, a complicated set of crossing lines showing
seem to leave little scope for showing data effectively, while a
simple regression leaves plenty of scope, but the difference is
nevertheless intriguing."

I still treasure a comment made by a senior Stata user, who might
want to be named for this, to the effect that showing the data on
graph typically confuses the issue.

Nevertheless I'll think about adding a -nodata- option, possibly
with a
sting in the tail. (For example, it might -drop- all your data, or

Thomas Steichen

Although you have suppressed printing a symbol for the data points
-scatter(msym(none))-, Stata still allows room for that invisible
in its y-axis range. Therefore you cannot reduce the range given
the code is written. Editing the code to allow what you want is

Change line:
           numlist "2/`= 1 + `: word count `fits'''"
           numlist "1/`= 1 + `: word count `fits'''"

And line:
       twoway scatter `y' `x1' if e(sample), `scatter' ///
       twoway `scatter'  ///

Then edit line:
program anovaplot, sort
program anovaplot0, sort

Save it with new name anovaplot0.ado and invoke it with command

Nick Cox's original will keep working and you'll have this one for

Of course, you could get fancy and add a -nodata- option that
both forms in a single program.

Diego Bellavia

I am trying to plot an ANOVA for repeated measures model using the
amazing anovaplot command.
Everything works fine except the yscale range. I need to reduce the
range and increase the scale
to make differences clear. So I tried:

anovaplot level groups, scatter(msym(none)) yscale (range(-12 -24))
ylabel(-12 (2) -24)

The problem is that I actually reduced the numbered range and the
labelling but now almost half of the graph
is empty. Is there any way to change the range so that I can take
advantage of all the graph extension ?

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index