BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

dbreslauer
I have rerun the subroutine a number of times and continue to get error messages.

Run MATRIX procedure:
 The variable name g not found in the dictionary
>Error encountered in source line #  1420
 
>Error # 12537
>A variable name of the variable list defined by VARIABLES or NAMES subcommand
>is not found in the dictionary of the file defined by FILE subcommand.
>Execution of this command stops.
 The variable name resid not found in the dictionary
>Error encountered in source line #  1421

>Error # 12537
>A variable name of the variable list defined by VARIABLES or NAMES subcommand
>is not found in the dictionary of the file defined by FILE subcommand.
>Execution of this command stops.
>Error encountered in source line #  1422
 
>Error # 12492
>An attempt has been made to use previously undefined matrix (or scalar).
>Execution of this command stops.
Matrix - 'RESID' is undefined
>Error encountered in source line #  1422

and the list of error messages goes on. Does anyone have any suggestions?
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

David Marso
Administrator
Contact the macro author or post it so people that know macros might be able to help!
I'm not going to bother to try tracking the damned thing down!

dbreslauer wrote
I have rerun the subroutine a number of times and continue to get error messages.

Run MATRIX procedure:
 The variable name g not found in the dictionary
>Error encountered in source line #  1420
 
>Error # 12537
>A variable name of the variable list defined by VARIABLES or NAMES subcommand
>is not found in the dictionary of the file defined by FILE subcommand.
>Execution of this command stops.
 The variable name resid not found in the dictionary
>Error encountered in source line #  1421

>Error # 12537
>A variable name of the variable list defined by VARIABLES or NAMES subcommand
>is not found in the dictionary of the file defined by FILE subcommand.
>Execution of this command stops.
>Error encountered in source line #  1422
 
>Error # 12492
>An attempt has been made to use previously undefined matrix (or scalar).
>Execution of this command stops.
Matrix - 'RESID' is undefined
>Error encountered in source line #  1422

and the list of error messages goes on. Does anyone have any suggestions?
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Bruce Weaver
Administrator
It must be this one (written by Marta GG):

http://www.spsstools.net/Syntax/RegressionRepeatedMeasure/Breusch-PaganAndKoenkerTest.txt


David Marso wrote
Contact the macro author or post it so people that know macros might be able to help!
I'm not going to bother to try tracking the damned thing down!

dbreslauer wrote
I have rerun the subroutine a number of times and continue to get error messages.

Run MATRIX procedure:
 The variable name g not found in the dictionary
>Error encountered in source line #  1420
 
>Error # 12537
>A variable name of the variable list defined by VARIABLES or NAMES subcommand
>is not found in the dictionary of the file defined by FILE subcommand.
>Execution of this command stops.
 The variable name resid not found in the dictionary
>Error encountered in source line #  1421

>Error # 12537
>A variable name of the variable list defined by VARIABLES or NAMES subcommand
>is not found in the dictionary of the file defined by FILE subcommand.
>Execution of this command stops.
>Error encountered in source line #  1422
 
>Error # 12492
>An attempt has been made to use previously undefined matrix (or scalar).
>Execution of this command stops.
Matrix - 'RESID' is undefined
>Error encountered in source line #  1422

and the list of error messages goes on. Does anyone have any suggestions?
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

PRogman
If it is that macro, then it is the AGGREGATE /OUTFILE that is the culprit.
In that macro it tries to write temporary file which will go to a write-protected folder (i'm guessing Windows SPSS installation folder: C:\Program Files\IBM\SPSS....).
Switch working directory! Unless you really care about where to put intermediate/temporary files use the default (Windows) temp folder.

Try (using demo data supplied with macro):
FILE HANDLE fpTemp /NAME="%temp%".

PRESERVE.
CD fpTemp.
bpktest x1 19 x2 TO x20.
RESTORE.
HTH /PR
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Marta Garcia-Granero
Hi!

Long time no see...

I felt my ears ringing... like someone was blaming me for something ;)

I wrote the macro when the relationship between Windows&SPSS was more
easy going. Starting with Windows 7, it is more difficult to write
temporary files from SPSS unless you run SPSS as Administrator, or, you
create a temporary folder (like "C:/Temp") and modify the macro to write
to that folder.

If the offending command is:

AGGREGATE
/OUTFILE='tempdata.sav'
/BREAK=constant
/rss = SUM(sq_res)
/N=N.
MATCH FILES /FILE=*
/FILE='tempdata.sav'.

