Re: cochran armitage test

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: cochran armitage test

Marta García-Granero
Hi Srujana

Monday, May 7, 2007, 6:45:35 AM, You wrote:

sb> sir,

OK, second time (it is not really important. but...) MADAM instead of
SIR, please.

First of all, I like to be reached thru the SPSS list, since my
anti-SPAM filters are quite rude with any message not belonging to any
email registered at my friends list (or flagged as coming from SPSS
list). Besides, other people might be interested in the thread.

Now, concerning your questions:

sb>         can u send me the basic concepts of caochran armitage test with formulas
sb>          iam a student in the field of biotechnology.so dont
sb> have much knowledge in statistics.because u gave that values i
sb> thought u might be knowing how u did it manually.so asked u for
sb> it. this was the article which iam trying to understand and
sb> substitute ur values.so u also try and if suceed in it.plz tell me
sb> also.

Again, first (unasked for, but anyway I'm going to say it):

Before attempting to use any statistical test, you need some
theoretical background. If you are going to need statistics for your
work, then learn the basics. It is not very wise to use a test without
knowing why it is adequate (is it, by the way?) or how it works. I can
recommend you a good online book: Statistics at Square One (at BMJ web
site) with its accompanying SPSS syntax (at King Douglas Web site):

The book: http://www.bmj.com/collections/statsbk/

The syntax:
http://www.kingdouglasconsulting.com/SPSS/DiverseCultures/Marta/Code/BMJ%20-%20Stats%20Square%20One.txt

(you can visit King's webpage, find a pictore of me -there are
several- and verify that I'm in fact a woman, BTW)

Next: are you really sure C-A test is really what you need? Be sure of
that before going on. The 1955 Armitage paper you sent to me (thanks a
lot, I didn't have that classic jewel) discusses other alternatives:
linear-by-linear trend and Kendall's tau (both are available with SPSS
using CROSSTABS). Did anybody tell you that you should use it, or did
you read a paper that used it and jumped to the conclusion that it
would be suitable for your needs? Think a bit about your research
question (you don't give me a clue about that) and then select the
statistical tool more appropriate for it.

Now, at last: I have adapted the code that gave you problems, and tunt
it into a more user-friendly MACRO. Finally, as an example I have used
Armitage paper sample dataset to test it (it seems to me that you
asked me to do that, am I right?)

**************************************************
*        COCHRAN-ARMITAGE TEST FOR TREND         *
**************************************************
* Ref: Alan Agresti (2002), Categorical Data     *
* Analysis (2nd Ed), pp 181-2, John Wiley & Sons *
**************************************************
* (c) Marta Garcia-Granero (may 2007)            *
* [hidden email]                         *
* Feel free to use or modify this code, but      *
* acknowledge the author                         *
**************************************************

* MACRO definition (run this part only once) *.
DEFINE CATREND(!POS=!TOKENS(1)
              /!POS=!TOKENS(1)
              /!POS=!CMDEND).
AGGREGATE
  /OUTFILE = 'C:\Temp\Aggdata.sav'
  /BREAK = !2
  /pi = MEAN(!1)
  /ni = N.
MATRIX.
PRINT/TITLE='Cochran-Armitage Test for Trend (Agresti 2002)'.
GET pi /VAR=pi /FILE='C:\Temp\Aggdata.sav'.
GET ni /VAR=ni /FILE='C:\Temp\Aggdata.sav'.
* Scoring *.
COMPUTE xi=!3.
* Reports *.
PRINT {xi,ni&*pi,ni}
 /FORMAT='F8.1'
 /TITLE='Statistics'
 /CLABELS='Score i','Count i','N i'.
PRINT MSUM(ni)
 /FORMAT='F8.0'
 /TITLE='Total sample size'.
* Calculations *.
COMPUTE p=MSUM(ni&*pi)/MSUM(ni).
COMPUTE x=MSUM(xi&*ni)/MSUM(ni).
COMPUTE num=(xi-x)&*ni&*pi.
COMPUTE den=p*(1-p)*ni&*((xi-x)&**2).
COMPUTE z=MSUM(num)/SQRT(MSUM(den)).
COMPUTE zsig=2*(1-CDFNORM(ABS(z))).
* Final report *.
PRINT {z,z**2,zsig,zsig/2}
 /FORMAT='F8.3'
 /CLABELS='Z','Z²','2-sig','1-sig'
 /TITLE='Statistics & Significance'.
COMPUTE observed={(ni-ni&*pi),ni&*pi}.
COMPUTE expected=RSUM(observed)*CSUM(observed)/MSUM(ni).
COMPUTE chisq=MSUM((observed-expected)&**2/expected).
COMPUTE chisqp=1-CHICDF(chisq,NROW(observed)-1).
COMPUTE reschi=chisq-z**2.
COMPUTE reschip=1-CHICDF(reschi,NROW(observed)-2).
PRINT {chisq,chisqp;reschi,reschip}
 /FORMAT='F8.3'
 /RLABELS='Pearson','Deviat.'
 /CLABELS='Chi²','Sig.'
 /TITLE='Pearson-Chi² & Deviation from trend (non-linearity)'.
END MATRIX.
!ENDDEFINE.

* Sample dataset (Table 1 of "Tests for Linear Trends in Proportions
* and Frequencies" P. Armitage. Biometrics, Vol. 11, No. 3. (Sep., 1955),
* pp. 375-386.

* Warning: response variable ("Carrier" in this example) must be 0/1 coded!!! *.
DATA LIST LIST/Tonsils Carrier Counts (3 F8).
BEGIN DATA
1 1  19
1 0 497
2 1  29
2 0 560
3 1  24
3 0 269
END DATA.
WEIGHT BY Counts.
VAR LABEL Tonsils 'Size of tonsils'/
          Carrier 'Nasal carrier status for S. pyogenes'.
VAL LABEL Tonsils 1'+' 2'++' 3'+++'/
          Carrier 0'Non-carrier' 1 'Carrier'.
VAR LEVEL Tonsils Carrier (ORDINAL).

* Using SPSS tools only *.

CROSSTABS
  /TABLES=Tonsils  BY Carrier
  /FORMAT= AVALUE TABLES
  /STATISTIC=CHISQ CTAU
  /CELLS= COUNT ROW.

* MACRO call for this dataset: response variable goes first, then the grouping variable,
  then the scores between curly brackets (ie: braces) and separated by semi-colons *.

CATREND Carrier Tonsils {-1; 0; 1}.


Regards,
Dr. Marta García-Granero,PhD           mailto:[hidden email]
Statistician