clear all
disp('Plasma Ascorbic Acid Level ')
% In the study {\em ``Interrelationships Between Stress, Dietary Intake, and
% Plasma Ascorbic Acid During Pregnancy''} conducted at the Virginia Polytechnic
% Institute and State University, the plasma ascorbic acid levels of
% pregnant women were compared for smokers versus non-smokers. Thirty-two women
% in the last three months of pregnancy, free of major health disorders, and
% ranging in age from 15 to 32 years were selected for the study. Prior to the
% collection of 20 ml of blood, the participants were told to avoid breakfast,
% forego their vitamin supplements, and avoid foods high in ascorbic acid
% content. From the blood samples, the following plasma ascorbic acid values of
% each subject were determined in milligrams per 100 milliliters:
nonsmo = [0.97 0.72 1.00 0.81 0.62 1.32 1.24 0.99 ...
                     0.90 0.74 0.88 0.94 1.06 0.86 0.85 0.58 0.57...
                     0.64 0.98 1.09 0.92 0.78 1.24 1.18];
 smo = [ 0.48 0.71 0.98 0.68 1.18 1.36 0.78 1.64];
 %test hypothesis that the plasma ascorbic acid levels are different for
 %the two groups. Use alpha=0.05.
 X1bar = mean(nonsmo);  s1 = std(nonsmo);  n1 = length(nonsmo);
 X2bar = mean(smo);  s2 = std(smo);  n2= length(smo);
 %s1 = 0.2104 s2 = 0.3915 we will check for equality of variances
 F = s1^2/s2^2  % 
 pval1 = 2*min(fcdf(F, n1-1,  n2 -1), 1-fcdf(F, n1-1,  n2 -1))
% pval1 =0.0223 < 5% and we will not assume equality of variance in
%      comparing the two means.
% The "nasty" df for the t test is [text 318p]
ndf = (s1^2/n1 + s2^2/n2 )^2 /( (s1^2 /n1)^2/(n1-1) + (s2^2/n2)^2 /(n2-1) )
t = (X1bar - X2bar)/sqrt( s1^2/n1 + s2^2/n2 )
pval = tcdf(t,ndf)
% ndf = 8.3892;   t =-0.4457;   pval = 0.3336
% there is no evidence that the mean mu1 is significantly smaller
% than mu2 at level 5\%

%%%%
