# st: RE: ...non parametric alternative to ANOVA...

 From "Nick Cox" To Subject st: RE: ...non parametric alternative to ANOVA... Date Sat, 3 Apr 2004 18:24:36 +0100

```It seems to me that this raises two large questions:

1. Whether there is some non-parametric method for
two-way ANOVA that handles interaction. In particular,
my understanding is that Friedman's procedure does not
extend to interactions.

2. Assuning an answer to 1, whether there is some
Stata implementation. I am not aware of one.

Rich Goldstein did a Friedman program in STB-3
in 1991. It still works, except that it assumes that
you have no variables whose names begin with "r".
If you have, the result will be wrong and they
will get -drop-ped.

I modernised the code as below. This has not been
tested much at all. But it doesn't do interactions
either.

*! 2.0.0 NJC 3 April 2004
*! 1.01 Richard Goldstein 17 July 1991
program friedman8
version 8
syntax varlist(min=2 numeric) [if] [in]

quietly {
marksample touse
count if `touse'
if r(N) == 0 error 2000
else local n = r(N)
local k : word count `varlist'

tempvar ranksum rankss
gen `ranksum' = 0 if `touse'
foreach v of local varlist {
tempvar rank
egen `rank' = rank(`v') if `touse'
replace `ranksum' = `ranksum' + `rank'
drop `rank'
}

gen `rankss' = `ranksum'^2
su `rankss', meanonly

local S = `r(sum)' - (((`k'^2) * `n' * (`n' + 1)^2) / 4)
local F = (12 * `S') / (`k' * `n' * (`n' + 1))
local W = (12 * `S') / ((`k'^2) * `n' * (`n'^2 - 1))
local prob = `k' * (`n' - 1) * `W'
}

di "{txt}Friedman = {res}" %8.4f `F'
di "{txt}Kendall =  {res}" %8.4f `W'
di "{txt}P-value =  {res}" %8.4f chiprob(`n' - 1, `prob')
end

Nick
n.j.cox@durham.ac.uk

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of
> fabiopericolini@fastwebnet.it
> Sent: 03 April 2004 04:38
> To: stata group mail
> Subject: st: ...non parametric alternative to ANOVA...
>
>
> Dear all,
> someone can tell me something about the non parametric
> alternatives to two-way
> ANOVA in Stata. I have to discover/investigate if a
> distribution is influenced
> by the interaction of two factors, I had just applied the
> kwallis test to
> the distribution with a combined factor of the two factor
> (combined factor=
> group (factor1 factor2) with good results but I think that
> this test doesn't
> go where I wish to go.
> Every opinion will be welcome.
> Many thanks.
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```