|
Hi Marta,
Thanks very much for your information and for the syntax. I tend to use
syntax or GUI depending on what I'm doing, so will have a good look at the
syntax you have sent.
If this doesn't take up too much time, would you be able to give me a
brief description of (a)the Cochran test and (b) the Cochran-Armitage test
that you mentioned. Nothing in-depth, but I'm just interested to know how
they differ since you mentioned that they are very different. I've had a
look around but can only seem to find info on the Cochran-Armitage test.
Best wishes.
Lou
On Thu, 18 May 2006 12:36:04 +0200, =?ISO-8859-1?B?
TWFydGEgR2FyY+1hLUdyYW5lcm8=?= <biostatistics@terra.es> wrote:
>Hi Lou
>
>CB> My data is as you have described it (i.e. I know the number of
>CB> people who did and did not take the test), so I will give the
>CB> Cochran test a go.
>
>I insist: please address your questions to the whole SPSS list, not to
>me only (other people might benefit from the information, and, also,
>sometimes my mail server - Terra - marks legitimate mail as junk, and
>stores it in a web folder I forget to watch, and your message could be
>lost & left unreplied).
>
>Now, I have to apologyze for an error that reversed the sense of my
>last message to you. It was late and I had worked a lot, my brain was
>quite slow ;)
>
>Where I said:
>
>MGG> I hope you are not working with aggregated data (I mean, I hope
>MGG> you don't have the individual data, but only the number of people who
>MGG> undertook or not the test...).
>
>I SHOULD have said
>
>MGG> I hope you are not working with aggregated data (I mean, I hope
>MGG> you have the individual data, not only the number of people who
>MGG> undertook or not the test...).
>
>Since you say you only have the aggregated data, you have lost the
>matching information, and Cochran test can't be done. You'll have to
>assume independent data (it can shift your results towards non
>significance) and use Cochran-Armitage test (name is quite close, but
>test is VERY different).
>
>Marta
>
>----------------------------------------------------------------------
>
>Do you use syntax or GUI? If you are "fluent" with syntax, then you can
>adapt the following code to your data:
>
>**************************************************
>* COCHRAN-ARMITAGE TEST FOR TREND *
>**************************************************
>* Ref: Alan Agresti (2002), Categorical Data *
>* Analysis (2nd Ed), pp 181-2, John Wiley & Sons *
>**************************************************
>* (c) Marta Garcia-Granero (september 2005) *
>* biostatistics@terra.es *
>* Feel free to use or modify this code, but *
>* acknowledge the author *
>**************************************************
>
>* Dataset #1: scoring is OK (example provided with SAS at:)
>
(http://www.id.unizh.ch/software/unix/statmath/sas/sasdoc/stat/chap28/sect4
0.htm)
>* (SAS results):
>* Statistic (Z) 4.7918
>* Asymptotic Test
>* One-sided Pr < Z <.0001
>* Two-sided Pr > |Z| <.0001
>* Sample Size = 161
>
>DATA LIST LIST/dose adverse count (3 F8.0).
>BEGIN DATA
>0 1 26
>0 2 6
>1 1 26
>1 2 7
>2 1 23
>2 2 9
>3 1 18
>3 2 14
>4 1 9
>4 2 23
>END DATA.
>VALUE LABEL adverse 1'No' 2'Yes'.
>WEIGHT BY count .
>
>* Using SPSS linear by linear test (close enough) *.
>CROSSTABS
> /TABLES=dose BY adverse
> /FORMAT= AVALUE TABLES
> /CELLS= COUNT ROW
> /STATISTIC=CHISQ.
>
>* Cochran-Armitage test with MATRIX *.
>
>* This code assumes the dependent variable is coded 0/1 (No/Yes) *.
>TEMPORARY.
>COMPUTE adverse=adverse-1.
>AGGREGATE
> /OUTFILE = 'c:\temp\aggdata.sav'
> /BREAK = dose
> /pi = MEAN(adverse)
> /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 (change if required) *.
>COMPUTE xi={0; 1; 2; 3; 4}.
>* 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.
>
>* As you can't specify scores for CROSSTABS, the key is recoding
>* the predictor to asign the scores you want. Suppose your data
>* don't reflect the scoring you want to give *.
>
>* Dataset #2 (Agresti 2002) *.
>DATA LIST LIST /alcohol malform count (3 F8.0).
>BEGIN DATA
>0 1 48
>0 0 17066
>1 1 38
>1 0 14464
>2 1 5
>2 0 788
>3 1 1
>3 0 126
>4 1 1
>4 0 37
>END DATA.
>
>VALUE LABEL alcohol
> 0 ' 0'
> 1 '<1'
> 2 '1-2'
> 3 '3-5'
> 4 '>6'.
>VALUE LABEL malform 0'Absent' 1'Present'.
>WEIGHT BY count .
>
>* Agresti gives the following scores: 0, 0.5, 1.5, 4, 7 *.
>
>* The following will not give the results expected (Z˛=6.57 p=0.010): *.
>
>CROSSTABS
> /TABLES=alcohol BY malform
> /FORMAT= AVALUE TABLES
> /CELLS= COUNT ROW
> /STATISTIC=CHISQ. /* LxL test is 1.828 (p=0.176)*.
>
>* Recoding and re-running *.
>TEMPORARY.
>RECODE alcohol (0=0) (1=0.5) (2=1.5) (3=4) (4=7) INTO alcscore .
>VARIABLE LABELS alcscore 'Scores for alcohol'.
>* Using SPSS linear by linear test (close enough) *.
>CROSSTABS
> /TABLES=alcscore BY malform
> /FORMAT= AVALUE TABLES
> /CELLS= COUNT ROW
> /STATISTIC=CHISQ. /* LxL is now 6.570 *.
>
>* Cochran-Armitage test with MATRIX *.
>
>* This time, MALFORM takes the correct values (0/1) *.
>AGGREGATE
> /OUTFILE='c:\temp\aggdata.sav'
> /BREAK=alcohol
> /pi = MEAN(malform)
> /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 (change if required) *.
>COMPUTE xi={0; 0.5; 1.5; 4; 7}.
>* 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.
|