OPTIONS CRT NODATE; name ridge 'Ridge Regression for OLS and AR1' ; ? ? RIDGE does Bayesian or weighted OLS regression; a special case ? of this procedure does Ridge regression. ? TSP 4.2B (January 1995) ? Author: Clint Cummins ? FREQ A; SMPL 46 75 ; LOAD ; SMPL 49 75 ; ? ? Read in the coefficient vector and var-cov for the prior. ? The example has two coefficients. ? mmake B2 0 0; read(type=sym,nrow=2) VB2; 100 0 100; ? OLSQ CONS C GNP ; RIDGE b2 vb2 ; AR1 CONS,C,GNP ; RIDGE b2 vb2 ; ? ================================================================= PROC RIDGE B2 VB2; ? ? Assume we have a prior distribution on B (the coefficients) with ? mean B2 and variance VB2. For standard ridge regression, B2 = 0, ? and VB2 = (s2/k)*I, but you can make B2 and VB2 be anything you ? like. ? mat VB1I = @VCOV"; mat VB2I = VB2"; mat VBR = (VB1I + VB2I)"; mat BR = VBR*(VB1I*@COEF + VB2I*B2); title 'Ridge estimates'; tstats(names=@RNMS) BR VBR; ENDPROC RIDGE; ? ================================================================== END; NOPRINT; SMPL 46 75 ; ? Data for sample run. LOAD GNP CONS I ; ? GNP, CONSUMPTION, INVESTMENT 475.7 301.4 71 468.3 306.2 70.1 487.7 312.8 82.3 490.7 320.0 65.6 533.5 338.1 93.7 576.5 342.3 94.1 598.5 350.9 83.2 621.8 364.2 85.6 613.7 370.9 83.4 654.8 395.1 104.1 668.8 406.3 102.9 680.9 414.7 97.2 679.5 419.0 87.7 720.4 441.5 107.4 736.8 453.0 105.4 755.3 462.2 103.6 799.1 482.9 117.4 830.7 501.4 124.5 874.4 528.7 132.1 925.9 558.1 150.1 981.0 586.1 161.3 1007.7 603.2 152.7 1051.8 633.4 159.5 1078.8 655.4 168.0 1075.3 668.9 154.7 1107.5 691.9 166.8 1171.1 733.0 188.3 1233.4 766.3 207.4 1210.7 759.8 180.0 1186.4 766.6 138.9 ;