SPSS 17 / Vista
I would like to use the coefficients, which were saved from a regression in a sav-file, within a new data file. Here the example: http://www.frag-einen-statistiker.de/spss/koeffizientenmatrix.sav for example: compute pb21lay_c = 1,194 * standard_lay2 + ... + 1,112 plus all the other variables (8 variables alltogether) couldn't find a solution. Thanks
Dr. Frank Gaeth
|
Since you have already captured the coefficients,
you could use MATRIX for this.
Alternatively, read the dataset with programmability and generate the required COMPUTE statements from it and use spss.Submit to run them. Jon Peck (no "h") Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: drfg2008 <[hidden email]> To: [hidden email] Date: 08/20/2011 01:58 PM Subject: [SPSSX-L] use saved coefficients from a regression in the data file Sent by: "SPSSX(r) Discussion" <[hidden email]> SPSS 17 / Vista I would like to use the coefficients, which were saved from a regression in a sav-file, within a new data file. Here the example: http://www.frag-einen-statistiker.de/spss/koeffizientenmatrix.sav for example: compute pb21lay_c = 1,194 * standard_lay2 + ... + 1,112 plus all the other variables (8 variables alltogether) couldn't find a solution. Thanks ----- Dr. Frank Gaeth FU-Berlin -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/use-saved-coefficients-from-a-regression-in-the-data-file-tp4719101p4719101.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 |
read the dataset with programmability
The only way I figured out so far is to use means tables [1] or CTABLES [2] (to read the data) and combine it with python [3]. Is that what is meant by programmability? Or is there a more straight forward way to it. Frank [1] MEANS TABLES=pb02back_c pb02lay_c pb12back_c pb12lay_c pb20back_c pb20lay_c pb21back_c pb21lay_c BY term /CELLS MEAN. [2] CTABLES /VLABELS VARIABLES=term DISPLAY=DEFAULT /VLABELS VARIABLES=pb02back_c pb02lay_c pb12back_c pb12lay_c pb20back_c pb20lay_c pb21back_c pb21lay_c DISPLAY=BOTH /TABLE term BY pb02back_c [MEAN] + pb02lay_c [MEAN] + pb12back_c [MEAN] + pb12lay_c [MEAN] + pb20back_c [MEAN] + pb20lay_c [MEAN] + pb21back_c [MEAN] + pb21lay_c [MEAN] /CATEGORIES VARIABLES=term ORDER=A KEY=VALUE EMPTY=EXCLUDE. [3] desc_table,errcode=spssaux.CreateXMLOutput(cmd, omsid= ...
Dr. Frank Gaeth
|
Administrator
|
Frank,
I have absolutely NO idea what you are up here to with CTABLES .... and OMS?? WTF is the point of that? Jon suggested MATRIX. I suggest you try his suggestion. ;-) Say your coefficients are in some SPSS system file Beta.sav .(Px1) Your Independent vars are in a SPSS system file RawX.sav . (NxP) UNTESTED off the cuff code -and it probably WORKS-. You may need to add a column of 1's to Raw.Sav for constant term. You can do that in MATRIX or outside. May need to alter the !VARS list accordingly. DEFINE !VARS () pb02back_c pb02lay_c pb12back_c pb12lay_c pb20back_c pb20lay_c pb21back_c pb21lay_c !ENDDEFINE . MATRIX. GET X /VARIABLES !VARS / FILE "RawX.sav". GET Beta / VARIABLES !VARS / FILE "Beta.sav". COMPUTE Pred=X*Beta. COMPUTE SNames={ !VARS, Predicted }. SAVE { X, Pred } / NAMES= SNames/ OUTFILE *. END MATRIX. Hey Look PEEPS, No freakin Python!!!!! HTH, David --
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?" |
In reply to this post by drfg2008
MEANS and CTABLES don't have anything to
do with the solutions I suggested. You can save the regression coefficients
using either OMS or REGRESSION command syntax ( /OUTFILE=COVB(coefs).)
You can read that into MATRIX along with the main dataset, extract the relevant columns, and use matrix operations to create the product. Or you could write Python code to read the coefficient matrix and generate transformation commands. But you don't need to do that here. HTH, Jon Peck (no "h") Senior Software Engineer, IBM [hidden email] new phone: 720-342-5621 From: drfg2008 <[hidden email]> To: [hidden email] Date: 08/23/2011 06:14 AM Subject: Re: [SPSSX-L] use saved coefficients from a regression in the data file Sent by: "SPSSX(r) Discussion" <[hidden email]> /read the dataset with programmability/ The only way I figured out so far is to use means tables [1] or CTABLES [2] (to read the data) and combine it with python [3]. Is that what is meant by programmability? Or is there a more straight forward way to it. Frank [1] MEANS TABLES=pb02back_c pb02lay_c pb12back_c pb12lay_c pb20back_c pb20lay_c pb21back_c pb21lay_c BY term /CELLS MEAN. [2] CTABLES /VLABELS VARIABLES=term DISPLAY=DEFAULT /VLABELS VARIABLES=pb02back_c pb02lay_c pb12back_c pb12lay_c pb20back_c pb20lay_c pb21back_c pb21lay_c DISPLAY=BOTH /TABLE term BY pb02back_c [MEAN] + pb02lay_c [MEAN] + pb12back_c [MEAN] + pb12lay_c [MEAN] + pb20back_c [MEAN] + pb20lay_c [MEAN] + pb21back_c [MEAN] + pb21lay_c [MEAN] /CATEGORIES VARIABLES=term ORDER=A KEY=VALUE EMPTY=EXCLUDE. [3] desc_table,errcode=spssaux.CreateXMLOutput(cmd, omsid= ... ----- Dr. Frank Gaeth FU-Berlin -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/use-saved-coefficients-from-a-regression-in-the-data-file-tp4719101p4726551.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 |
In reply to this post by drfg2008
Another way (in addition to matrix or computes) to
get the predicted Y from a regression
add the two files with /IN = set1 and run the regression using /SELECT set1 EQ 1. Art Kendall Social Research Consultants On 8/20/2011 3:54 PM, drfg2008 wrote: ===================== 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 REFCARDSPSS 17 / Vista I would like to use the coefficients, which were saved from a regression in a sav-file, within a new data file. Here the example: http://www.frag-einen-statistiker.de/spss/koeffizientenmatrix.sav for example: compute pb21lay_c = 1,194 * standard_lay2 + ... + 1,112 plus all the other variables (8 variables alltogether) couldn't find a solution. Thanks ----- Dr. Frank Gaeth FU-Berlin -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/use-saved-coefficients-from-a-regression-in-the-data-file-tp4719101p4719101.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
Art Kendall
Social Research Consultants |
Administrator
|
In reply to this post by drfg2008
OK!!! Time Out Frank,
I finally booted into Windows where I have SPSS installed and opened your file. You could just have easily copy/pasted it in your original message. term pb02back pb02lay pb12back pb12lay pb20back pb20lay pb21back pb21lay (Intercept) -1.028 -1.086 1.043 1.258 -1.010 -1.099 .808 1.112 standard_Back_1 .000 .000 1.011 -1.084 4.313 .000 1.677 2.044 standard_Lay_1 -.001 -.005 -.694 1.321 -2.167 2.257 -.009 -.149 standard_Back_2 5.051 .179 .006 .787 .005 -.003 .659 -.941 standard_Lay_2 -2.882 2.077 1.556 1.038 -.005 .000 -.329 1.194 My previous MATRIX solution stands except use your terms as elements of !VAR and add the dependent variable names (pb02back pb02lay ...pb21lay) on the SNAMES. Don't forget to create the vector of ones called Intercept in the RawX.sav file. DEFINE !VARS () Intercept standard_Back_1 standard_Lay_1 standard_Back_2 standard_Lay_2 !ENDDEFINE . MATRIX. GET X /VARIABLES !VARS / FILE "RawX.sav". GET Beta / VARIABLES !VARS / FILE "Beta.sav". COMPUTE Pred=X*Beta. COMPUTE SNames={ !VARS, "pb02back_c", "pb02lay_c", "pb12back_c", "pb12lay_c" , "pb20back_c", "pb20lay_c", "pb21back_c", "pb21lay_c" }. SAVE { X, Pred } / NAMES= SNames/ OUTFILE *. END MATRIX. Hey Look PEEPS, No freakin Python!!!!! HTH, David
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 |