new;
format /m1 /rdn 9,4;
@*******Of[^̓ǂݍ***********@

open f1=c:\sum2016\para;
b=readr(f1,100);
f1=close(f1);

load x[248,7]=c:\sum2016\dataset1.csv;

@********f̐胋[`[**********@
output file=c:\sum2016\bunseki.txt reset;
__output = 2;

whour=x[.,2]*24;
stt=x[.,4]*24;
tt=x[.,7]*24;

i=0;
do while i<=12;
@	stt=x[.,4]*24-i/6;@
	whour=((x[.,2]*24).>=8).*(x[.,2]*24-i/6)+((x[.,2]*24).<8).*(x[.,2]*24);
@	tt=((x[.,2]).==200).*((x[.,7]*24).<1).*(x[.,7]*24-i/60)+((x[.,2]).==200).*((x[.,7]*24).>=1).*(x[.,7]*24)+(x[.,2]-((x[.,2]).==200)).*(x[.,7]*24);@
    detour=exp(b[1]+b[2]*whour+b[3]*(stt.<=7)+b[4]*(stt.>7).*(stt.<=8)+b[5]*(x[.,3].==100)+b[6]*(tt));

    prob=(detour./(1+detour));

print i~sumc(prob)/rows(x);

i=i+1;
endo;
output off;
end;



