different solutions when applying ridge() or the standard formulation

1 view (last 30 days)
Dear all,
Recently I have been working with a very simple ridge regression example. In particular, based on the data included bellow
y = Xr'·b + e
X = [3.4 50.3;6.2 60;8 67;9.2 72; 10.2 76;11.1 79;11.8 82.5];
Xr = [ones(7,1) X];
y = [0 3 6 9 12 15 18]';
I calculate the arising coefficients (b) using the ridge() function implemented in matlab:
br = ridge(y,X,0.05,0)
Note that the flag is equal to zero and, therefore, the obtained coefficients should be those according to the initial data. In addition, as suggested by the help of ridge(), The model does not include a constant term, and X should not contain a column of 1s.
br =
-26.7914
0.2816
0.4800
However, so as to validate this result I also solve the original ridge formula, namely:
b=inv(Xr'*Xr+0.05*eye(3))*Xr'*y
b =
-2.1186
2.8194
-0.1868
Surprisingly, both results where completely different. The best solution should be that with the less value in the following penalized residual sum of squares:
PRSSr = sum((y-Xr*br).^2)+0.05*sum(br.^2)
PRSSr =
48.1683
PRSS = sum((y-Xr*b).^2)+0.05*sum(b.^2)
PRSS =
16.8857
This is a little bit astonishing for me since a better solution was expected using the ridge() function.
Could any one put light on this please?
Many many thanks in advance!
Jon

Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!