Hi SPSS Experts,
I am using relative weightage analysis to determines the relative importance of each independent variable to the dependent variable. I am using the syntax which is posted on this link : http://www1.psych.purdue.edu/~jlebreto/rweight2.sps Following the syntax for your reference : NEW FILE. MATRIX DATA VARIABLES=ROWTYPE_ overall x1 x2 x3 x4 x5 x6 x7 x8 x9 . BEGIN DATA CORR 1.0000 CORR .1746 1.0000 CORR .2064 .6681 1.0000 CORR .1403 .2137 .3026 1.0000 CORR .1523 .3113 .4252 .5493 1.0000 CORR .1218 .2365 .3051 .5942 .5982 1.0000 CORR .1497 .1805 .3169 .4371 .4744 .4083 1.0000 CORR .0851 .1661 .2903 .2920 .3071 .2205 .5473 1.0000 CORR .2045 .1903 .2756 .2855 .4035 .3376 .3008 .2088 1.0000 CORR .2962 .0999 .2547 .2995 .4125 .3731 .2965 .1960 .5608 1.0000 END DATA. MATRIX. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * The user can provide variable labels for the output here, if desired. * * Labels are limited to 8 characters. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *. COMPUTE LABELS = {'x1';'x2';'x3';'x4';'x5';'x6';'x7';'x8';'x9'} . MGET / TYPE = CORR. COMPUTE R = CR. /* CR is default name of matrix */ COMPUTE N = NCOL(R). /* Number of variables */ COMPUTE RXX = R(2:N,2:N). /* Correlations between the X's */ COMPUTE RXY = R(2:N,1). /* Correlations between Y and the X's */ CALL EIGEN(RXX,EVEC,EV). /* Begin singular value decomposition */ COMPUTE D = MDIAG(EV). /* Diagonal matrix of eigenvalues */ COMPUTE DELTA = SQRT(D). /* Square root of eigenvalues */ * Create the matrix of correlations between the original X variables and the new orthogonal variables. COMPUTE LAMBDA = EVEC * DELTA * T(EVEC). COMPUTE LAMBDASQ = LAMBDA &**2. /* Square the correlations */ * Use the inverse of LAMBDA to find the regression coefficients of Y on the orthogonal variables. COMPUTE BETA = INV(LAMBDA) * RXY. /* Regression coefficients */ COMPUTE RSQUARE = CSSQ(BETA). /* Calculate R-square */ * The next two steps multiply the squared LAMBDA elements by the squared betas, sum across variables, divide by R-square, and multiply by 100 to create the importance weights. COMPUTE RAWWGT = LAMBDASQ * BETA &**2. /* Raw importance weights */ COMPUTE IMPORT = (RAWWGT &/ RSQUARE) * 100. /* Rescale to % of R-square */ * Print the relative weights. The number of decimal places can be controlled by changing the format. PRINT RSQUARE /FORMAT=F8.3. PRINT RAWWGT /FORMAT=F8.3 /TITLE = "Raw Relative Weights" /RNAMES = LABELS . PRINT IMPORT /FORMAT=PCT8.1 /TITLE = "Relative Weights as Percentage of R-square" /RNAMES = LABELS . END MATRIX. This is working absolutely fine for my project. The code above prints the matrix expression in output window. I wish to save these RSQUARE, RAWWGT and IMPORT matrix expression to data file with their respective labeling. Following the syntax i am using for RAWWGT and IMPORT as their number of rows are same SAVE {RAWWGT,IMPORT} /OUTFILE='C:\Directory\Importance_Score.sav'. END MATRIX. This code saves the matrix expression scores but not creating the variable containing labeling against it. |
Administrator
|
FYI:
SAVE matrix expression [/OUTFILE = {file reference}] {* } [/VARIABLES = variable list] [/NAMES = names vector] [/STRINGS = variable list] ---
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 Ujjawal
Hello, I will be out of the office Monday and Tuesday, March 4-5, 2013. I will periodically check my email during this time. Best, Michael Toner ********************************************* Michael J. Toner, Ph.D. Associate Director, Graduate Enrollment and Data Management Office of the Graduate School Temple University 1803 N. Broad St. 501 Carnell Hall Philadelphia, PA 19122-6095 phone 215.204.6577 fax 215.204.8781 email [hidden email] |
In reply to this post by David Marso
Thank you David for your reply. Before posting this question, i read MATRIX-END MATRIX chapter from syntax reference book. I tried accomplishing the task using all the possible codes i could think of but not succeeded.
1. The code below labels variable names of the matrix expressions. However, i want code to supply the name of matrix expressions containing row labels for the matrix. (Like RNAMES works in PRINT command) SAVE {RAWWGT,IMPORT} /OUTFILE='Directory\Importance_Score.sav' / NAMES = LABELS END MATRIX. Following the output the code above returns Driver1 Driver2 .0034 14.96 .0050 21.85 .0000 .09 .0012 5.59 .0038 16.37 .00014 .62 .00230 9.92 .00161 6.94 .00134 5.76 .00174 7.51 .00241 10.38 This is the desired output : Drivers RAW RELATIVE Driver1 0.0034 14.96 Driver2 0.005 21.85 Driver3 0 0.09 Driver4 0.0012 5.59 Driver5 0.0038 16.37 Driver6 0.00014 0.62 Driver7 0.0023 9.92 Driver8 0.00161 6.94 Driver9 0.00134 5.76 Driver10 0.00174 7.51 Driver11 0.00241 10.38 Can this be accomplished using any other command than SAVE in matrix ? I used MSAVE,WRITE but could not get code delivered the desired output. Any help would be greatly appreciated! Thank you so much in advance . |
Free forum by Nabble | Edit this page |