Biserial correlation coefficient. Applicative program.
Costescu, Mihai Radu
procedure coef_corel_biserial(pq_y:real;var r:real); type vect=array[1..50] of real; var v,n1,n2:vect; n:integer; media1,media2,med_tot,s:real; procedure citire(k:integer;var x:vect); var i:integer; begin for i:=1 to k do begin write('Varianta',i:3,' : '); readln(x[i]); end; end; function media(k:integer;v,x:vect):real; var nt,suma:real; i:integer; begin suma:=0; nt:=0; for i:=1 to k do begin suma:= suma+v[i]*x[i]; nt:=nt+x[i]; end; media:=suma/nt; end; function media_total(k:integer;v,x,y:vect):real; var nt,suma:real; i:integer; begin suma:=0; nt:=0; for i:=1 to k do begin suma:= suma+v[i]*(x[i]+y[i]); nt:=nt+x[i]+y[i]; end; media_total:=suma/nt; end; function ab_med_patrat(k:integer;med_total:real;v,x,y:vect):real; var nt,suma:real; i:integer; begin suma:=0; nt:=0; for i:=1 to k do begin suma:=suma+sqr(v[i]-med_total)*(x[i]+y[i]); nt:=nt+x[i]+y[i]; end; ab_med_patrat:=sqrt(suma/nt); end; begin {procedure coef_corel_biserial} write('Introduceti numarul de variante al variabilei continue n='); readln(n); writeln('Introduceti variantele variabilei continue'); citire(n,v); writeln('Introduceti numerele corespunzatoare variantelor care poarta caracteristica A a variantei dihotomice'); citire(n,n1); writeln('Introduceti numerele corespunzatoare variantelor care poarta caracteristica B a variantei dihotomice'); citire(n,n2); write('Introduceti valoarea pq/y = '); readln(pq_y); media1:=media(n,v,n1); media2:=media(n,v,n2); med_tot:=media_total(n,v,n1,n2); s:=ab_med_patrat(n,med_tot,v,n1,n2); r:=(media1-media2)/s*pq_y; writeln('Coeficientul de corelatie biserial r = ',r:6:4); end;