Opens in a new tab

One-Way ANOVA in Stata
Commands, Bartlett's Test and Effect Size Output

One-way ANOVA in Stata gives an F test from oneway or anova, a Bartlett line that is easy to over-read, and follow-up tools that live in other commands. A report that names its adjustment and its effect size has to draw on more than one block of output.

What You'll Need
Stata with the dataset open
A do-file or a blank editor
A continuous outcome measure

IN SHORT

What oneway Reports and What Needs Another Command

A one-way ANOVA tests whether three or more independent groups share one mean on a continuous outcome, and it indicates how much of the outcome’s variation the grouping explains. To run an ANOVA in Stata with one grouping factor, type oneway followed by the outcome and the grouping variable. The F test and Bartlett’s test for equal variances are printed together, while pairwise comparisons come from pwmean or pwcompare and eta-squared from estat esize after anova. OnlineSPSS, a specialist statistical consultancy for academic, clinical and professional research, carries out and reviews this analysis through an in-house PhD-level statistician.

In This Guide

1
Confirm the Data Layout
2
Inspect Spread by Group
3
Run oneway With Tabulate
4
Request Adjusted Comparisons
5
Refit With anova for Eta-Squared
6
Save the Do-File and Log

ANALYSIS SUPPORT

Analysis Support for This Method

The model is simple, but its follow-ups are spread across commands. An ordinal outcome may call for a rank-based comparison, while sharply unequal spread points to a test of means that does not assume equal variances.

One-Way ANOVA

Group means compared with the omnibus test, adjusted comparisons and an effect size with its interval, set out for your design and the output it produces.

Explore One-Way ANOVA
Kruskal-Wallis Test

A rank-based comparison of three or more groups, suited to an ordinal outcome or to one where the mean is a poor summary.

Explore Kruskal-Wallis Test

BEFORE YOU RUN IT

What the oneway Output Takes for Granted

None of the following shows up in the output itself: how the groups are coded, whether rows are independent, how unequal spread is handled and which comparisons were planned.

A Labeled Grouping Variable The grouping variable is a numeric code with one value per group and value labels attached, so the comparison tables name the groups instead of listing 1, 2 and 3.

Independent Rows Each participant sits in one group on one row. Repeated measurements or clustered participants call for a different model, and the group sizes are tabulated first.

A Plan for Unequal Spread Bartlett's test is sensitive to departures from normality, so it is a poor gatekeeper. How unequal spread will be handled is decided from the design and the group sizes.

Comparisons Chosen in Advance Decide whether all pairs or each group against a control are of interest, since the adjustment and the number of comparisons follow from that choice.

IN STATA

How to Run a One-Way ANOVA in Stata

The oneway command in Stata and the anova command are both part of official Stata and fit the same model, and the follow-ups below depend on which of the two was run.

1

Confirm the Data Layout

Check that the outcome sits in a single continuous variable, the groups in a numeric variable with value labels, and that no participant appears on two rows.

Check: Run tabulate on the grouping variable first. A group with very few rows, or one that is absent altogether, changes which comparisons can be made before any F test is read.

2

Inspect Spread by Group

Plot the outcome by group to compare spread, skew and outliers.

Watch: Compare spread and outliers by eye before reading any p-value. A box plot makes unequal spread and extreme values visible in a way that Bartlett’s line alone does not.

3

Run oneway With Tabulate

Run oneway with the tabulate option to see the group means, the F test and Bartlett’s test.

Tip: The tabulate option prints each group’s mean, standard deviation and frequency above the test, so the n per group can be checked before the F test is read.

4

Request Adjusted Comparisons

Request adjusted pairwise comparisons with pwmean and an mcompare() method, or with the bonferroni, scheffe or sidak options of oneway.

Tip: Report each adjusted difference together with its interval from the pwmean table, not the p-value alone, so the reader sees how large the difference may be.

5

Refit With anova for Eta-Squared

Fit the model again with anova, then call estat esize for eta-squared with its interval.

Check: Compare the number of observations that anova reports with the total frequency from oneway. Both leave out rows with a missing outcome or group, so the counts should agree.

6

Save the Do-File and Log

Save the commands in a do-file and keep the log, so the whole analysis can be rerun and the printed output stays beside it.

Tip: Open a log with log using before the first command and close it with log close at the end, so that the printed output is stored next to the do-file that produced it.

Stata Commands
graph box outcome, over(group)
oneway outcome group, tabulate
pwmean outcome, over(group) mcompare(tukey) effects
anova outcome group
estat esize

READING THE OUTPUT

Reading the oneway Block and Its Follow-Ups

oneway prints one block with the F test and Bartlett's line, and the comparisons and the effect size appear only when their own commands are run.

