clear all
close all

% The goal of the study was to inform a woman of her chances of being a DMD carrier
% based on serum markers as well as her family pedigree. Enzyme
% levels were measured in known carriers (67 samples) and in a group of
% noncarriers (127 samples).
% Hemopexin level was in 3rd column, carrier indicator (0/1) was in 6th column
% of dmd.mat.
% Are the mean levels of hemopexin for the two groups (carrier/no carrier) significantly different?

load 'C:\STAT\Descriptive\Descriptivedat\dmd.mat'

hemo0 = dmd( dmd(:,6)== 0, 3);
hemo1 = dmd( dmd(:,6)== 1, 3);
n1=length(hemo0)
n2=length(hemo1)
xbar1 = mean(hemo0), s21 = var(hemo0)
xbar2 = mean(hemo1), s22 = var(hemo1)


 F = s21/s22
 pval1 = 2*min(fcdf(F, n1-1,  n2 -1), 1-fcdf(F, n1-1,  n2 -1))


ndf = (s21/n1 + s22/n2 )^2 /( (s21/n1)^2/(n1-1) + (s22/n2)^2 /(n2-1) )


[(xbar1 - xbar2) - sqrt(s21/n1 + s22/n2) * tinv(0.975,ndf),  
     (xbar1 - xbar2) + sqrt(s21/n1 + s22/n2) * tinv(0.975,ndf)]  

t = (xbar1 - xbar2 - (-10))/sqrt(s21/n1 + s22/n2)
pval = tcdf(t, ndf)

figure(1)
bihist(hemo0, hemo1, 40)
