Hello,
I want to save the unstandardized regression coefficients. At this moment, i have the following syntax: DEFINE !MyRegression (y=!token(1)/ x=!enclose("[","]")) REGRESSION /MISSING LISTWISE /STATISTICS COEFF OUTS R ANOVA /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT !y /METHOD=ENTER !x. !ENDDEFINE . !MyRegression y = ER1 x = [SV1 R1] . !MyRegression y = ER2 x = [SV2 R2] . !MyRegression y = ER3 x = [SV3 R3] . !MyRegression y = ER... x = [SV... R...] . !MyRegression y = ER600 x = [SV600 R600] . EXECUTE . How can I save the coefficients of the five different regressions? |
Administrator
|
REGRESSION....../blah blah blah...
/[/OUTFILE={COVB ('savfile'|'dataset')}] [{ ...... From the FM:"OUTFILE Subcommand OUTFILE saves the parameter covariance or correlation matrix with parameter estimates, standard errors, significance values, and residual degrees of freedom for each term in the final equation in IBM® SPSS® Statistics format data files. It also saves model information in XML format..... blah blah blah......... Personally I would just do it in MATRIX language. MATRIX. .........blah blah blah COMPUTE BetaHat=T(X)*X*T(X)*Y . SAVE Betahat/OUTFILE="blah blah blah".......
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?" |
I have no experience with matrix, thus I used OUTFILE
The problem with OUTFILE is that SPSS is only saving the estimates of the last regression Can somebody give me a exact solution? |
Administrator
|
You need OUTFILE to specify a different name every time, so make the outfile name another macro parameter.
--
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 jkr570
Besides the built-in syntax in REGRESSION
for saving coefficients, you can use the more general OMS command to save
any pivot table as a dataset or in other formats. See the OMS Control
Panel on Utilities for a gui interface this and read about OMS in the CSR.
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: jkr570 <[hidden email]> To: [hidden email] Date: 05/14/2012 03:35 AM Subject: [SPSSX-L] Save Unstandardized Regression Coefficients Sent by: "SPSSX(r) Discussion" <[hidden email]> Hello, I want to save the unstandardized regression coefficients. At this moment, i have the following syntax: DEFINE !MyRegression (y=!token(1)/ x=!enclose("[","]")) REGRESSION /MISSING LISTWISE /STATISTICS COEFF OUTS R ANOVA /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT !y /METHOD=ENTER !x. !ENDDEFINE . !MyRegression y = ER1 x = [SV1 R1] . !MyRegression y = ER2 x = [SV2 R2] . !MyRegression y = ER3 x = [SV3 R3] . !MyRegression y = ER... x = [SV... R...] . !MyRegression y = ER600 x = [SV600 R600] . EXECUTE . How can I save the coefficients of the five different regressions? -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Save-Unstandardized-Regression-Coefficients-tp5708786.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 |
Administrator
|
In reply to this post by jkr570
The way you are approaching this is ludicrous!
The variables in the regressions have a very systematic structure. Restructure the file from WIDE to LONG with VARSTOCASES then use SPLIT FILE and run *ONE REGRESSION COMMAND!!!*. You really *DON'T* want to have 600 *DIFFERENT* parameter files laying about do you? Anytime you find yourself calling a MACRO 600 times you need to rethink the problem!!! --
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?" |
Administrator
|
data list free / ER1 TO ER3 SV1 TO SV3 R1 TO R3.
BEGIN DATA 5 6 3 5 1 6 5 3 6 1 5 3 6 1 5 3 6 1 5 3 6 1 5 6 3 1 5 6 7 3 1 5 6 3 5 1 6 3 5 1 6 3 5 1 2 6 7 5 3 6 7 1 5 3 6 7 1 5 3 6 7 1 5 7 3 1 6 3 6 1 5 3 6 7 1 5 3 7 6 1 5 3 6 7 1 5 3 6 1 5 6 3 1 5 6 3 1 5 6 3 5 1 6 3 5 1 6 7 3 5 6 7 1 5 3 6 7 1 5 3 6 7 1 2 5 3 END DATA. VARSTOCASES / MAKE ER FROM ER1 TO ER3 / MAKE SV FROM SV1 TO SV3 / MAKE R FROM R1 TO R3 / INDEX=VNUM (3) /ID=ID. SORT CASES BY VNUM. SPLIT FILE LAYERED BY VNUM . REGRESSION DEP ER / METHOD ENTER SV R / OUTFILE COVB( 'Betas.sav') . GET FILE 'Betas.sav'.
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?" |
Administrator
|
In reply to this post by David Marso
USING MATRIX:
data list free / ER1 TO ER3 SV1 TO SV3 R1 TO R3. BEGIN DATA 5 6 3 5 1 6 5 3 6 1 5 3 6 1 5 3 6 1 5 3 6 1 5 6 3 1 5 6 7 3 1 5 6 3 5 1 6 3 5 1 6 3 5 1 2 6 7 5 3 6 7 1 5 3 6 7 1 5 3 6 7 1 5 7 3 1 6 3 6 1 5 3 6 7 1 5 3 7 6 1 5 3 6 7 1 5 3 6 1 5 6 3 1 5 6 3 1 5 6 3 5 1 6 3 5 1 6 7 3 5 6 7 1 5 3 6 7 1 5 3 6 7 1 2 5 3 END DATA. MATRIX. GET ER /VAR ER1 TO ER3/ FILE *. GET SV /VAR SV1 TO SV3/ FILE *. GET R /VAR R1 TO R3/ FILE *. COMPUTE B=MAKE (3,4,0). LOOP #=1 TO 3. + COMPUTE X={MAKE(NROW(R),1,1),SV(:,#),R(:,#)}. + COMPUTE B(#,:)={#,T(GINV(T(X)*X)*T(X)*ER(:,#) )}. END LOOP. SAVE B / OUTFILE *. END MATRIX.
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?" |
I have used the following code, because i don't understand your code.
/OUTFILE COVB (!quote(!concat('C:\Users\Jordy Kremer\Desktop\SPSS\output', !y, '.sav'))). With three regressions, i get 3 different files. I have found acode on the internet to get all the parameters in one file. Only the underlying code isn't working. Can you see what is wrong whit underlying code. * Get all parameters in the same file; keep only the parameters estimates.. GET FILE= 'C:\Users\Jordy Kremer\Desktop\SPSS\outputER1.sav' !DO !y=2 !TO !nbvar ADD FILES FILE=* /FILE=!QUOTE(!CONCAT('C:\Users\Jordy Kremer\Desktop\SPSS\outputER',!y,'.sav')) . !DOEND SELECT IF RTRIM(rowtype_)="EST". MATCH FILES /FILE=* /RENAME (depvar_ rowtype_ varname_ = d0 d1 d2) /FILE='C:\Users\Jordy Kremer\Desktop\SPSS\Test.sav' /DROP= d0 d1 d2. EXECUTE. !ENDDEFINE. |
Administrator
|
"I have used the following code, because i don't understand your code."
VARSTOCASES. SORT. SPLIT FILE. That isn't rocket science! That is what manuals are for! If you don't understand it look up the commands in the manual and it will become clear. Without the complete definition of your MACRO and whatever error messages, I am not going to try to ESP this one. Furthermore, your original suggested 600 regressions. That is MESSY to say the least. My personal preference is the MATRIX solution because you don't require the data restructure, the sort or the split. It may look obtuse but a few minutes of manual consultation will make it clear. MATRIX. GET ER /VAR ER1 TO ER3/ FILE *. GET SV /VAR SV1 TO SV3/ FILE *. GET R /VAR R1 TO R3/ FILE *. COMPUTE B=MAKE (3,4,0). LOOP #=1 TO 3. + COMPUTE BX(#,:)={#,T(GINV({MAKE(NROW(R),1,1),SV(:,#),R(:,#)})*ER(:,#) )}. END LOOP. SAVE BX / OUTFILE *. END MATRIX. ---
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?" |
Administrator
|
Some crude benchmarks (N=10000, P=600 -p=1,k=2-) .
Using V2C/SORT Split 100 seconds. using Matrix 19.32 seconds Using the iterated macro (extrapolated from P at 105 seconds=38 -> 27 minutes!!! This does ***NOT*** include concatenating the 600 Files which would take another LONG stretch ***. ---------------------------------------- **** Generate some data **** 10,000 cases of each of 1800 variables ***. INPUT PROGRAM. + NUMERIC ER001 TO ER600 SV001 TO SV600 R001 TO R600. + LOOP #=1 TO 10000. + DO REPEAT ER=ER001 TO ER600 /SV=SV001 TO SV600 /R=R001 TO R600. + COMPUTE SV=NORMAL(1). + COMPUTE R= NORMAL(1). + COMPUTE ER=SUM(SV*.5,R*.70,NORMAL(1)). + END REPEAT. + END CASE. + END LOOP. + END FILE. END INPUT PROGRAM. SAVE OUTFILE 'tmpregdata.sav'. GET FILE 'tmpregdata.sav'. DEFINE Blah () !DO !@= 1 !TO 600. !IF (!LENGTH(!@) !EQ 1) !THEN !LET !I=!CONCAT("00",!@) !IFEND. !IF (!LENGTH(!@) !EQ 2) !THEN !LET !I=!CONCAT("0",!@) !IFEND. REG / DEP !CONCAT(ER,!I) / METHOD ENTER !CONCAT(SV,!I) !CONCAT(R,!I) / OUTFILE COVB( !QUOTE(!CONCAT("C:\Temp\Betas_",!I,'.sav'))). !DOEND !ENDDEFINE. SET MPRINT ON. Blah. **38 completed at sw 1:45 extrapolate to over 27 minutes. VARSTOCASES / MAKE ER FROM ER001 TO ER600 / MAKE SV FROM SV001 TO SV600 / MAKE R FROM R001 TO R600 / INDEX=VNUM (600) /ID=ID. SORT CASES BY VNUM. SPLIT FILE LAYERED BY VNUM . REGRESSION DEP ER / METHOD ENTER SV R / OUTFILE COVB( 'Betas.sav') . *1:41.45 *. PRESERVE. GET FILE tmpregdata.sav. SET MXLOOPS 600. MATRIX. GET data /VAR ER001 TO ER600 SV001 TO SV600 R001 TO R600/ FILE *. COMPUTE B=MAKE (600,4,0). LOOP #=1 TO 600. + COMPUTE B(#,:)={#,T(GINV({MAKE(NROW(data),1,1),data(:,#+600),data(:,#+1200)})*data(:,#))}. END LOOP. SAVE B / OUTFILE * / VARIABLES vnum, const, b_sv, b_r. END MATRIX. RESTORE. *19.32 . MATCH FILES / TABLE * / FILE 'Betas.sav' / BY VNUM . SELECT IF ROWTYPE_="EST". COMPUTE D2=SUM((const-const_)**2,(b_sv-sv)**2,(r-b_r)**2). COMPUTE DABS=SUM(ABS(const-const_),ABS(b_sv-sv),ABS(r-b_r)). FORMATS const b_sv b_r const_ sv r d2 DABS(F20.16). DESC const const_ b_sv sv b_r r d2 DABS/STAT MIN MAX MEAN STDDEV SUM.
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?" |
Free forum by Nabble | Edit this page |