close all
clear all

load 'C:\STAT\Logistic\Logisticdat\sagittal.mat'

y = sagittal(:,1);
X = sagittal(:,2:5);


[b ,dev ,stats ] = glmfit(X,y,'binomial');
[b1, lassostuff] = lassoglm(X,y,'binomial','NumLambda',30,'CV',10);
 figure;        lassoPlot(b1, lassostuff,'plottype','CV');
 
 figure;  lassoPlot(b1,lassostuff);      
         
b
b1

%%
yfit  = glmval(b,X,'logit');
x_des =[ones(size(y)) X];
lin  = x_des  * b;
figure(1), hold on
plot(lin(1:20), yfit(1:20),'or')
plot(lin(21:60), yfit(21:60),'ob')
line=-20:0.1:20; logi= exp(line)./(1+exp(line));
plot(line, logi, 'r-')
yfit_binary = yfit >0.5;
sum(yfit_binary ~= y)
hold off

figure(2)
plot(   sagittal(sagittal(:,1)==0,2),  sagittal(sagittal(:,1)==0,3), 'go')
hold on
plot(   sagittal(sagittal(:,1)==1,2),  sagittal(sagittal(:,1)==1,3), 'ro')


