Simple Regression Output

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

Simple Regression Output

Riya
This post was updated on .
Hey Everyone,

I am running a simple regression analysis including 26 variables. Taking 2 variables at a time , one variable would be dependent and other one would be independent one. For 26 variables , i have to perform this task 25 times. I thought to automate this using SPSS macro. I succeeded it to a some extent. However, my requirement is to save UNSTANDARDIZED BETA ONLY for all the 25 independent variables to a single data file in SPSS or excel .

Following the syntax that i developed :

DEFINE !var (items = !CMDEND)
!DO !vara !IN (!items)
REGRESSION
  /MISSING LISTWISE
  /STATISTICS COEFF
  /CRITERIA=PIN(.05) POUT(.10)
  /NOORIGIN
  /DEPENDENT var1
  /METHOD=ENTER !vara.
!DOEND
!ENDDEFINE.

!var items= var2 var3.

I know how to export the output using OMS and selecting a particular table. But that will create multiple datasets. I wish to collaborate them in a single datafile.

Thanks and Regards
Riya
Reply | Threaded
Open this post in threaded view
|

Re: Simple Regression Output

Bruce Weaver
Administrator
I would suggest using something other than !var as your macro name.  How about !MyReg instead?  

* Example using 1991 GSS data file.

new file.
dataset close all.
get file = "C:\SPSSdata\1991 U.S. General Social Survey.sav".
dataset name raw.

DEFINE !MyReg (items = !CMDEND)
!DO !vara !IN (!items)
REGRESSION
  /MISSING LISTWISE
  /STATISTICS COEFF
  /CRITERIA=PIN(.05) POUT(.10)
  /NOORIGIN
  /DEPENDENT prestg80
  /METHOD=ENTER !vara.
!DOEND
!ENDDEFINE.


* OMS.
DATASET DECLARE  Coeff.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Regression'] SUBTYPES=['Coefficients']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='Coeff'.

!MyReg items = age educ paeduc maeduc speduc.

OMSEND.
dataset activate Coeff.
select if Var2 NE "(Constant)".
list Var2 B.

* Use DELETE VARIABLES if you want to delete variables other than Var2 and B.
* Var2 could be AUTORECODEd to numeric too.


Now let's wait for David to show us a neat MATRIX method for doing the same thing.  ;-)


Riya wrote
Hey Everyone,

I am running a simple regression analysis including 26 variables. Taking 2 variables at a time , one variable would be dependent and other one would be independent one. For 26 variables , i have to perform this task 25 times. I thought to automate this using SPSS macro. I succeeded it to a some extent. However, my requirement is to save UNSTANDARDIZED BETA ONLY for all the 25 independent variables to a single data file in SPSS or excel .

Following the syntax that i developed :

DEFINE !var (items = !CMDEND)
!DO !vara !IN (!items)
REGRESSION
  /MISSING LISTWISE
  /STATISTICS COEFF
  /CRITERIA=PIN(.05) POUT(.10)
  /NOORIGIN
  /DEPENDENT var1
  /METHOD=ENTER !vara.
!DOEND
!ENDDEFINE.

!var items= var2 var3.

I know how to export the output using OMS and selecting a particular table. But that will create multiple datasets. I wish to collaborate them in a single datafile.

Thanks and Regards
Riya
--
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: Simple Regression Output

Riya
Thanks a ton Bruce :)  I was unaware of this syntax NUMBERED=TableNumber_ OUTFILE= in OMS. Does this option exist in GUI? I was searching that but couldn't find it.
Reply | Threaded
Open this post in threaded view
|

Re: Simple Regression Output

Bruce Weaver
Administrator
Click on Utilities - OMS Control Panel, explore and select the options you want, then exit via PASTE!  ;-)



Riya wrote
Thanks a ton Bruce :)  I was unaware of this syntax NUMBERED=TableNumber_ OUTFILE= in OMS. Does this option exist in GUI? I was searching that but couldn't find it.
--
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: Simple Regression Output

David Marso
Administrator
In reply to this post by Bruce Weaver
"Now let's wait for David to show us a neat MATRIX method for doing the same thing.  ;-)".

You scoundrel [FILTERED] !! You knew I would bite! ;-))).
Actually needed a short break from my nervous breakdown .

