Running a Tukey HSD test (and the like) after an ANOVA
Oftentimes, the ANOVA itself is not enough to satisfy your research questions. One way of looking at the nuances of your ANOVA is with a Tukey test. While Stata does not have a simple Tukey test command built-in, a few easy steps will download a user-created one that works just as well.
Assuming you have not already installed the command, type findit tukeyhsd
into the Command window. Scroll down to the bottom of the search page, and the only package result will appear in blue. Click the blue link, then click the blue click here to install link. If you do not already have them installed, you will need to do install sg101 via the same process (findit sg101
). Once you have installed sg101, you can also findit tkcomp
(to find and install the Tukey-Kramer test package) or findit fhcomp
(to find and install the Fisher-Hayter test package). All are similar, though the way they calculate degrees of freedom (and therefore critical values) differs and (according to the UCLA website) the latter two may be preferred in the case of unequal cell sizes. The options explored below are identical for all three tests.
Once installed, first run your ANOVA and then the command is tukeyhsd [variable]
.
Additionally, you can set a p-value via the level()
option, or you can look at levels of one variable, restricted to one level of the other independent variable by the if
suffix. See the below example for more details.
For the purposes of this example, accept the following: I ran an experiment looking at whether or not puppies influence happiness. I have a control group (no dogs or puppies, condition=1), an experimental group with full grown dogs (condition=2) and a second experimental group of just puppies (condition=3). Additionally, I have the participants split into two groups, those who consider themselves dog people (selfident=0) and those who consider themselves cat people (self-ident=1). The dependent variable is happiness (named happy) In this case, all variables are between subjects. I run the ANOVA via anova happy selfident condition
and achieve a significant result for condition, as well as over all. Since there were three conditions, I'm now curious which ones differed. Therefore I run a tukeyhsd condition
which yields the following output:
So though conditions 1 and 2 did not differ, condition 3 (just puppies) differed from both of the other conditions. Now, I might become curious if these effects were smaller for self-identified cat people, so to just look at "cat people." The command would be tukeyhsd condition if selfident==1
and it is up to you to remember what you are looking at (as the output will not note the difference).