* Load the Theil textile data set with the DEMO command. ?DEMO * RIDGE REGRESSION sample 1 17 * Make room for 10 different sets of coefficients dim beta 3 10 k 10 * Put OLS coefficients in the first column, ridge k=0 gen1 k:1=0 * Use the ? prefix to suppress printing of the OLS output. ?ols consume income price / coef=beta:1 * Let ridge k go from 0.1 to 0.9. do #=2,10 gen1 k:#=(#-1)/10 ?ols consume income price / ridge=k:# coef=beta:# endo * Transpose the beta matrix. matrix b=beta' matrix results=(k|b) print results sample 1 10 * Plot the coefficients for income (b:1) and price (b:2) against k. * This gives the ridge trace for these coefficients. genr beta_inc=b:1 genr beta_pr=b:2 graph beta_inc beta_pr k / lineonly STOP