begin comment Lineair regression with random coefficients,S 431,R 1279,program EAS 290666; integer tal,J1,J2,max,df; real t,t1,P; comment SP 131, see descr 28; real procedure tDistr(m,t);value m,t;integer m;real t; begin integer i; real x,s,u,v; x:=arctan(abs(t)/sqrt(m));v:=cos(x)**2; if m%2*2=m then begin s:=u:=sin(x)/2; i:=0 end else begin u:=4*arctan(1);s:=x/u;u:=sin(2*x)/u/2; if m>=3 then s:=s+u;i:=1 end; m:=m-2; L: if i>=m then go to out;i:=i+2;u:=u*v*(i-1)/i;s:=s+u;go to L; out: tDistr:= if t<=0 then .5-s else .5+s end tDistr; NLCR;PRINTTEXT("Result EAS 209666,band");ABSFIXT(10,0,read);tal:=read; L: NLCR;NLCR;ABSFIXT(10,0,read);NLCR; J1:=read;J2:=read;if J1 - J2 >= 0 then max:=J1 else max:=J2; begin integer i,j,k,n,p; real s1,s2,s3,s4; real array BB[1 : 2],b[1 : 2,1 : max]; i:=0; for p:=J1,J2 do begin i:=i + 1; if i = 1 then PRINTTEXT("estimated slopes first sample") else PRINTTEXT("estimated slopes second sample");s4:=0; for j:=1 step 1 until p do begin n:=read;s1:=s2:=s3:=0; begin real array x[1 : n]; for k:=1 step 1 until n do begin x[k]:=read;s1:=s1 + x[k] end; s1:=s1 / n; for k:=1 step 1 until n do begin x[k]:=x[k] - s1;s2:=s2 + x[k] ** 2;s3:=s3 + x[k] * read end end; b[i,j]:=s3 / s2;NLCR;FLOT(6,2,b[i,j]);SPACE(3);FLOT(6,2,s2);s4:=s4 + b[i,j] / p end; BB[i]:=s4 end; t:=0; for j:=1 step 1 until J1 do begin b[1,j]:=b[1,j] - BB[1];t:=t + b[1,j] ** 2 end; for j:=1 step 1 until J2 do begin b[2,j]:=b[2,j] - BB[2];t:=t + b[2,j] ** 2 end; t:=(BB[1] - BB[2]) / t;t1:=J1 * J2 * (J1 + J2 - 2);t1:=t1 / (J1 + J2);t:=t * sqrt(t1); NLCR;PRINTTEXT("test for equality of slopes: t=");FLOT(6,2,t);NLCR; df:=J1 + J2 - 2;PRINTTEXT("df= ");ABSFIXT(3,1,df);NLCR; P:=tDistr(df,t);PRINTTEXT("Pbr= ");FLOT(6,2,P) end; tal:=tal - 1;if tal > 0 then goto L end