This page is hosted on AFS file server space, which is being shut down on November 13, 2018. If you are seeing this message, your service provider needs to take steps now. Visit afs.unc.edu for more information.
RIDGE REGRESSION FOR LONGLEY DATA USING SYSTAT'S MATRIX MODULE
SAT 3/13/99 9:27:46 AM

SYSTAT VERSION 7.0.1
COPYRIGHT (C) 1997, SPSS INC.

Welcome to SYSTAT!

>matrix
Current program limits:
     Number of MATRICES = 15.
     Number of row and column NAMES = 230.
     Number of NUMERIC data elements = 4100 (32800 bytes).
     Number of CHARACTER data elements = 1100 (13200 bytes).

>USE 'C:\SYSTAT7\DATA\LONGLEY.SYD'
SYSTAT Rectangular file C:\SYSTAT7\DATA\LONGLEY.SYD,
created Tue Feb 18, 1986 at 13:56:00, contains variables:
 DEFLATOR     GNP          UNEMPLOY     ARMFORCE     POPULATN     TIME
 TOTAL
********** Active Matrix: LONGLEY **********

>format 11 7

>mat y = longley(;total)
********** Active Matrix: Y **********

>mat x = longley(;deflator..time)
********** Active Matrix: X **********

>mat y = colzsc(y)
********** Active Matrix: Y **********

>mat x = colzsc(x)
********** Active Matrix: X **********

>mat xpx = trp(x)*x/(nrow(x)-1)
********** Active Matrix: XPX **********

>mat xpy = trp(x)*y/(nrow(x)-1)
********** Active Matrix: XPY **********

>sho xpx
 
Matrix: XPX
                 DEFLATOR         GNP    UNEMPLOY    ARMFORCE    POPULATN
 DEFLATOR       1.0000000   0.9915892   0.6206334   0.4647442   0.9791634
 GNP            0.9915892   1.0000000   0.6042609   0.4464368   0.9910901
 UNEMPLOY       0.6206334   0.6042609   1.0000000  -0.1774206   0.6865515
 ARMFORCE       0.4647442   0.4464368  -0.1774206   1.0000000   0.3644163
 POPULATN       0.9791634   0.9910901   0.6865515   0.3644163   1.0000000
 TIME           0.9911492   0.9952735   0.6682566   0.4172451   0.9939528
                     TIME
 DEFLATOR       0.9911492
 GNP            0.9952735
 UNEMPLOY       0.6682566
 ARMFORCE       0.4172451
 POPULATN       0.9939528
 TIME           1.0000000
********** Active Matrix: XPX **********

>sho xpy
 
Matrix: XPY
 DEFLATOR       0.9708985
 GNP            0.9835516
 UNEMPLOY       0.5024981
 ARMFORCE       0.4573074
 POPULATN       0.9603906
 TIME           0.9713295
********** Active Matrix: XPY **********

>mat beta = inv(xpx)*xpy
********** Active Matrix: BETA **********

>sho beta
 
Matrix: BETA
 DEFLATOR       0.0462820
 GNP           -1.0137463
 UNEMPLOY      -0.5375426
 ARMFORCE      -0.2047407
 POPULATN      -0.1012211
 TIME           2.4796644
********** Active Matrix: BETA **********

>mat ridge = i(6)
********** Active Matrix: RIDGE **********

>mat betar = inv(xpx+ridge#0.01)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.02)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.03)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.04)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.05)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.06)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.07)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.08)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat betar = inv(xpx+ridge#0.09)*xpy
********** Active Matrix: BETAR **********

>mat beta = beta||betar
********** Active Matrix: BETA **********

>mat beta = trp(beta)
********** Active Matrix: BETA **********

>mat ridge = [0.0; 0.01; 0.02; 0.03; 0.04; 0.05; 0.06; 0.07; 0.08;,

>0.09]
********** Active Matrix: RIDGE **********

>colname ridge = ridge
********** Active Matrix: RIDGE **********

>mat beta = beta||ridge
********** Active Matrix: BETA **********

>show beta
 
Matrix: BETA
     DEFLATOR         GNP    UNEMPLOY    ARMFORCE    POPULATN        TIME
    0.0462820  -1.0137463  -0.5375426  -0.2047407  -0.1012211   2.4796644
    0.2243909   0.3384163  -0.3012889  -0.1203120   0.0900342   0.5684712
    0.2554418   0.3389921  -0.2794636  -0.1027295   0.1713698   0.4314136
    0.2631998   0.3346829  -0.2623944  -0.0895991   0.2023704   0.3776147
    0.2651152   0.3298206  -0.2474496  -0.0784852   0.2177420   0.3480589
    0.2649235   0.3250096  -0.2339612  -0.0686880   0.2262858   0.3289198
    0.2638317   0.3203945  -0.2216270  -0.0598886   0.2312827   0.3152458
    0.2623252   0.3160117  -0.2102638  -0.0519009   0.2342336   0.3048190
    0.2606278   0.3118634  -0.1997416  -0.0445991   0.2359194   0.2964941
    0.2588520   0.3079400  -0.1899598  -0.0378905   0.2367841   0.2896178
        RIDGE
    0.0
    0.0100000
    0.0200000
    0.0300000
    0.0400000
    0.0500000
    0.0600000
    0.0700000
    0.0800000
    0.0900000
********** Active Matrix: BETA **********

>format

>save beta
Matrix: BETA has been saved.
********** Active Matrix: BETA **********

>use beta
SYSTAT Rectangular file beta.SYD,
created Sat Mar 13, 1999 at 09:28:56, contains variables:
 DEFLATOR     GNP          UNEMPLOY     ARMFORCE     POPULATN     TIME
 RIDGE
********** Active Matrix: BETA **********

>plot deflator..time*ridge/overlay line xmin=-0.01 xmax=0.1 ymin=-1.1 ymax=2.5,

>                          stick xlim=0 xlabel='Ridge Factor',

>                          ylim=0 ylabel='Estimate of Beta'



Last modified 13 April 1999