Dear all,
Iâm using the nonparametric 2 related samples McNemar test in SPSS 15 (NPAR TEST), but the output doesnât give me a value for the McNemar chi-square. The output gives the crosstab plus a table containing âNâ and âExact Sig. (2-tailed)â. Why is SPSS not giving the chi-square and how can I get the chi-square? Thank you very much for your help! Sytske ===================== 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 |
Hi,
Is your sample size relatively small? If so, I think you will find that SPSS has done an exact test (hence the 'exact' p value) rather than a test through the chi-square distribution. You could get a chi-square statistic by doing the test by hand, but you would need to look up the associated p value for the value of chi-square, as it might well differ slightly from the exact p value. I'd suggest just reporting it as an exact test! Julius > Dear all, > > I'm using the nonparametric 2 related samples McNemar test in SPSS 15 > (NPAR > TEST), but the output doesn't give me a value for the McNemar > chi-square. > The output gives the crosstab plus a table containing 'N' and 'Exact > Sig. > (2-tailed)'. Why is SPSS not giving the chi-square and how can I get the > chi-square? > > Thank you very much for your help! > > Sytske > > ===================== > 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 > ===================== 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 |
In reply to this post by Sytske
Sytske escribió:
> > I'm using the nonparametric 2 related samples McNemar test in SPSS 15 (NPAR > TEST), but the output doesn't give me a value for the McNemar chi-square. > The output gives the crosstab plus a table containing 'N' and 'Exact Sig. > (2-tailed)'. Why is SPSS not giving the chi-square and how can I get the > chi-square? If sample size is low (I recall something like "less than 25 discordant pairs (0/1 & 1/0 values)"), SPSS will always give the exact p-value. For big sample sizes, SPSS will give McNemar's Chi-square, but corrected for continuity. Both tests (exact & continuity corrected) are too conservative (according to Montecarlo simulations run & published by someone whose name I don't remember right now). If you have more than 10 discordant pairs, uncorrected chi-square should be used instead. It can be easily computed from the crosstab table output, and using some MATRIX code (see MACRO below). HTH, Marta García-Granero * MACRO definition (it also computes a 96%CI -Newcombe's method- for the difference in percentages, nice extra!) *. DEFINE MYMCNEMAR(!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)). DATASET NAME Datos. DATASET DECLARE Resultados1 WINDOW=HIDDEN. DATASET DECLARE Resultados2 WINDOW=HIDDEN. PRESERVE. SET ERRORS=NONE RESULTS=NONE. MATRIX. COMPUTE nanb=!1 . COMPUTE napb=!2 . COMPUTE panb=!3 . COMPUTE papb=!4 . COMPUTE a=nanb. COMPUTE b=napb. COMPUTE c=panb. COMPUTE d=papb. COMPUTE perc={(c+d)/(a+b+c+d);(b+d)/(a+b+c+d)}. 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 z = 1.959964. COMPUTE zsq = 1.959964*1.959964. COMPUTE x5=papb+panb. COMPUTE x6=napb+nanb. COMPUTE x7=papb+napb. COMPUTE x8=panb+nanb. COMPUTE x9=x7+x8. COMPUTE x10=(panb-napb)/x9. COMPUTE x11=2*x5+zsq. COMPUTE x12=z&*(zsq+4*x5&*x6/x9)&**0.5. COMPUTE x13=2*(x9+zsq). COMPUTE x14=(x11+x12)/x13. COMPUTE x15=(x11-x12)/x13. COMPUTE x16=x5/x9-x15. COMPUTE x17=x14-x5/x9. COMPUTE x21=2*x7+zsq. COMPUTE x22=z&*(zsq+4*x7&*x8/x9)&**0.5. COMPUTE x24=(x21+x22)/x13. COMPUTE x25=(x21-x22)/x13. COMPUTE x26=x7/x9-x25. COMPUTE x27=x24-x7/x9. COMPUTE x29=x5&*x6&*x7&*x8. COMPUTE x30=1. DO IF x29 EQ 0. - COMPUTE x30=0. END IF. COMPUTE x31=papb&*nanb-panb&*napb. COMPUTE x32=0. DO IF (x31 GT 0). - COMPUTE x32=1. END IF. COMPUTE x33=x31-x9/2. COMPUTE x35=0. DO IF (x33 GT 0). - COMPUTE x35=x33. END IF. COMPUTE x36=x32&*x35+(1-x32)&*x31. COMPUTE x37=x30&*x36. COMPUTE x38=x30&*x29&**0.5+(1-x30). COMPUTE x39=x37/x38. /* phi hat. COMPUTE x40=x16&*x16-2*x39&*x16&*x27+x27&*x27. COMPUTE x41=x17&*x17-2*x39&*x17&*x26+x26&*x26. COMPUTE x42=x10-SQRT(x40). COMPUTE x43=x10+SQRT(x41). COMPUTE vnames={'P1','P2','Puntual','Inferior','Superior'}. SAVE {100*T(perc),100*x10,100*x42,100*x43} /OUTFILE=Resultados1 /NAMES=vnames. COMPUTE vnames={'Chi2','Sig'}. SAVE {chi2,chi2sig;chi2cor,chi2sigc} /OUTFILE=Resultados2 /NAMES=vnames. END MATRIX. RESTORE. DATASET ACTIVATE Resultados1. FORMAT P1 TO Superior (PCT4.2). VAR LABEL P1 'Porc. A'/P2 'Porc. B'/ Puntual 'Diferencia'. OMS /SELECT TABLES /IF COMMANDS='Summarize' SUBTYPES='Case Processing Summary' /DESTINATION VIEWER=NO. SUMMARIZE /TABLES=ALL /FORMAT=LIST NOCASENUM NOTOTAL /TITLE='95%CI for difference in proportions (paired) (*)' /CELLS=NONE. OMSEND. ECHO '(*) Exact (Newcombe method)'. DATASET ACTIVATE Resultados2. DATASET CLOSE Resultados1. 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' . OMS /SELECT TABLES /IF COMMANDS='Summarize' SUBTYPES='Case Processing Summary' /DESTINATION VIEWER=NO. SUMMARIZE /TABLES=Test chi2 Sig /FORMAT=LIST NOCASENUM NOTOTAL /TITLE='McNemar Chi-square statistics(*)' /CELLS=NONE. OMSEND. DATASET ACTIVATE Datos. DATASET CLOSE Resultados2. ECHO '(*) Asymptotic'. !ENDDEFINE. * An example of the macro call: suppose your crosstab table output (from SPSS' McNemar output) looks like this: * No Yes * No 10 12 * Yes 4 20 MYMCNEMAR 10 12 4 20. ===================== 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 |
Hi all
I'm trying the McNemar Macro of Marta in SPSS 22 but get an error every time.. (in command name, is not recognized and in end of command of Define) Does anyone know how to solve this problem? Thanks in advance! Mieke (student) |
Hi:
Since WIndows 7, SPSS can't write files from MATRIX. Either try to run SPSS with administrator permissions, or use this simplified version of the macro. Best regards, Marta GG DEFINE MyMcNemar(!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)). MATRIX. COMPUTE nanb=!1 . COMPUTE napb=!2 . COMPUTE panb=!3 . COMPUTE papb=!4 . COMPUTE a=nanb. COMPUTE b=napb. COMPUTE c=panb. COMPUTE d=papb. COMPUTE perc={(c+d)/(a+b+c+d);(b+d)/(a+b+c+d)}. 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 z = 1.959964. COMPUTE zsq = 1.959964*1.959964. COMPUTE x5=papb+panb. COMPUTE x6=napb+nanb. COMPUTE x7=papb+napb. COMPUTE x8=panb+nanb. COMPUTE x9=x7+x8. COMPUTE x10=(panb-napb)/x9. COMPUTE x11=2*x5+zsq. COMPUTE x12=z&*(zsq+4*x5&*x6/x9)&**0.5. COMPUTE x13=2*(x9+zsq). COMPUTE x14=(x11+x12)/x13. COMPUTE x15=(x11-x12)/x13. COMPUTE x16=x5/x9-x15. COMPUTE x17=x14-x5/x9. COMPUTE x21=2*x7+zsq. COMPUTE x22=z&*(zsq+4*x7&*x8/x9)&**0.5. COMPUTE x24=(x21+x22)/x13. COMPUTE x25=(x21-x22)/x13. COMPUTE x26=x7/x9-x25. COMPUTE x27=x24-x7/x9. COMPUTE x29=x5&*x6&*x7&*x8. COMPUTE x30=1. DO IF x29 EQ 0. - COMPUTE x30=0. END IF. COMPUTE x31=papb&*nanb-panb&*napb. COMPUTE x32=0. DO IF (x31 GT 0). - COMPUTE x32=1. END IF. COMPUTE x33=x31-x9/2. COMPUTE x35=0. DO IF (x33 GT 0). - COMPUTE x35=x33. END IF. COMPUTE x36=x32&*x35+(1-x32)&*x31. COMPUTE x37=x30&*x36. COMPUTE x38=x30&*x29&**0.5+(1-x30). COMPUTE x39=x37/x38. /* phi hat. COMPUTE x40=x16&*x16-2*x39&*x16&*x27+x27&*x27. COMPUTE x41=x17&*x17-2*x39&*x17&*x26+x26&*x26. COMPUTE x42=x10-SQRT(x40). COMPUTE x43=x10+SQRT(x41). COMPUTE orr=panb/napb. COMPUTE se_orr=SQRT(1/panb+1/napb). COMPUTE low_orr=orr*EXP(-z*se_orr). COMPUTE upp_orr=orr*EXP(z*se_orr). PRINT /TITLE="MCNEMAR CHI-SQUARE TESTS AND RELATED STATISTICS". PRINT {chi2,chi2sig;chi2cor,chi2sigc} /TITLE="CHI-SQUARE TESTS (ASYMPTOTIC)" /FORMAT="F8.3" /RLABELS="Uncorr.","Corr." /CLABELS="Stat.","Sig.". PRINT {100*T(perc),100*x10,100*x42,100*x43} /TITLE="PERCENTAGES, DIFFERENCE & 95%CI FOR DIFFERENCE (NEWCOMBE'S METHOD #10)" /FORMAT="F8.2" /CLABELS="p(A)","p(B)","Diff.","Lower","Upper". PRIINT{orr,low_orr,upp_orr} /TITLE="MCNEMAR'S ODDS-RATIO & 95CI (ASYMPTOTIC)" /FORMAT="F8.2" /CLABELS="OR","Lower","Upper". END MATRIX. !ENDDEFINE. MyMcNemar 20 12 2 15. El 08/06/2016 a las 10:47, Mieke escribió: > Hi all > > I'm trying the McNemar Macro of Marta in SPSS 22 but get an error every > time.. (in command name, is not recognized and in end of command of Define) > Does anyone know how to solve this problem? > > <http://spssx-discussion.1045642.n5.nabble.com/file/n5732339/Mcnemar_macro_error.jpg> > > Thanks in advance! > Mieke (student) > > > > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/No-chi-square-value-in-McNemar-test-output-tp1080750p5732339.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > 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 > ===================== 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 |
Hi, Marta.
What are you saying? Are you saying WRITE or SAVE statements of MATRIX session are not working on Windows 8/10?! Or something else? 08.06.2016 12:50, Marta Garcia-Granero
пишет:
Hi: ===================== 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 |
In reply to this post by Marta Garcia-Granero
Matrix seems to use the installation folder which is protected.
Try: PRESERVE. CD "%temp%". MyMcNemar 20 12 2 15. RESTORE. HTH, PRogman (away from spss machine) |
In reply to this post by Kirill Orlov
Hi KirilL:
I used to write a lot of macros that took advantage of the
possibility of having several datasets open at the same time. They
worked OK with Windows XP and any version of SPSS (15 or newer).
SInce I switched to Windows 7/10, I discovered that exporting data
from matrix to an already declared (and empty) dataset triggered
an error. The workaround was to write temporary files in disk
(C:\Temp\ was my favorite folder) and open them later, or run SPSS
with administrator rights (which was impossible for my students at
the university). Since I kept on getting private emails regarding
the problem with that macro in particular, I rewrote it to avoid
any data crossing between MATRIX and SPSS data editor.
I think this topic was discussed some months (years?) ago on this list.
Best regards, Marta El 08/06/2016 a las 12:05, Kirill Orlov
escribió:
Hi, Marta. ===================== 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 |
Marta,
MATRIX should be able to save to a declared dataset. The CSR doc on SAVE statement of matrix session puts it: OUTFILE designates the file to which the matrix expression is to be written. It can be an actual filename in quotes, a previously declared dataset in the current session, or a file handle defined on a FILE HANDLE command that precedes the matrix program. To save a matrix expression as the active dataset, specify an asterisk (*). If there is no active dataset, one will be created; if there is one, it is replaced by the saved matrices. I've never encounter problems ("I discovered that exporting data from matrix to an already declared (and empty) dataset triggered an error") with it on Windows 7 and any SPSS version 15 or higher. I'm not sure about Windows 10 (just recently installed it, so I still have to check). Can you send me a piece of code that invoked such error on Windows 7 or 10? What does the error message say? 08.06.2016 16:21, Marta Garcia-Granero
пишет:
===================== 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 |
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 |
In reply to this post by PRogman
Hi PRogman:
It works with your solution. Thanks A LOT! Marta El 08/06/2016 a las 12:30, PRogman escribió: > Matrix seems to use the installation folder which is protected. > Try: > > PRESERVE. > CD "%temp%". > MyMcNemar 20 12 2 15. > RESTORE. > > HTH, PRogman (away from spss machine) > > > > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/No-chi-square-value-in-McNemar-test-output-tp1080750p5732343.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > 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 > ===================== 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 |
I just was preparing to suppose the same as PRogman did.
Probably (my guess) when MATRIX saves to a declared dataset it actually saves first to a hard disc, at least partly. If hard disc saving comes on the scene, then naturally, you must have administrator rights to save anywhere or you must have prepared a folder where you are allowed to save to. CD command sets the default saving route to such a folder. How do you think? Is it a solution for every such error case you were complaining above? On my page http://www.spsstools.net/en/KO-aboutmacros I have a special point for users ("protected directory") about it. 08.06.2016 17:50, Marta Garcia-Granero
пишет:
Hi PRogman: ===================== 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 |
In reply to this post by Marta Garcia-Granero
Hi All!
Thanks a lot for your reply! Unfortunately, mine is still not working, giving error (even as administrator of with simplified matrix..) Progman, where do I use your PRESERVE -RESTORE? Do I use it in Syntax before putting the matrix in? or together? (I'm sorry I'm really not experienced with SPSS) Mieke |
Administrator
|
In reply to this post by Sytske
Marta has posted a macro you can use. Here is another option you could use if all you want is the Chi-square value and its p-value.
* McNemar's Chi-square is equivalent to a Chi-square * goodness of fit test (using Pearson's Chi-square) * on the two discordant cells, which I'll call b and c. DATA LIST LIST /b c (2F5.0). BEGIN DATA 12 4 END DATA. * For both cells, the expected frequency under the null hypothesis * is the mean of the two observed counts. COMPUTE E = MEAN(b,c). COMPUTE Xsq1 = (b-E)**2/E + (c-E)**2/E. COMPUTE Xsq2 = (ABS(b-E)-.5)**2/E + (ABS(c-E)-.5)**2/E. COMPUTE df = 1. COMPUTE p1 = 1 - CDF.CHISQ(Xsq1,df). COMPUTE p2 = 1 - CDF.CHISQ(Xsq2,df). FORMATS Xsq1 Xsq2 p1 p2 (F8.3) / df (F5.0). LIST. List b c E Xsq1 Xsq2 df p1 p2 12 4 8.00 4.000 3.063 1 .046 .080 Number of cases read: 1 Number of cases listed: 1 * Xsq1 and Xsq2 are the uncorrected and continuity-corrected * versions respectively of McNemar's Chi-square test. Results from Marta's macro: MyMcNemar 10 12 4 20. MCNEMAR CHI-SQUARE TESTS AND RELATED STATISTICS CHI-SQUARE TESTS (ASYMPTOTIC) Stat. Sig. Uncorr. 4.000 .046 Corr. 3.063 .080 MCNEMAR'S ODDS-RATIO & 95CI (ASYMPTOTIC) OR Lower Upper .33 .11 1.03 HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by Mieke
The MATRIX command seems to use the SPSS installation folder, which is protected from Windows Vista and onward (I think). If a DATASET DECLARE command is used it probably tries to write a temporary file to that folder and crashes, unless you have administrator status.
So, before a MATRIX command is run you need to change the current working directory (folder, in modern terms) with the CD command to a folder with read/write permissions. %temp% is shorthand in the Windows environment for the temporary folder, but you can choose another if you want. I don't know what the corresponding Mac folder path would be, if you are in that environment. PRESERVE and RESTORE just saves and restores whatever settings you have, including current working folder. They are not necessary, it is just a good habit restore things to original state when finished. As the code already uses a PRESERVE an easy modification would be to place the CD command inside the macro, but then it makes the code windows-specific: ... PRESERVE. SET ERRORS=NONE RESULTS=NONE. CD "%temp%" /*Windows temp folder*/. MATRIX. ... HTH
|
In reply to this post by Mieke
Hi Mieke:
As a closing remark. A general advice: when you copy/paste code from web pages, make sure that line wrapping doesn't split long lines in two. I took a look at the picture you attached (<http://spssx-discussion.1045642.n5.nabble.com/file/n5732339/Mcnemar_macro_error.jpg> ), and I realized that your initial error message had in fact nothing to do with MATRIX trying to write temporary files on protected folders. Make sure that the first line in the macro definition: DEFINE MYMCNEMAR(!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)/POSITIONAL !TOKENS(1)). Is in fact one single line. Since we can shorten some keywords, try this as first line in the macro definition of the code you were using: DEFINE MYMCNEMAR(!POS !TOKENS(1) /!POS !TOKENS(1)/!POS !TOKENS(1)/POS !TOKENS(1)). If you had read the error message, you would have understood where the problem was. From the picture you sent: >Error # 6823. Command name: DEFINE >On the DEFINE command, each parameter definition ... I didn't read beyond the first line. When I saw that the macro involved was MyMcNemar, I entered automatic mode and sent you the standard reply. Regards, Marta GG El 08/06/2016 a las 17:29, Mieke escribió: > Hi All! > > Thanks a lot for your reply! Unfortunately, mine is still not working, > giving error (even as administrator of with simplified matrix..) Progman, > where do I use your PRESERVE -RESTORE? Do I use it in Syntax before putting > the matrix in? or together? (I'm sorry I'm really not experienced with SPSS) > > Mieke > > > > > -- > View this message in context: http://spssx-discussion.1045642.n5.nabble.com/No-chi-square-value-in-McNemar-test-output-tp1080750p5732350.html > Sent from the SPSSX Discussion mailing list archive at Nabble.com. > > ===================== > 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 > . > ===================== 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 |
Free forum by Nabble | Edit this page |