Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Pairwise comparisons repeated ANOVA

From   Joseph Coveney <>
To   Statalist <>
Subject   Re: st: Pairwise comparisons repeated ANOVA
Date   Wed, 09 Apr 2003 19:57:52 +0900

Sven-Erik Johansson posted: "Is there any option or STB available for pairwise 
comparisons in an oneway ANOVA with repeated measurements?"

George Hoffman suggested prcomp, but it seems to assume independent samples, not 
paired observations.

I think that the most commonly recommended way (see, for example, or passim) is to perform paired 
Student's t-tests, since this assures that the correct covariance is used for each 
comparison, something that cannot always be assured with a pooled error term from the 
repeated-measures analysis of variance table.  Adjustments for multiple testing can 
then be done with -_mtest- (see -help undocumented-).  I've illustrated the technique in 
the do-file below using a dataset from B. J. Winer, D. R. Brown and K. M. Michels, 
_Statistical Principles in Experimental Design_. Third Edition. (New York:  McGraw-Hill, 
1991), p. 228.  In the illustration, I happen to use Holm's method for multiple 
As an alternative, although I'm not sure what advantage there would be over multiple 
paired Student's t-tests, Sven-Erik could use -manova- in conjuction with -manovatest, 
ytransform()-s with the pairwise contrasts specified in transformation matrixes.  
Adjustment for multiplicity would still be in order.

Joseph Coveney


set more off
infile byte rctime1 byte rctime2 byte rctime3 byte rctime4 using ///
preserve // Displaying the omnibus randomized-blocks ANOVA
generate byte person = _n
reshape long rctime, i(person) j(drug)
anova rctime drug person, repeated(drug) // Note epsilons as index of sphericity
restore // Individual comparisons begins next
matrix A = J(1, 3, 0)
local testno = 0
forvalues i = 1/3 {
    local j = `i' + 1
    forvalues k = `j'/4 {
        quietly ttest rctime`i' = rctime`k'
        matrix B = (`i', `k', r(p))
        if `testno' == 0 {
            matrix A = B
        else {
            matrix A = A \ B 
        local rownamesA = "`rownamesA'" + "testpair`++testno' "
matrix rownames A = `rownamesA'
matrix colnames A = onedrug otherdrug unadjustp
_mtest adjust A, mtest(holm) pindex(3) append
matrix list r(result)


*   For searches and help try:

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