%% Recreate the model select results from the Boston Housing Data from the paper
%  Schmidt, D. F. & Makalic, E.
%  Robust Lasso Regression with Student-t Residuals
%  Lecture Notes in Artificial Intelligence, to appear, 2017.

% Load the boston housing data
clear;
load boshouse.mat

% Fit models for nu = 1, 2, 10 and 1e5 (approx. Gaussian) using CV
rng(1)
fprintf('Fitting model with nu = 1\n');
[  b_1,   b0_1,   retval_1] = tlasso(X, y, 1, 'CV', 10, 'MCReps', 10);
fprintf('Fitting model with nu = 2\n');
[  b_2,   b0_2,   retval_2] = tlasso(X, y, 2, 'CV', 10, 'MCReps', 10);
fprintf('Fitting model with nu = 10\n');
[ b_10,  b0_10,  retval_10] = tlasso(X, y, 10, 'CV', 10, 'MCReps', 10);
fprintf('Fitting model with nu = 1e5 (Gaussian)\n');
[b_inf, b0_inf, retval_inf] = tlasso(X, y, 1e5, 'CV', 10, 'MCReps', 10);

% Display results
fprintf('\n');
fprintf(' Results\n');
fprintf(' ------------------------------------------\n');
fprintf('%8s%8s','nu','CV Err');
fprintf('%10s', varnames{:});
fprintf('\n');

fprintf('%8d%8.4f', 1, retval_1.CVErr(retval_1.IndexMinCV));
fprintf('%10.4f', b_1(:,retval_1.IndexMinCV));
fprintf('\n');

fprintf('%8d%8.4f', 2, retval_2.CVErr(retval_2.IndexMinCV));
fprintf('%10.4f', b_2(:,retval_2.IndexMinCV));
fprintf('\n');

fprintf('%8d%8.4f', 10, retval_10.CVErr(retval_10.IndexMinCV));
fprintf('%10.4f', b_10(:,retval_10.IndexMinCV));
fprintf('\n');

fprintf('%8s%8.4f', 'Gaussian', retval_inf.CVErr(retval_inf.IndexMinCV));
fprintf('%10.4f', b_inf(:,retval_inf.IndexMinCV));
fprintf('\n');