%TLASSO_PATH Compute a t-lasso path.
% Users should refer to the 'tlasso' function to use this software.
function [B, B0, sigma2, negll] = tlasso_path(X, y, nu, tau2, theta_start, maxiter)

%% Setup
[~,p] = size(X);

nsteps = length(tau2);
B = zeros(p,nsteps);
B0 = zeros(1,nsteps);
sigma2 = zeros(1,nsteps);
negll = zeros(1,nsteps);

%% Lasso path
for i = (nsteps):-1:1
    [b, b0, s2, L, s2_ml] = tlasso_EM(X, y, nu, tau2(i), theta_start, maxiter);
    theta_start = [b0; b; s2];

    %% Record the best solution
    B(:,i) = b;
    B0(i) = b0;
    sigma2(i) = s2_ml;
    negll(i) = L;