Date: Mon, 28 Jan 2008 23:56:03 -0500
Reply-To: Lisa Stickney <Lts1@ptd.net>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Lisa Stickney <Lts1@ptd.net>
Subject: Re: Help with Matrix output (& Paired data OR macro too, for H)
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=response
Thanks! This is great. Lisa
----- Original Message -----
From: "Marta García-Granero" <mgarciagranero@gmail.com>
To: <SPSSX-L@LISTSERV.UGA.EDU>
Sent: Monday, January 28, 2008 11:34 AM
Subject: Re: Help with Matrix output (& Paired data OR macro too, for H)
> Hi Lisa
>
> This is an example of how to use multiple datasets to export output from
> MATRIX and present it in pivot tables (using SUMMARIZE). The macro used
> computes McNmear's OR, and it will reply H's question concerning how to
> compute OR for paired data.
>
> DEFINE PAIREDOR (!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)).
> DATASET NAME OriginalData.
> * Preserve original data *.
> DATASET COPY DuplicateData WINDOW=FRONT.
> SORT CASES BY !1(A) !2(A).
> AGGREGATE
> /OUTFILE=*
> /BREAK=!1 !2
> /N=n.
> * Initialize empty dataset to dump MATRIX output later *.
> DATASET DECLARE Results1 WINDOW=HIDDEN.
> DATASET DECLARE Results2 WINDOW=HIDDEN.
> PRESERVE.
> * Shut down all output (MATRIX code is invisible) *.
> SET ERRORS=NONE RESULTS=NONE.
> MATRIX.
> GET obs /VAR=n .
> COMPUTE a=obs(1).
> COMPUTE b=obs(2).
> COMPUTE c=obs(3).
> COMPUTE d=obs(4).
> RELEASE obs.
> COMPUTE chi2=((b-c)&**2)&/(b+c).
> COMPUTE chi2sig=1-CHICDF(chi2,1).
> COMPUTE chi2cor=(ABS(b-c)-1)&**2&/(b+c).
> COMPUTE chi2sigc=1-CHICDF(chi2cor,1).
> COMPUTE orr=b/c.
> COMPUTE seorr=SQRT(1/b+1/c).
> COMPUTE loworr=orr*EXP(-1.96*seorr).
> COMPUTE upporr=orr*EXP(1.96*seorr).
> COMPUTE vnames={'Chi2','Sig'}.
> SAVE {chi2,chi2sig;chi2cor,chi2sigc} /OUTFILE=Results1 /NAMES=vnames.
> COMPUTE vnames={'OddsR','Inferior','Superior'}.
> SAVE {orr,loworr,upporr} /OUTFILE=Results2 /NAMES=vnames.
> END MATRIX.
> * Output starts again *.
> RESTORE.
> * This is just some output cleaning *.
> OMS /SELECT TABLES
> /IF COMMANDS='Summarize' SUBTYPES='Case Processing Summary'
> /DESTINATION VIEWER=NO.
> OMS /SELECT ALL
> /IF LABELS='Active Dataset'
> /DESTINATION VIEWER=NO.
> * Print report for chi-square tests *.
> DATASET ACTIVATE Results1.
> FORMAT chi2(F8.3) Sig (F8.4).
> VAR LABEL chi2 'Chi²'/ Sig 'Sig.'.
> STRING Test (A12).
> IF ($casenum EQ 1) Test = 'Uncorrected' .
> IF ($casenum EQ 2) Test = 'Corrected' .
> SUMMARIZE
> /TABLES=Test chi2 Sig
> /FORMAT=LIST NOCASENUM NOTOTAL
> /TITLE='McNemar Chi-square tests'
> /CELLS=NONE.
> * Getting rid of the now useless dataset *.
> DATASET ACTIVATE Results2.
> DATASET CLOSE Results1.
> * Prin report for OR & 95%CI *.
> FORMAT OddsR TO Superior (F8.2).
> VAR LABEL OddsR 'OR (McNemar)' Inferior 'Lower' Superior 'Upper'.
> SUMMARIZE
> /TABLES=ALL
> /FORMAT=LIST NOCASENUM NOTOTAL
> /TITLE='OR & 95%CI (*)'
> /CELLS=NONE.
> OMSEND.
> * Getting rid of the now useless datasets *.
> DATASET ACTIVATE DuplicateData.
> DATASET CLOSE Results2.
> DATASET ACTIVATE OriginalData.
> DATASET CLOSE DuplicateData.
> ECHO '(*) Asymptotic'.
> !ENDDEFINE.
>
> * Sample dataset (1:1 matched binary data, lower value means exposed in
> both groups) *.
> DATA LIST FREE/Case Control (2 F8).
> BEGIN DATA
> 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2
> 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
> 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 1 2 1 2 1
> 2 1 2 1 2 1 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2
> 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
> 2 2
> END DATA.
> VALUE LABEL Case Control 1'Exposed to Risk' 2 'Non exposed'.
> LIST /CASES=FROM 1 TO 10.
>
> * MACRO call *.
> PAIREDOR Case Control.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
|