Login  Register

Re: No chi-square value in McNemar test output?

Posted by Marta Garcia-Granero on Jun 08, 2016; 2:40pm
URL: http://spssx-discussion.165.s1.nabble.com/No-chi-square-value-in-McNemar-test-output-tp1080750p5732347.html

Hi Kirill:


I don't have easy access to SPSS right now. (not complaining... well,
yes, a bit). I had to find some computer at the University of Navarra
Clinic with a license.


On Windows 10 Home/IBM SPSS 22.0.0.2 (patch applied) 64 bits. Without
administrator rights.

"SPSS Statistics cannot access a file with the given file
specification.  The file specification is either syntactically invalid,
specifies an invalid drive, specifies a protected directory, specifies a
protected file, or specifies a non-sharable file. "

This error triggers a lot of errors due to attempts to format/label non
existent variables, and so on.

Macro works flawlessly if SPSS is "Run as administrator".

This is the macro, with a sample dataset and macro call:

DEFINE PAIREDOR (!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)).
DATASET NAME Datos.
DATASET COPY Duplicado.
AGGREGATE
  /OUTFILE=*
  /BREAK=!1 !2
  /N=n.
DATASET DECLARE Resultados1 WINDOW=HIDDEN.
DATASET DECLARE Resultados2 WINDOW=HIDDEN.
PRESERVE.
SET ERRORS=NONE RESULTS=NONE.
MATRIX.
GET obs /VAR=n .
COMPUTE b=obs(2).
COMPUTE c=obs(3).
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=Resultados1 /NAMES=vnames.
COMPUTE vnames={'OddsR','Lower','Upper'}.
SAVE {orr,loworr,upporr} /OUTFILE=Resultados2 /NAMES=vnames.
END MATRIX.
RESTORE.
OMS
/SELECT TABLES
/IF COMMANDS='Summarize' SUBTYPES='Case Processing Summary'
/DESTINATION VIEWER=NO.
DATASET ACTIVATE Resultados1.
FORMAT chi2(F8.3) Sig (F8.4).
VAR LABEL chi2 'ChiĀ²'/ Sig 'Sig.'.
STRING Test (A11).
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.
DATASET ACTIVATE Resultados2.
FORMAT OddsR TO Upper (F8.2).
VAR LABEL OddsR 'OR (McNemar)'.
SUMMARIZE
/TABLES=ALL
/FORMAT=LIST NOCASENUM NOTOTAL
/TITLE='OR & 95%CI (*)'
/CELLS=NONE.
OMSEND.
DATASET ACTIVATE Datos WINDOW=ASIS.
DATASET CLOSE Duplicado.
DATASET CLOSE Resultados1.
DATASET CLOSE Resultados2.
ECHO '(*) Asymptotic'.
!ENDDEFINE.

* Sample dataset (aggregated, but the macro works OK with "normal"
-expanded- datasets) *.
DATA LIST LIST/LowWeight NormalWeight frequency (3 F8).
BEGIN DATA
1 1  8
1 2 22
2 1  8
2 2 18
END DATA.

VAR LABEL LowWeight 'Low weight baby mother'/
          NormalWeight 'Normal weight baby mother'.
VAL LABEL LowWeight NormalWeight 1'Smoker' 2'Non smoker'.
WEIGHT BY frequency.

* McNemar test with SPSS (no OR) *.
CROSSTABS
   /TABLES=LowWeight BY NormalWeight
   /STATISTIC=MCNEMAR.


* Macro call *.
PAIREDOR LowWeight NormalWeight.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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