• Loop a Regression Analysis (Newbie here)

    From mad00geo@gmail.com@21:1/5 to All on Tue Jul 16 04:05:33 2019
    So i am working on my master thesis and i need to do a regression analysis. I have used SPSS but i am a newbie when it comes to the syntax part. Basically i have to loop a 100 dependent variables with a independent variable. After a quick search over
    here i found a previous thread about creating a macro and running the regression syntax and the funny thing is it did work yesterday but today running the same syntax i can't evoke the macro and it's returning an error.

    I get two errors. One is that the !MyReg isn't recognized by SPSS and the second, it breaks at a certain point when going through the variable.

    This is the code. It'd be really helpful if someone could point out what i am doing wrong.

    Thanks in advance!

    DATASET ACTIVATE DataSet1.

    DEFINE !MyReg (Ylist = !CMDEND)

    !DO !Y !IN(!Ylist)

    REGRESSION

    /DESCRIPTIVES MEAN STDDEV CORR SIG N

    /MISSING LISTWISE

    /STATISTICS COEFF OUTS CI(95) BCOV R ANOVA CHANGE

    /CRITERIA=PIN(.05) POUT(.10)

    /NOORIGIN

    /DEPENDENT !Y

    /METHOD=ENTER RP.

    !DOEND

    !ENDDEFINE



    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028

    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042

    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056

    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070

    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084

    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098

    VAR00099 VAR00100 VAR00101

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mad00geo@gmail.com@21:1/5 to Bruce Weaver on Tue Jul 16 04:53:16 2019
    On Tuesday, July 16, 2019 at 1:42:23 PM UTC+2, Bruce Weaver wrote:
    On Tuesday, July 16, 2019 at 7:05:34 AM UTC-4, mad0...@gmail.com wrote:
    So i am working on my master thesis and i need to do a regression analysis. I have used SPSS but i am a newbie when it comes to the syntax part. Basically i have to loop a 100 dependent variables with a independent variable. After a quick search over
    here i found a previous thread about creating a macro and running the regression syntax and the funny thing is it did work yesterday but today running the same syntax i can't evoke the macro and it's returning an error.

    I get two errors. One is that the !MyReg isn't recognized by SPSS and the second, it breaks at a certain point when going through the variable.

    This is the code. It'd be really helpful if someone could point out what i am doing wrong.

    Thanks in advance!

    DATASET ACTIVATE DataSet1.

    DEFINE !MyReg (Ylist = !CMDEND)

    !DO !Y !IN(!Ylist)

    REGRESSION

    /DESCRIPTIVES MEAN STDDEV CORR SIG N

    /MISSING LISTWISE

    /STATISTICS COEFF OUTS CI(95) BCOV R ANOVA CHANGE

    /CRITERIA=PIN(.05) POUT(.10)

    /NOORIGIN

    /DEPENDENT !Y

    /METHOD=ENTER RP.

    !DOEND

    !ENDDEFINE



    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028

    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042

    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056

    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070

    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084

    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098

    VAR00099 VAR00100 VAR00101



    There is no command terminator (i.e., a period) at the end of your macro call.

    That's an awfully large number of DVs. What are you doing about the so-called "multiplicity problem"? Two of the most thoughtful articles I've read on that issue are these two by Schulz & Grimes. It might be worth having a look at them.

    https://www.ncbi.nlm.nih.gov/pubmed/15866314 https://www.ncbi.nlm.nih.gov/pubmed/15885299

    HTH.

    So i did put a period at the end of the macro call but ended up with the following error.
    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    Error # 1. Command name: !MyReg
    The first word in the line is not recognized as an SPSS Statistics command. >Execution of this command stops.
    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028
    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042
    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056
    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070
    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084
    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098
    VAR00099 VAR00100 VAR00101 .


    I'll take a look at the articles.
    Is there any other way to run a regression for a 100 dependent variables. I have to do another regression which will include additionally a 100 independent variables (also looping according to the dependent variable). It's a regression analysis for 100
    stock portfolios, dependent variable being the portfolio return.
    Thank you.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bruce Weaver@21:1/5 to mad0...@gmail.com on Tue Jul 16 04:42:21 2019
    On Tuesday, July 16, 2019 at 7:05:34 AM UTC-4, mad0...@gmail.com wrote:
    So i am working on my master thesis and i need to do a regression analysis. I have used SPSS but i am a newbie when it comes to the syntax part. Basically i have to loop a 100 dependent variables with a independent variable. After a quick search over
    here i found a previous thread about creating a macro and running the regression syntax and the funny thing is it did work yesterday but today running the same syntax i can't evoke the macro and it's returning an error.

    I get two errors. One is that the !MyReg isn't recognized by SPSS and the second, it breaks at a certain point when going through the variable.

    This is the code. It'd be really helpful if someone could point out what i am doing wrong.

    Thanks in advance!

    DATASET ACTIVATE DataSet1.

    DEFINE !MyReg (Ylist = !CMDEND)

    !DO !Y !IN(!Ylist)

    REGRESSION

    /DESCRIPTIVES MEAN STDDEV CORR SIG N

    /MISSING LISTWISE

    /STATISTICS COEFF OUTS CI(95) BCOV R ANOVA CHANGE

    /CRITERIA=PIN(.05) POUT(.10)

    /NOORIGIN

    /DEPENDENT !Y

    /METHOD=ENTER RP.

    !DOEND

    !ENDDEFINE



    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028

    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042

    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056

    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070

    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084

    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098

    VAR00099 VAR00100 VAR00101



    There is no command terminator (i.e., a period) at the end of your macro call.

    That's an awfully large number of DVs. What are you doing about the so-called "multiplicity problem"? Two of the most thoughtful articles I've read on that issue are these two by Schulz & Grimes. It might be worth having a look at them.

    https://www.ncbi.nlm.nih.gov/pubmed/15866314 https://www.ncbi.nlm.nih.gov/pubmed/15885299

    HTH.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bruce Weaver@21:1/5 to mad0...@gmail.com on Tue Jul 16 07:50:52 2019
    On Tuesday, July 16, 2019 at 7:53:18 AM UTC-4, mad0...@gmail.com wrote:
    On Tuesday, July 16, 2019 at 1:42:23 PM UTC+2, Bruce Weaver wrote:
    On Tuesday, July 16, 2019 at 7:05:34 AM UTC-4, mad0...@gmail.com wrote:
    So i am working on my master thesis and i need to do a regression analysis. I have used SPSS but i am a newbie when it comes to the syntax part. Basically i have to loop a 100 dependent variables with a independent variable. After a quick search
    over here i found a previous thread about creating a macro and running the regression syntax and the funny thing is it did work yesterday but today running the same syntax i can't evoke the macro and it's returning an error.

    I get two errors. One is that the !MyReg isn't recognized by SPSS and the second, it breaks at a certain point when going through the variable.

    This is the code. It'd be really helpful if someone could point out what i am doing wrong.

    Thanks in advance!

    DATASET ACTIVATE DataSet1.

    DEFINE !MyReg (Ylist = !CMDEND)

    !DO !Y !IN(!Ylist)

    REGRESSION

    /DESCRIPTIVES MEAN STDDEV CORR SIG N

    /MISSING LISTWISE

    /STATISTICS COEFF OUTS CI(95) BCOV R ANOVA CHANGE

    /CRITERIA=PIN(.05) POUT(.10)

    /NOORIGIN

    /DEPENDENT !Y

    /METHOD=ENTER RP.

    !DOEND

    !ENDDEFINE



    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028

    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042

    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056

    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070

    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084

    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098

    VAR00099 VAR00100 VAR00101



    There is no command terminator (i.e., a period) at the end of your macro call.

    That's an awfully large number of DVs. What are you doing about the so-called "multiplicity problem"? Two of the most thoughtful articles I've read on that issue are these two by Schulz & Grimes. It might be worth having a look at them.

    https://www.ncbi.nlm.nih.gov/pubmed/15866314 https://www.ncbi.nlm.nih.gov/pubmed/15885299

    HTH.

    So i did put a period at the end of the macro call but ended up with the following error.
    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    Error # 1. Command name: !MyReg
    The first word in the line is not recognized as an SPSS Statistics command. >Execution of this command stops.
    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028
    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042
    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056
    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070
    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084
    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098
    VAR00099 VAR00100 VAR00101 .


    I'll take a look at the articles.
    Is there any other way to run a regression for a 100 dependent variables. I have to do another regression which will include additionally a 100 independent variables (also looping according to the dependent variable). It's a regression analysis for 100
    stock portfolios, dependent variable being the portfolio return.
    Thank you.

    You could restructure the file from WIDE to LONG and then use SPLIT FILE. E.g.,

    * Restructure data from WIDE to LONG.
    VARSTOCASES
    /ID=ID
    /MAKE Y FROM VAR00002 TO VAR00101
    /INDEX=DV(100)
    /KEEP=RP
    /NULL=KEEP.

    * Make DV inedex variable match the numbers on the original variables.
    COMPUTE DV = DV+1.
    SORT CASES BY DV.
    SPLIT FILE BY DV.
    REGRESSION
    /STATISTICS COEFF OUTS CI(95) R ANOVA
    /DEPENDENT Y
    /METHOD=ENTER RP.
    SPLIT FILE OFF.

    With so many outcome variables, I would also use OMS to direct the needed bits of regression output to a new dataset for further processing. You can find examples in the documentation or by Googling <SPSS OMS>.

    HTH.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mad00geo@gmail.com@21:1/5 to Bruce Weaver on Tue Jul 16 09:01:40 2019
    On Tuesday, July 16, 2019 at 4:50:54 PM UTC+2, Bruce Weaver wrote:
    On Tuesday, July 16, 2019 at 7:53:18 AM UTC-4, mad0...@gmail.com wrote:
    On Tuesday, July 16, 2019 at 1:42:23 PM UTC+2, Bruce Weaver wrote:
    On Tuesday, July 16, 2019 at 7:05:34 AM UTC-4, mad0...@gmail.com wrote:
    So i am working on my master thesis and i need to do a regression analysis. I have used SPSS but i am a newbie when it comes to the syntax part. Basically i have to loop a 100 dependent variables with a independent variable. After a quick search
    over here i found a previous thread about creating a macro and running the regression syntax and the funny thing is it did work yesterday but today running the same syntax i can't evoke the macro and it's returning an error.

    I get two errors. One is that the !MyReg isn't recognized by SPSS and the second, it breaks at a certain point when going through the variable.

    This is the code. It'd be really helpful if someone could point out what i am doing wrong.

    Thanks in advance!

    DATASET ACTIVATE DataSet1.

    DEFINE !MyReg (Ylist = !CMDEND)

    !DO !Y !IN(!Ylist)

    REGRESSION

    /DESCRIPTIVES MEAN STDDEV CORR SIG N

    /MISSING LISTWISE

    /STATISTICS COEFF OUTS CI(95) BCOV R ANOVA CHANGE

    /CRITERIA=PIN(.05) POUT(.10)

    /NOORIGIN

    /DEPENDENT !Y

    /METHOD=ENTER RP.

    !DOEND

    !ENDDEFINE



    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028

    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042

    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056

    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070

    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084

    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098

    VAR00099 VAR00100 VAR00101



    There is no command terminator (i.e., a period) at the end of your macro call.

    That's an awfully large number of DVs. What are you doing about the so-called "multiplicity problem"? Two of the most thoughtful articles I've read on that issue are these two by Schulz & Grimes. It might be worth having a look at them.

    https://www.ncbi.nlm.nih.gov/pubmed/15866314 https://www.ncbi.nlm.nih.gov/pubmed/15885299

    HTH.

    So i did put a period at the end of the macro call but ended up with the following error.
    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    Error # 1. Command name: !MyReg
    The first word in the line is not recognized as an SPSS Statistics command.
    Execution of this command stops.
    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028
    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042
    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056
    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070
    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084
    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098
    VAR00099 VAR00100 VAR00101 .


    I'll take a look at the articles.
    Is there any other way to run a regression for a 100 dependent variables. I have to do another regression which will include additionally a 100 independent variables (also looping according to the dependent variable). It's a regression analysis for
    100 stock portfolios, dependent variable being the portfolio return.
    Thank you.

    You could restructure the file from WIDE to LONG and then use SPLIT FILE. E.g.,

    * Restructure data from WIDE to LONG.
    VARSTOCASES
    /ID=ID
    /MAKE Y FROM VAR00002 TO VAR00101
    /INDEX=DV(100)
    /KEEP=RP
    /NULL=KEEP.

    * Make DV inedex variable match the numbers on the original variables. COMPUTE DV = DV+1.
    SORT CASES BY DV.
    SPLIT FILE BY DV.
    REGRESSION
    /STATISTICS COEFF OUTS CI(95) R ANOVA
    /DEPENDENT Y
    /METHOD=ENTER RP.
    SPLIT FILE OFF.

    With so many outcome variables, I would also use OMS to direct the needed bits of regression output to a new dataset for further processing. You can find examples in the documentation or by Googling <SPSS OMS>.

    HTH.

    I got the first code to work finally. There was a period at the end of /METHOD=ENTER RP. Once i removed the period the code worked.

    Could you guide me on how to modify the first code if i need to add an independent variable that would loop as per the dependent variable? That is for VAR00002 an independent variable Ind1, for VAR00003 Ind2 and so on till VAR00101 Ind100.

    Thanks for your help!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bruce Weaver@21:1/5 to mad0...@gmail.com on Tue Jul 16 11:32:31 2019
    On Tuesday, July 16, 2019 at 12:01:43 PM UTC-4, mad0...@gmail.com wrote:
    On Tuesday, July 16, 2019 at 4:50:54 PM UTC+2, Bruce Weaver wrote:
    On Tuesday, July 16, 2019 at 7:53:18 AM UTC-4, mad0...@gmail.com wrote:
    On Tuesday, July 16, 2019 at 1:42:23 PM UTC+2, Bruce Weaver wrote:
    On Tuesday, July 16, 2019 at 7:05:34 AM UTC-4, mad0...@gmail.com wrote:
    So i am working on my master thesis and i need to do a regression analysis. I have used SPSS but i am a newbie when it comes to the syntax part. Basically i have to loop a 100 dependent variables with a independent variable. After a quick
    search over here i found a previous thread about creating a macro and running the regression syntax and the funny thing is it did work yesterday but today running the same syntax i can't evoke the macro and it's returning an error.

    I get two errors. One is that the !MyReg isn't recognized by SPSS and the second, it breaks at a certain point when going through the variable.

    This is the code. It'd be really helpful if someone could point out what i am doing wrong.

    Thanks in advance!

    DATASET ACTIVATE DataSet1.

    DEFINE !MyReg (Ylist = !CMDEND)

    !DO !Y !IN(!Ylist)

    REGRESSION

    /DESCRIPTIVES MEAN STDDEV CORR SIG N

    /MISSING LISTWISE

    /STATISTICS COEFF OUTS CI(95) BCOV R ANOVA CHANGE

    /CRITERIA=PIN(.05) POUT(.10)

    /NOORIGIN

    /DEPENDENT !Y

    /METHOD=ENTER RP.

    !DOEND

    !ENDDEFINE



    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028

    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042

    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056

    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070

    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084

    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098

    VAR00099 VAR00100 VAR00101



    There is no command terminator (i.e., a period) at the end of your macro call.

    That's an awfully large number of DVs. What are you doing about the so-called "multiplicity problem"? Two of the most thoughtful articles I've read on that issue are these two by Schulz & Grimes. It might be worth having a look at them.

    https://www.ncbi.nlm.nih.gov/pubmed/15866314 https://www.ncbi.nlm.nih.gov/pubmed/15885299

    HTH.

    So i did put a period at the end of the macro call but ended up with the following error.
    !MyReg Ylist = VAR00002 VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 VAR00008 VAR00009 VAR00010 VAR00011 VAR00012 VAR00013 VAR00014

    Error # 1. Command name: !MyReg
    The first word in the line is not recognized as an SPSS Statistics command.
    Execution of this command stops.
    VAR00015 VAR00016 VAR00017 VAR00018 VAR00019 VAR00020 VAR00021 VAR00022 VAR00023 VAR00024 VAR00025 VAR00026 VAR00027 VAR00028
    VAR00029 VAR00030 VAR00031 VAR00032 VAR00033 VAR00034 VAR00035 VAR00036 VAR00037 VAR00038 VAR00039 VAR00040 VAR00041 VAR00042
    VAR00043 VAR00044 VAR00045 VAR00046 VAR00047 VAR00048 VAR00049 VAR00050 VAR00051 VAR00052 VAR00053 VAR00054 VAR00055 VAR00056
    VAR00057 VAR00058 VAR00059 VAR00060 VAR00061 VAR00062 VAR00063 VAR00064 VAR00065 VAR00066 VAR00067 VAR00068 VAR00069 VAR00070
    VAR00071 VAR00072 VAR00073 VAR00074 VAR00075 VAR00076 VAR00077 VAR00078 VAR00079 VAR00080 VAR00081 VAR00082 VAR00083 VAR00084
    VAR00085 VAR00086 VAR00087 VAR00088 VAR00089 VAR00090 VAR00091 VAR00092 VAR00093 VAR00094 VAR00095 VAR00096 VAR00097 VAR00098
    VAR00099 VAR00100 VAR00101 .


    I'll take a look at the articles.
    Is there any other way to run a regression for a 100 dependent variables. I have to do another regression which will include additionally a 100 independent variables (also looping according to the dependent variable). It's a regression analysis for
    100 stock portfolios, dependent variable being the portfolio return.
    Thank you.

    You could restructure the file from WIDE to LONG and then use SPLIT FILE. E.g.,

    * Restructure data from WIDE to LONG.
    VARSTOCASES
    /ID=ID
    /MAKE Y FROM VAR00002 TO VAR00101
    /INDEX=DV(100)
    /KEEP=RP
    /NULL=KEEP.

    * Make DV inedex variable match the numbers on the original variables. COMPUTE DV = DV+1.
    SORT CASES BY DV.
    SPLIT FILE BY DV.
    REGRESSION
    /STATISTICS COEFF OUTS CI(95) R ANOVA
    /DEPENDENT Y
    /METHOD=ENTER RP.
    SPLIT FILE OFF.

    With so many outcome variables, I would also use OMS to direct the needed bits of regression output to a new dataset for further processing. You can find examples in the documentation or by Googling <SPSS OMS>.

    HTH.

    I got the first code to work finally. There was a period at the end of /METHOD=ENTER RP. Once i removed the period the code worked.

    Could you guide me on how to modify the first code if i need to add an independent variable that would loop as per the dependent variable? That is for VAR00002 an independent variable Ind1, for VAR00003 Ind2 and so on till VAR00101 Ind100.

    Thanks for your help!

    It gets a bit messier when you want the macro to step through two lists in parallel. You need to use !HEAD and !TAIL functions, as shown in some of the examples here:

    http://www.angelfire.com/wv/bwhomedir/spss/SLR_macro_v2.txt

    I think you might find that restructuring from WIDE to LONG and then using SPLIT FILE is easier. Here's a scaled down example.


    * Create a small fake dataset to illustrate.
    NEW FILE.
    DATA LIST LIST / VAR00002 VAR00003 VAR00004 Ind1 Ind2 Ind3 (6F5.0).
    BEGIN DATA
    40 50 55 60 58 49
    50 52 54 64 44 71
    60 49 57 59 39 57
    END DATA.

    * Restructure data from WIDE to LONG.
    VARSTOCASES
    /ID=ID
    /MAKE Y FROM VAR00002 TO VAR00004
    /MAKE X FROM Ind1 TO Ind3
    /INDEX=Model(3)
    /NULL=KEEP.

    * Make DV inedex variable match the numbers on the original variables.
    SORT CASES BY Model.
    SPLIT FILE BY Model.
    REGRESSION
    /STATISTICS COEFF OUTS CI(95) R ANOVA
    /DEPENDENT Y
    /METHOD=ENTER X.
    SPLIT FILE OFF.

    * With a large number of DVs, consider using OMS to direct the
    * desired bits of output to a new dataset for further processing.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)