Replace it by:

AGGREGATE
/OUTFILE='C:/Temp/tempdata.sav'
/BREAK=constant
/rss = SUM(sq_res)
/N=N.
MATCH FILES /FILE=*
/FILE='C:/Temp/tempdata.sav'.


And see what happens.

Unable to test it myself. Knee deep in Stata & R (gosh! I was soooo
happy running ANOVA models with SPSS!)

Running back to RStudio hard and cold arms.

Marta

El 18/09/2014 a las #4, PRogman escribió:

> If it is that macro, then it is the AGGREGATE /OUTFILE that is the culprit.
> In that macro it tries to write temporary file which will go to a
> write-protected folder (i'm guessing Windows SPSS installation folder:
> C:\Program Files\IBM\SPSS....).
> Switch working directory! Unless you really care about where to put
> intermediate/temporary files use the default (Windows) temp folder.
>
> Try (using demo data supplied with macro):
>
> HTH /PR
>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727304.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
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Kirill Orlov
In advance issuing command
CD 'myfolder'.
where myfolder is the path where one has the rights to save files to, solves it.


18.09.2014 14:04, Marta Garcia-Granero пишет:
Hi!

Long time no see...

I felt my ears ringing... like someone was blaming me for something ;)

I wrote the macro when the relationship between Windows&SPSS was more easy going. Starting with Windows 7, it is more difficult to write temporary files from SPSS unless you run SPSS as Administrator, or, you create a temporary folder (like "C:/Temp") and modify the macro to write to that folder.

If the offending command is:

AGGREGATE
/OUTFILE='tempdata.sav'
/BREAK=constant
/rss = SUM(sq_res)
/N=N.
MATCH FILES /FILE=*
/FILE='tempdata.sav'.

Replace it by:

AGGREGATE
/OUTFILE='C:/Temp/tempdata.sav'
/BREAK=constant
/rss = SUM(sq_res)
/N=N.
MATCH FILES /FILE=*
/FILE='C:/Temp/tempdata.sav'.


And see what happens.

Unable to test it myself. Knee deep in Stata & R (gosh! I was soooo happy running ANOVA models with SPSS!)

Running back to RStudio hard and cold arms.

Marta

El 18/09/2014 a las #4, PRogman escribió:
If it is that macro, then it is the AGGREGATE /OUTFILE that is the culprit.
In that macro it tries to write temporary file which will go to a
write-protected folder (i'm guessing Windows SPSS installation folder:
C:\Program Files\IBM\SPSS....).
Switch working directory! Unless you really care about where to put
intermediate/temporary files use the default (Windows) temp folder.

Try (using demo data supplied with macro):

HTH /PR



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727304.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




===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

David Marso
Administrator
Why not get rid of ALL disk file usage and use DATASETS?
----
Kirill Orlov wrote
In advance issuing command
CD 'myfolder'.
where myfolder is the path where one *has *the rights to save files to,
solves it.


18.09.2014 14:04, Marta Garcia-Granero ?????:
> Hi!
>
> Long time no see...
>
> I felt my ears ringing... like someone was blaming me for something ;)
>
> I wrote the macro when the relationship between Windows&SPSS was more
> easy going. Starting with Windows 7, it is more difficult to write
> temporary files from SPSS unless you run SPSS as Administrator, or,
> you create a temporary folder (like "C:/Temp") and modify the macro to
> write to that folder.
>
> If the offending command is:
>
> AGGREGATE
> /OUTFILE='tempdata.sav'
> /BREAK=constant
> /rss = SUM(sq_res)
> /N=N.
> MATCH FILES /FILE=*
> /FILE='tempdata.sav'.
>
> Replace it by:
>
> AGGREGATE
> /OUTFILE='C:/Temp/tempdata.sav'
> /BREAK=constant
> /rss = SUM(sq_res)
> /N=N.
> MATCH FILES /FILE=*
> /FILE='C:/Temp/tempdata.sav'.
>
>
> And see what happens.
>
> Unable to test it myself. Knee deep in Stata & R (gosh! I was soooo
> happy running ANOVA models with SPSS!)
>
> Running back to RStudio hard and cold arms.
>
> Marta
>
> El 18/09/2014 a las #4, PRogman escribió:
>> If it is that macro, then it is the AGGREGATE /OUTFILE that is the
>> culprit.
>> In that macro it tries to write temporary file which will go to a
>> write-protected folder (i'm guessing Windows SPSS installation folder:
>> C:\Program Files\IBM\SPSS....).
>> Switch working directory! Unless you really care about where to put
>> intermediate/temporary files use the default (Windows) temp folder.
>>
>> Try (using demo data supplied with macro):
>>
>> HTH /PR
>>
>>
>>
>> --
>> View this message in context:
>> http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727304.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
>
>