*---Simulate some data ---*.
INPUT PROGRAM.
NUMERIC VAR01 TO VAR35 (F8.3).
VECTOR VAR=VAR01 TO VAR35 .
LOOP CASE=1 TO 300.
+  COMPUTE VAR(1)= NORMAL(1).
+  LOOP #=2 TO 35.
+    COMPUTE VAR(#)=VAR(#-1)*.80+ NORMAL(1).
+  END LOOP.
+  END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE .
DATASET NAME RAW.

**-----Uses first variable in file as dependent.  The rest are entered as independent individually**.
DATASET DECLARE REG.
MATRIX.
GET DATA /FILE * / VAR ALL.
COMPUTE Y=DATA(:,1).
COMPUTE ONE=MAKE(NROW(DATA),1,1).
LOOP #=2 TO NCOL(DATA).
COMPUTE X={ONE,DATA(:,#)}.
SAVE (T(GINV(T(X)*X )*T(X)*Y)) / OUTFILE reg /VARIABLES Const B1.
END LOOP.
END MATRIX.

**--There may be a cleaner way to merge in the variable names --*.
DATASET ACTIVATE RAW.
DATASET COPY Rawcopy.
SELECT IF $CASENUM=1.
FLIP.
SELECT IF CASE_LBL NE "VAR01".

MATCH FILES FILE * / FILE REG.
EXECUTE.
DELETE VARIABLES Var001.
FORMATS ALL (F10.8).

Bruce Weaver wrote
I would suggest using something other than !var as your macro name.  How about !MyReg instead?  

* Example using 1991 GSS data file.

new file.
dataset close all.
get file = "C:\SPSSdata\1991 U.S. General Social Survey.sav".
dataset name raw.

DEFINE !MyReg (items = !CMDEND)
!DO !vara !IN (!items)
REGRESSION
  /MISSING LISTWISE
  /STATISTICS COEFF
  /CRITERIA=PIN(.05) POUT(.10)
  /NOORIGIN
  /DEPENDENT prestg80
  /METHOD=ENTER !vara.
!DOEND
!ENDDEFINE.


* OMS.
DATASET DECLARE  Coeff.
OMS
  /SELECT TABLES
  /IF COMMANDS=['Regression'] SUBTYPES=['Coefficients']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_
   OUTFILE='Coeff'.

!MyReg items = age educ paeduc maeduc speduc.

OMSEND.
dataset activate Coeff.
select if Var2 NE "(Constant)".
list Var2 B.

* Use DELETE VARIABLES if you want to delete variables other than Var2 and B.
* Var2 could be AUTORECODEd to numeric too.


Now let's wait for David to show us a neat MATRIX method for doing the same thing.  ;-)


Riya wrote
Hey Everyone,

I am running a simple regression analysis including 26 variables. Taking 2 variables at a time , one variable would be dependent and other one would be independent one. For 26 variables , i have to perform this task 25 times. I thought to automate this using SPSS macro. I succeeded it to a some extent. However, my requirement is to save UNSTANDARDIZED BETA ONLY for all the 25 independent variables to a single data file in SPSS or excel .

Following the syntax that i developed :

DEFINE !var (items = !CMDEND)
!DO !vara !IN (!items)
REGRESSION
  /MISSING LISTWISE
  /STATISTICS COEFF
  /CRITERIA=PIN(.05) POUT(.10)
  /NOORIGIN
  /DEPENDENT var1
  /METHOD=ENTER !vara.
!DOEND
!ENDDEFINE.

!var items= var2 var3.

I know how to export the output using OMS and selecting a particular table. But that will create multiple datasets. I wish to collaborate them in a single datafile.

Thanks and Regards
Riya
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: Simple Regression Output

Riya
Thanks a bunch David :) Your response to my query gives me an opportunity to learn new things . This time  i I need to read INPUT PROGRAM from RTFM :))
Reply | Threaded
Open this post in threaded view
|

Re: Simple Regression Output

David Marso
Administrator
INPUT PROGRAM is a great way to generate material for simulation and reading complex files.
There are not a lot of examples in the FM however if you search the archives you will find plenty.
Here is one such search.
http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=search_page&node=1068821&query=INPUT+PROGRAM&sort=date
When you find an example, you will want to refer to FM to get insight into the various commands used.
Notably:
LOOP -END LOOP, VECTOR , DO REPEAT, LEAVE, END CASE, END FILE and many others.
Definitely look at the INPUT PROGRAM-END INPUT PROGRAM to get the lay of the land.
---
In my previous posting the IP is incidental,  The meat is the MATRIX -END MATRIX.


Riya wrote
Thanks a bunch David :) Your response to my query gives me an opportunity to learn new things . This time  i I need to read INPUT PROGRAM from RTFM :))
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
|

Automatic reply: Simple Regression Output

Tierney, Mary Lou

On Wednesday and Thursday 20-21 March, I am at our McLean campus and in meetings for the majority of both days.  I will respond to email in the evenings.

 

Please contact:

 

·         [hidden email] for questions or assistance with FY14 proposal process questions including Idea Market, Strategy Market or Innovation@MITRE (sponsor portal)

·         [hidden email] for questions or assistance with MIP funded project processes or the website

·         [hidden email] for questions about or assistance with MIP ProjectPages (page functionality, content on the pages, i.e. PI name, project title, etc.)

·         [hidden email] for questions about charge numbers

·         [hidden email] for assistance with other Innovation Zone sites, such as CI&T InZone

 

Regards,

Mary Lou

Reply | Threaded
Open this post in threaded view
|

Re: Simple Regression Output

Riya
In reply to this post by David Marso
Yeah right "  The meat is the MATRIX -END MATRIX ". I have a basic understanding of MATRIX-END MATRIX function. But, INPUT-END INPUT is completely greek to me . Thanks for sharing the link :)
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Simple Regression Output

Weinberg, Jerry
In reply to this post by Riya

I will be away from my office from 3/20 to 3/31.