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

Re: st: Kwallis in a loop [now p-value of the Kwallis]


From   "Herve STOLOWY" <stolowy@hec.fr>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Kwallis in a loop [now p-value of the Kwallis]
Date   Sun, 06 Nov 2005 21:37:46 +0100

Dear Kit:

Thanks again for your help. I applied your suggestion and it works. The principle of the loop is fine.

I have a new question concerning how to get the p-value of the kwallis test.

Here is my loop:

local action replace
foreach var of varlist index2 prov_ass {
egen rank_`var' = rank(`var') if sodas3cl < . 
bysort sodas3cl : egen ranksum_`var' = sum(rank_`var') 
by sodas3cl : egen rankmean_`var' = mean(rank_`var') 

statsmat `var', s(N) by(sodas3cl) mat(m1)
tabstat rankmean_`var', by(sodas3cl) save
tabstatmat m2
matrix m3 = m1,m2
statsmat rankmean_`var', s(N 0) mat(m4)
matrix m5 = m3\m4
makematrix m6, from(r(chi2_adj) formula to add) label : kwallis `var', by(sodas3cl)
matrix m7 = m5\m6
mat2txt, matrix(m7) saving(table5) `action'
local action append
}

As the p-value of the test is not returned as a scalar, I learnt from prior postings to the list that I should add the relevant formula. For the Mann-Whitney U test, I know that the formula is: 2*normprob(-abs(r(z))).

Unfortunately, I don't know the right formula for the Kwallis test. I searched in the kwallis ado file but don't find it. I certainly miss it.

Best regards

Herve

***********************************************************
Professeur/Professor
Coordinateur du Département/Head of Department
HEC Paris
Département Comptabilité Contrôle de gestion / Dept of Accounting and Management Control
1, rue de la Liberation
78351 - Jouy-en-Josas
France
Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
stolowy@hec.fr
http://campus.hec.fr/profs/stolowy/perso/home.htm
>>> baum@bc.edu 11/06/05 7:42 PM >>>
Herve said

foreach var of varlist index2 prov_ass {
egen rank_`var' = rank(`var') if sodas3cl < .
bysort sodas3cl : egen ranksum_`var' = sum(rank_`var')
by sodas3cl : egen rankmean_`var' = mean(rank_`var')

tabstat rankmean_`var', by(sodas3cl) save
tabstatmat statdes3
mat2txt, matrix(statdes3) saving(statdes3) append

}

My problem is the following:

At the end of the loop, the first time, I should have -replace- and  
the subsequent times -append-. I don't know how can I make Stata  
understand this difference in a loop.


local action replace
foreach ... {

mat2txt. ... `action'
local action append
}

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html


*
*   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/



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