% examples of the plasso for linear regression
% small p
p = 8;
tbeta = [3,1.5,0,0,0.5,.5,0,0]';
Sig = eye(p);
truebeta = [2;tbeta]; % vector of true coefficients

n = 200;
sig = 1;
x = mvnrnd(zeros(1,p),Sig,n);
y = 2+x*tbeta + sig*randn(n,1);

betalasso = alasso(center(x),center(y));
betalasso = [mean(y)-mean(x)*betalasso;betalasso]; % alasso estimate
obj = adaplasso_est(x,y);
betaplasso = obj.beta;  % plasso estimate
obj = adapwplasso_est(x,y);
betawplasso = obj.beta; % weighted plasso estimate
[truebeta,betalasso,betaplasso,betawplasso]

% large p
p = 100;
tbeta = zeros(p,1);
tbeta(10*(1:10)) = 5;
Sig = eye(p,p);
truebeta = [2;tbeta];

n = 200;
sig = 1;
x = mvnrnd(zeros(1,p),Sig,n);
y = 2+x*tbeta + sig*randn(n,1);

betalasso = alasso(center(x),center(y));
betalasso = [mean(y)-mean(x)*betalasso;betalasso]; % alasso estimate
obj = adaplasso_est(x,y);
betaplasso = obj.beta;  % plasso estimate
obj = adapwplasso_est(x,y);
betawplasso = obj.beta;
[truebeta,betalasso,betaplasso,betawplasso]% weighted plasso estimate

