View Single Post
  #3   Report Post  
Jerry W. Lewis
 
Posts: n/a
Default anova post-hoc analysis: tukey test

Tukey did a lot of things. In the context of ANOVA, I will assume that you
mean his single degree of freedom to test for non-additivity.

You are correct that Excel has no native function to do this. Moreover, the
calculations do not lend themselves easily to an array formula. However it
is not difficult to write a UDF to do the calculations. The following UDF
assumes that you have complete data arranged in rows and columns (for
example, treatments and blocks). You pass that rectangular array of data to
the function, as in
=Tukey1df(A1:C5)
to get the p-value for non-additivity. Other components of the ANOVA are
identified by comments in the code.

If you are using an early version of Excel that does not support the
WorksheetFunction keyword, then replace WorksheetFunction with Application
and the code should work.

Jerry

Function Tukey1df(y)
Dim rAveD(), cAveD() ' arrays of deviations of row/column averages
from grand mean
Dim r As Long, c As Long, dfe As Long, i As Long, j As Long, _
Ave As Double, denom1 As Double, denom2 As Double, _
SSr As Double, SSc As Double, SSTukey As Double, SStot As Double,
MSe As Double, FTukey As Double
r = y.Rows.Count
c = y.Columns.Count
If Application.Count(y) < r * c Then Tukey1df = [#VALUE!]: Exit Function
ReDim rAveD(1 To r), cAveD(1 To c)
Ave = WorksheetFunction.Average(y)
denom2 = 0
For j = 1 To c
cAveD(j) = WorksheetFunction.Average(y.Columns(j)) - Ave
denom2 = denom2 + cAveD(j) ^ 2
Next j
denom1 = 0
SSTukey = 0
For i = 1 To r
rAveD(i) = WorksheetFunction.Average(y.Rows(i)) - Ave
denom1 = denom1 + rAveD(i) ^ 2
For j = 1 To c
SSTukey = SSTukey + y(i, j) * rAveD(i) * cAveD(j)
Next j
Next i
SSTukey = SSTukey ^ 2 / denom1 / denom2 ' SS for non-additivity
SSr = WorksheetFunction.DevSq(rAveD) * c ' SS for rows
SSc = WorksheetFunction.DevSq(cAveD) * r ' SS for columns
SStot = WorksheetFunction.DevSq(y) ' SS for (corrected) total
dfe = (r - 1) * (c - 1) - 1
MSe = (SStot - SSr - SSc - SSTukey) / dfe ' MS for error (residual)
FTukey = SSTukey / MSe ' F for non-additivity
Tukey1df = WorksheetFunction.FDist(FTukey, 1, dfe) ' p-value for
non-additivity
End Function


"Ross" wrote:

excel does not have such a built-in function so i tried analyse-it and
INERST13.XLS from web. both don't have any clear instructions how the
dataset should be input. is anybody knowing how to best perform such a test
in Excel? thx in advance!!