Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: RE: Need help making an ado for Tamhane test

From   "Lythgoe, Dan" <>
To   "''" <>
Subject   st: RE: Need help making an ado for Tamhane test
Date   Fri, 31 May 2013 07:28:15 +0000

Hi Marta,

I'm no expert myself but -help syntax- will set you in the right direction.


Dan Lythgoe

-----Original Message-----
From: [] On Behalf Of Marta García-Granero
Sent: 31 May 2013 08:22
Subject: st: Need help making an ado for Tamhane test

Hi everybody:

Since I come from the SPSS programming world, my understanding of Stata programming is somewhere between nil and zero. Anyway, I have attempted
(perpetrated?) to write some code for Tamhane's T2 multiple comparison of means with heterogeneous variances. The method is rather simple, it consists simply in unequal variances (Satterthwhite's method) t tests with Sidak adjustment of p-values.

Right now, the code is rather automatic: it calculates the number of groups (assuming they are numbered starting from 1, and without gaps), number of comparisons, cycles through all the pairwise comparisons, and adjusts the two-tailed p-values.

qui sum Status,meanonly
local comp=r(max)*(r(max)-1)/2
qui levelsof Status,local(levels)
foreach i of local levels{
     foreach j of local levels{
         if `i'<`j'{
         quietly ttest Hb if (Status==`i')|(Status==`j'), by(Status) unequal
         display `i' " " _c
         display "vs "`j' "    " _c
         display  %6.4f 1-(1-r(p))^`comp'

To avoid having to edit it every time I want to use it, to replace "Hb" 
by the dependent variable name and "Status" by the grouping variable, I would like to turn it into a program, like this:

tamhane Hb, by(Status)

Unfortunately, I have hit the ceiling of my knowledge in Stata programming as it is right now. In a future I want to add some more output, like mean differences, standard error and the adjusted confidence intervals for mean differences, but I think that would be easy, since most of the information is available as r(something) (with the exception of the confidence limits, that should be computed using the t value for the Satterthwhite's df).

Any hints (or directions concerning where to look for information)?

Thanks in advance.

Marta García-Granero
Dpt. of Biochemistry and Genetics
University of Navarra
*   For searches and help try:

*   For searches and help try:

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