Output element What it tells you What to check
Summary table (tabulate option): Mean, Std. dev., Freq. Group means, spread and sizes That Freq. matches the intended n per group
Analysis of Variance: Between groups The variation attributed to the grouping, with its df and mean square That df equals the number of groups minus one
Analysis of Variance: Within groups The residual variation, with its df That df reflects the participants analyzed, after missing values
F and Prob > F The omnibus statistic and its p-value That it is reported as evidence that some means differ, not as evidence of which ones
Bartlett’s line under the table (wording varies by release) A chi-square test of equal variances That it is not used to pick between versions of the test, since it is sensitive to non-normality
Comparison matrix headed Row Mean-Col Mean Mean differences with adjusted p-values for the method requested That the adjustment named in the text is the one requested
pwmean contrast table Pairwise differences with intervals, adjusted only when mcompare() is given That an adjustment was requested, because the default is no adjustment
estat esize output Eta-squared with a confidence interval from the noncentral F distribution That the measure named in the text is the one printed: eta-squared unless omega was requested

REPORTING

Reporting the F Test, the Comparisons and the Effect Size

Each part of the sentence has its own command, so the report is assembled from several places and not copied from a single block.

Report F(df between, df within) = ___, p = ___ from the Analysis of Variance block, then the group means and standard deviations. Add eta-squared = ___ with its 95% CI [___, ___] from estat esize in Stata, naming the measure, because the same command reports omega-squared when the omega option is added. Give the pairwise differences with the adjustment named, taken from the pwmean contrast table with its intervals. Say whether equal variances were assumed: the F from oneway assumes them, and its documented options include no Welch-type test, so where the spread differs a robust alternative is chosen separately and named in the methods.

F With Both dfEta-Squared With CIAdjustment NamedGroup Means and SDsVariance Assumption

COMMON MISTAKES

Command-Level Slips in a Stata One-Way Report

Because the work is divided between commands, the slips below arise at the joins, and the do-file shows each of them.

Bartlett as Gatekeeper Switching analyses according to Bartlett's p-value treats a test sensitive to non-normality as a rule, so the choice is justified from the design and the group sizes.

Unadjusted Pairwise Output pwmean without mcompare() prints unadjusted comparisons, so a table of many pairs can be reported as if the family-wise error had been controlled.

Effect Size After the Wrong Command estat esize is documented for linear models after regress or anova and not after oneway, so the model is refitted with anova before the effect size is requested.

Omnibus F Read as Group Differences A significant F says that some means differ, not which ones or by how much, so the sentence is followed by the adjusted comparisons and an estimate of size.

Unlabeled Group Codes Groups coded 1, 2 and 3 with no value labels leave the pairwise tables hard to read, so labels are attached before any comparison is run.

Eta-Squared Called Omega-Squared estat esize reports eta-squared by default and omega-squared only on request, so a text naming omega-squared beside the default value mislabels the measure.

Output in hand but the follow-ups unsettled? Independent Statistical Review weighs the adjustment and the effect size you chose against the design that produced the groups.

Request an Assessment

What's Next

Repeated measurements on the same people call for Repeated Measures ANOVA.
Comparing groups after adjusting for a baseline score leads on to ANCOVA.
Several predictors of one outcome are covered under Multiple Linear Regression.

FREQUENTLY ASKED QUESTIONS

Questions About ANOVA in Stata: oneway and Its Follow-Ups

The follow-ups for a one-way model are scattered across commands, which raises three practical questions: where adjusted comparisons come from, how to get an effect size and why two commands give one F.

No: oneway offers the bonferroni, scheffe and sidak options, so Tukey-adjusted comparisons come from pwmean, or from pwcompare after anova. The pwmean call with over(group), mcompare(tukey) and effects returns adjusted differences with their intervals. Without mcompare() the default is no adjustment, and both commands assume equal variances across groups.

Refit the model with anova and call estat esize, since the command works after regress or anova and not after oneway. It reports eta-squared with a confidence interval by default, and the omega option reports omega-squared instead. The F test is identical in both commands, so nothing in the main result changes by refitting.

Both fit the same model and give the same F and p-value, so the choice is practical. oneway adds Bartlett’s test, the tabulate option and three built-in multiple-comparison methods. anova supports pwcompare and estat esize and extends to further factors, so the two are often used together.

An in-house PhD-level statistician at OnlineSPSS can choose the adjustment for your group structure, run the commands on your data and prepare the do-file, or go through a model you have already fitted. The reporting stage belongs to Results Reporting & Interpretation, and what the comparisons mean for your field is yours to decide.

Your data and project details are handled confidentially, and project information is not published. Researcher names and institutions are not used publicly without permission. An NDA is available where required and can be arranged before sensitive materials are shared. Read more about confidentiality and data security.

You share your research question, design and relevant materials, such as the dataset or the output you have, and a statistically trained Research Coordinator reviews the request and responds the same day. The analysis, deliverables, timeline and one fixed project fee are then confirmed before any work begins, so the timeline follows from the agreed scope.

Still have a question? Find more answers in our full FAQ.

View All FAQs →

NEXT STEP

Which Comparisons Does
Your Design Call For?

The adjustment, the effect size and the treatment of unequal spread all follow from the group structure and the research question, and can be settled from a model already run or from the data alone.

No Commitment Required

Strictly Confidential

Fixed Project Fee

In-House PhD-Level Statisticians

Same-Day Response

Serving Researchers Since 2014