=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Marta Garcia-Granero
Because DATASETS were affected by the bad relationship between W7 and SPSS.

I wrote the macro before ADDVARIABLES existed in AGGREGATE. Maybe
rewriting the whole AGGREGATE&MATCH FILES part would solve the problem.

Best regards,
Marta

El 18/09/2014 a las #4, David Marso escribió:

> Why not get rid of ALL disk file usage and use DATASETS?
> ----
>
> Kirill Orlov wrote
>> In advance issuing command
>> CD 'myfolder'.
>> where myfolder is the path where one *has *the rights to save files to,
>> solves it.
>>
>>
>> 18.09.2014 14:04, Marta Garcia-Granero ?????:
>>> Hi!
>>>
>>> Long time no see...
>>>
>>> I felt my ears ringing... like someone was blaming me for something ;)
>>>
>>> I wrote the macro when the relationship between Windows&SPSS was more
>>> easy going. Starting with Windows 7, it is more difficult to write
>>> temporary files from SPSS unless you run SPSS as Administrator, or,
>>> you create a temporary folder (like "C:/Temp") and modify the macro to
>>> write to that folder.
>>>
>>> If the offending command is:
>>>
>>> AGGREGATE
>>> /OUTFILE='tempdata.sav'
>>> /BREAK=constant
>>> /rss = SUM(sq_res)
>>> /N=N.
>>> MATCH FILES /FILE=*
>>> /FILE='tempdata.sav'.
>>>
>>> Replace it by:
>>>
>>> AGGREGATE
>>> /OUTFILE='C:/Temp/tempdata.sav'
>>> /BREAK=constant
>>> /rss = SUM(sq_res)
>>> /N=N.
>>> MATCH FILES /FILE=*
>>> /FILE='C:/Temp/tempdata.sav'.
>>>
>>>
>>> And see what happens.
>>>
>>> Unable to test it myself. Knee deep in Stata & R (gosh! I was soooo
>>> happy running ANOVA models with SPSS!)
>>>
>>> Running back to RStudio hard and cold arms.
>>>
>>> Marta
>>>
>>> El 18/09/2014 a las #4, PRogman escribió:
>>>> If it is that macro, then it is the AGGREGATE /OUTFILE that is the
>>>> culprit.
>>>> In that macro it tries to write temporary file which will go to a
>>>> write-protected folder (i'm guessing Windows SPSS installation folder:
>>>> C:\Program Files\IBM\SPSS....).
>>>> Switch working directory! Unless you really care about where to put
>>>> intermediate/temporary files use the default (Windows) temp folder.
>>>>
>>>> Try (using demo data supplied with macro):
>>>>
>>>> HTH /PR
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727304.html
>>>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>>>
>>>> =====================
>>>> To manage your subscription to SPSSX-L, send a message to
>>>>
>> LISTSERV@.UGA
>>   (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@.UGA
>>   (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@.UGA
>>   (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
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727309.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
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

David Marso
Administrator
In reply to this post by David Marso
OR even better use FILE * MODE ADDVARIABLES and skip the MATCH.
Additionally, current versions of SPSS don't require a variable on BREAK.
--
David Marso wrote
Why not get rid of ALL disk file usage and use DATASETS?
----
Kirill Orlov wrote
In advance issuing command
CD 'myfolder'.
where myfolder is the path where one *has *the rights to save files to,
solves it.


18.09.2014 14:04, Marta Garcia-Granero ?????:
> Hi!
>
> Long time no see...
>
> I felt my ears ringing... like someone was blaming me for something ;)
>
> I wrote the macro when the relationship between Windows&SPSS was more
> easy going. Starting with Windows 7, it is more difficult to write
> temporary files from SPSS unless you run SPSS as Administrator, or,
> you create a temporary folder (like "C:/Temp") and modify the macro to
> write to that folder.
>
> If the offending command is:
>
> AGGREGATE
> /OUTFILE='tempdata.sav'
> /BREAK=constant
> /rss = SUM(sq_res)
> /N=N.
> MATCH FILES /FILE=*
> /FILE='tempdata.sav'.
>
> Replace it by:
>
> AGGREGATE
> /OUTFILE='C:/Temp/tempdata.sav'
> /BREAK=constant
> /rss = SUM(sq_res)
> /N=N.
> MATCH FILES /FILE=*
> /FILE='C:/Temp/tempdata.sav'.
>
>
> And see what happens.
>
> Unable to test it myself. Knee deep in Stata & R (gosh! I was soooo
> happy running ANOVA models with SPSS!)
>
> Running back to RStudio hard and cold arms.
>
> Marta
>
> El 18/09/2014 a las #4, PRogman escribió:
>> If it is that macro, then it is the AGGREGATE /OUTFILE that is the
>> culprit.
>> In that macro it tries to write temporary file which will go to a
>> write-protected folder (i'm guessing Windows SPSS installation folder:
>> C:\Program Files\IBM\SPSS....).
>> Switch working directory! Unless you really care about where to put
>> intermediate/temporary files use the default (Windows) temp folder.
>>
>> Try (using demo data supplied with macro):
>>
>> HTH /PR
>>
>>
>>
>> --
>> View this message in context:
>> http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727304.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
>
>



=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Kirill Orlov
In reply to this post by David Marso
David, I presume creating datasets might be more RAM-consuming (even with window=hide) than routing data to hard disc. I may be wrong, though. Multiple datasets are great, who says no? Still, I use them seldom in programming. Bring me over?


18.09.2014 20:41, David Marso пишет:
Why not get rid of ALL disk file usage and use DATASETS?
----


===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

David Marso
Administrator
In reply to this post by Marta Garcia-Granero
Done ;-)
I don't think I broke anything.
------------.
* BREUSCH-PAGAN & KOENKER TEST MACRO *
* See 'Heteroscedasticity: Testing and correcting in SPSS'
* by Gwilym Pryce, for technical details.
* Code by Marta Garcia-Granero 2002/10/28.
*   Modified by David Marso 2014/09/18
   (changed AGGREGATE and MATCH, slight mods to MATRIX code, some formatting).
 
* The MACRO needs 3 arguments:
* the dependent, the number of predictors and the list of predictors
* (if they are consecutive, the keyword TO can be used) .
* (1) MACRO definition (select an run just ONCE).
 
DEFINE bpktest(
   !POSITIONAL !TOKENS(1)
  /!POSITIONAL !TOKENS(1)
  /!POSITIONAL !CMDEND).
* Regression to GET the residuals and residual plots.
REGRESSION
    /STATISTICS R ANOVA
    /DEPENDENT !1
    /METHOD=ENTER !3
    /SCATTERPLOT=(*ZRESID,*ZPRED)
    /RESIDUALS HIST(ZRESID) NORM(ZRESID)
    /SAVE RESID(residual) .
DO IF $casenum=1.
PRINT /"Examine the scatter plot of the residuals to detect"
       /"model misspecification and/or heteroscedasticity"
       /""
       /"Also, check the histogram and np plot of residuals "
       /"to detect non normality of residuals "
       /"Skewness and kurtosis more than twice their SE indicate non-normality ".
END IF.

* Checking normality of residuals.
DESCRIPTIVES VARIABLES=residual /STATISTICS=KURTOSIS SKEWNESS .
* New dependent variable (g) creation.
COMPUTE sq_res=residual**2.
AGGREGATE
    /OUTFILE=* MODE ADDVARIABLES
    /BREAK=
    /rss = SUM(sq_res)
    /N=N.
COMPUTE g=sq_res/(rss/n).
* BP&K tests.
* Regression of g on the predictors.
REGRESSION
   /STATISTICS R ANOVA
   /DEPENDENT g
   /METHOD=ENTER !3
   /SAVE RESID(resid) .

* Routine adapted from Gwilym Pryce.
MATRIX.
COMPUTE p=!2.
GET g
    / VARIABLES=g.
GET resid
    / VARIABLES=resid.
COMPUTE sq_res2 = resid&**2.
COMPUTE n       = nrow(g).
COMPUTE rss     = msum(sq_res2).
COMPUTE m0      = ident(n)-((1/n)*make(n,n,1)).
COMPUTE tss     = transpos(g)*m0*g.
COMPUTE regss   = tss-msum(sq_res2).

*Final report.
PRINT /TITLE " BP&K TESTS".
PRINT /TITLE " ==========".
PRINT regss
    /format="f8.4"
    /title="Regression SS".
PRINT rss
    /format="f8.4"
    /title="Residual SS".
PRINT tss
    /format="f8.4"
    /title="Total SS".
COMPUTE r_sq=1-(rss/tss).
PRINT r_sq
    /format="f8.4"
    /title="R-squared".
PRINT n
    /format="f4.0"
    /title="Sample size (N)".
PRINT p
    /format="f4.0"
    /title="Number of predictors (P)".
COMPUTE bp_test=0.5*regss.
PRINT bp_test
    /format="f8.3"
    /title="Breusch-Pagan test for Heteroscedasticity (CHI-SQUARE df=P)".
COMPUTE sig=1-chicdf(bp_test,p).
PRINT sig
    /format="f8.4"
    /title="Significance level of Chi-square df=P (H0:homoscedasticity)".
COMPUTE k_test=n*r_sq.
PRINT k_test
    /format="f8.3"
    /title="Koenker test for Heteroscedasticity (CHI-SQUARE df=P)".
COMPUTE sig=1-chicdf(k_test,p).
PRINT sig
    /format="f8.4"
    /title="Significance level of Chi-square df=P (H0:homoscedasticity)".
END MATRIX.
!ENDDEFINE.
 
* (2) Sample data (replace by your own)*.
 
INPUT PROGRAM.
- VECTOR x(20).
- LOOP #I = 1 TO 50.
- LOOP #J = 1 TO 20.
- COMPUTE x(#J) = NORMAL(1).
- END LOOP.
- END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
execute.
 
* x1 is the dependent and x2 TO x20 the predictors.
 
* (3) MACRO CALL (select and run).
 
BPKTEST x1 19 x2 TO x20.

Marta García-Granero-2 wrote
Because DATASETS were affected by the bad relationship between W7 and SPSS.

I wrote the macro before ADDVARIABLES existed in AGGREGATE. Maybe
rewriting the whole AGGREGATE&MATCH FILES part would solve the problem.

Best regards,
Marta

El 18/09/2014 a las #4, David Marso escribió:
> Why not get rid of ALL disk file usage and use DATASETS?
> ----
>
> Kirill Orlov wrote
>> In advance issuing command
>> CD 'myfolder'.
>> where myfolder is the path where one *has *the rights to save files to,
>> solves it.
>>
>>
>> 18.09.2014 14:04, Marta Garcia-Granero ?????:
>>> Hi!
>>>
>>> Long time no see...
>>>
>>> I felt my ears ringing... like someone was blaming me for something ;)
>>>
>>> I wrote the macro when the relationship between Windows&SPSS was more
>>> easy going. Starting with Windows 7, it is more difficult to write
>>> temporary files from SPSS unless you run SPSS as Administrator, or,
>>> you create a temporary folder (like "C:/Temp") and modify the macro to
>>> write to that folder.
>>>
>>> If the offending command is:
>>>
>>> AGGREGATE
>>> /OUTFILE='tempdata.sav'
>>> /BREAK=constant
>>> /rss = SUM(sq_res)
>>> /N=N.
>>> MATCH FILES /FILE=*
>>> /FILE='tempdata.sav'.
>>>
>>> Replace it by:
>>>
>>> AGGREGATE
>>> /OUTFILE='C:/Temp/tempdata.sav'
>>> /BREAK=constant
>>> /rss = SUM(sq_res)
>>> /N=N.
>>> MATCH FILES /FILE=*
>>> /FILE='C:/Temp/tempdata.sav'.
>>>
>>>
>>> And see what happens.
>>>
>>> Unable to test it myself. Knee deep in Stata & R (gosh! I was soooo
>>> happy running ANOVA models with SPSS!)
>>>
>>> Running back to RStudio hard and cold arms.
>>>
>>> Marta
>>>
>>> El 18/09/2014 a las #4, PRogman escribió:
>>>> If it is that macro, then it is the AGGREGATE /OUTFILE that is the
>>>> culprit.
>>>> In that macro it tries to write temporary file which will go to a
>>>> write-protected folder (i'm guessing Windows SPSS installation folder:
>>>> C:\Program Files\IBM\SPSS....).
>>>> Switch working directory! Unless you really care about where to put
>>>> intermediate/temporary files use the default (Windows) temp folder.
>>>>
>>>> Try (using demo data supplied with macro):
>>>>
>>>> HTH /PR
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727304.html
>>>> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>>>>
>>>> =====================
>>>> To manage your subscription to SPSSX-L, send a message to
>>>>
>> LISTSERV@.UGA
>>   (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@.UGA
>>   (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@.UGA
>>   (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
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5727309.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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Jon K Peck
In reply to this post by Kirill Orlov
Datasets do not live in RAM any more than data files do.  Think of a dataset as an anonymous file.

BTW, I should point out that there is an extension command for the Breusch-Pagan test.  It allows for a model for the variance or a general test.  The SPSSINC BREUSCH PAGAN command is included in the R Essentials.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Kirill Orlov <[hidden email]>
To:        [hidden email]
Date:        09/18/2014 11:26 AM
Subject:        Re: [SPSSX-L] BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




David, I presume creating datasets might be more RAM-consuming (even with window=hide) than routing data to hard disc. I may be wrong, though. Multiple datasets are great, who says no? Still, I use them seldom in programming. Bring me over?


18.09.2014 20:41, David Marso пишет:
Why not get rid of ALL disk file usage and use DATASETS?
----



===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

dbreslauer
In reply to this post by Marta Garcia-Granero
Marta,
Bless you. That fixed the problem. I cannot thank you enough.

David
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

dbreslauer
In reply to this post by Marta Garcia-Granero
Hello Marta,
Thank you for the revised macro. It helped with the file problem, but now I get another error message.

Warnings
Invalid variable name on REGRESSION SAVE subcommand--The name selected for a variable to be saved already exists as a variable name, or has already been used on the SAVE subcommand in this procedure. Text found: residual.
Execution of this command stops.
*WARNING* REGRESSION syntax scan continues. Further diagnostics from this command may be misleading - interpret with care.

I found that I needed to delete the variables that were added to the file to get rid of this message and make it work. Thank you again so much for taking the time to revise the macro.

David




Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Bruce Weaver
Administrator
David Marso's revision of the macro (posted on Sep 18) includes two REGRESSION commands with /SAVE sub-commands as follows:

   /SAVE RESID(residual) .
and
   /SAVE RESID(resid) .

Note that for /SAVE, "New variable names must be unique."  (Source:  the FM!)

So, it looks like you have two options:  

1) Modify the macro to include the names of two Residuals variables as arguments, and then make sure you hand it residual variable names that have not already been used when you call it.

2) If running the macro as is repeatedly, rename variables residual and resid before calling the 2nd time (or 3rd or 4th time, etc).  E.g.,

* Call the macro the first time.

RENAME VARIABLES (residual resid = residual_01 resid_01).
* Call the macro the second time.

RENAME VARIABLES (residual resid = residual_02 resid_02).
* Call the macro the third time.

HTH.


dbreslauer wrote
Hello Marta,
Thank you for the revised macro. It helped with the file problem, but now I get another error message.

Warnings
Invalid variable name on REGRESSION SAVE subcommand--The name selected for a variable to be saved already exists as a variable name, or has already been used on the SAVE subcommand in this procedure. Text found: residual.
Execution of this command stops.
*WARNING* REGRESSION syntax scan continues. Further diagnostics from this command may be misleading - interpret with care.

I found that I needed to delete the variables that were added to the file to get rid of this message and make it work. Thank you again so much for taking the time to revise the macro.

David
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

lascone
In reply to this post by dbreslauer
I am trying to run the subroutine in SPSS, however I am a total newbie with syntax; could you help with a brief instruction of how I can input my sample data in this command?


 INPUT PROGRAM.
- VECTOR x(20).
- LOOP #I = 1 TO 50.
- LOOP #J = 1 TO 20.
- COMPUTE x(#J) = NORMAL(1).
- END LOOP.
- END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
execute.

That would help me soooo much! Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: BREUSCH-PAGAN & KOENKER TEST MACRO -undefined variables

Jon Peck
The syntax you posted runs and creates random variables x1 to x20.  What is your actual problem?

On Sat, Jan 30, 2016 at 3:55 AM, lascone <[hidden email]> wrote:
I am trying to run the subroutine in SPSS, however I am a total newbie with
syntax; could you help with a brief instruction of how I can input my sample
data in this command?


 INPUT PROGRAM.
- VECTOR x(20).
- LOOP #I = 1 TO 50.
- LOOP #J = 1 TO 20.
- COMPUTE x(#J) = NORMAL(1).
- END LOOP.
- END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
execute.

That would help me soooo much! Thank you!



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/BREUSCH-PAGAN-KOENKER-TEST-MACRO-undefined-variables-tp5727299p5731404.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



--
Jon K Peck
[hidden email]

===================== 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