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

st: Binomial Sign Test for Two Dependent Samples


From   Thomas Speidel <[email protected]>
To   [email protected]
Subject   st: Binomial Sign Test for Two Dependent Samples
Date   Fri, 14 Jan 2005 15:18:53 -0700

I am trying to create little program for a "Binomial Sign Test for Two Dependant Samples".
This test is somewhere between a signrank test and a binomial. The computations are fairly simple:

1. Find the differences among the pairs
2. Ignore all null differences
3. Count the number of non-zero, non-missing differences (i.e. n)
4. Count the number of positive differences (call it x)
5. Compute: Binomial(n, k, 0.5)

I am trying to implement this into a little program so that I can loop it through a number of variables/groups. However, because I am not an expert programmer, I came to a roadblock... Following is a sample of my data:

NOTE: *posneg: is the sign of the difference (i.e. 0=no difference; 1=Positive; -1=Negative)
+--------------------------------------------------+
|liverid group mp1posneg mp2posneg mp3posneg|
|--------------------------------------------------|
| 929444 1 0 -1 -1 |
| 948579 1 -1 0 -1 |
| 953012 1 -1 0 -1 |
| 956482 1 -1 0 -1 |
| 986833 1 . . . |
| 9314571 1 . . . |
| 9314751 1 . -1 . |
| 9413243 1 -1 -1 -1 |
| 9510420 1 . . . |
| 9613027 1 . . . |
| 9614920 1 -1 0 -1 |
| 9820601 1 -1 0 -1 |
| 9821645 1 0 0 -1 |
| 9912795 1 0 0 -1 |
|--------------------------------------------------|
| 12896 2 0 0 -1 |
| 94787 2 . -1 0 |
| 98613 2 . 0 . |
| 111381 2 . 0 -1 |
| 936134 2 0 0 0 |
| 969968 2 . -1 . |
| 991853 2 . . . |
| 9617199 2 -1 0 -1 |
| 9810799 2 . 0 -1 |
|--------------------------------------------------|
| 9338 3 . -1 . |
| 953132 3 -1 -1 -1 |
| 954005 3 -1 -1 -1 |
+--------------------------------------------------+

I am trying to find the binomial for each variable by group
This is what I have thus far, but does not work:

foreach x of var mp1posneg mp2posneg mp3posneg {
foreach i in 1 2 3 {
qui count if `x'posneg==1 & group == `i'
local pos_`i'`x' = r(N)
qui count if `x'posneg==1 | `x'posneg==-1 & group == `i'
local n_`i'`x'=r(N)
display Binomial(n_`i'`x', pos_`i'`x', 0.5)
}
}



Thanks,
Thomas




This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.
*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index