% Exercise 9.11 Hypersplenism and White Blood Cell Count.
% Hypersplenism is a disorder that causes the spleen
% to rapidly and prematurely destroy blood cells.
% In the general population the count of white
% blood cells is normal with the mean of
% $7200/mm^3$ and standard deviation $\sigma = 1500.$
%
% It is believed that hypersplenism decreases the leukocyte count.
%
% (a) If in a sample of 16 persons affected by hypersplenism
% the mean white blood cell count
% was found to be ${\bar X}= 5213/mm^3.$
% The sample standard deviation was $s = 1682/mm^3.$ Test
% $H_0: \mu = 7200$ versus the alternative $H_1: \mu < 7200.$
% (b) Find the power of the test against the alternative $H_1: \mu = 6000.$
%
% (c) What sample size is needed if the
% effect $|mu1 - mu0|/sigma = 0.4$ is to be
% detected with the power of 80\%
n=16; xbar=5213; mu0 = 7200; s=1682; alpha = 0.05;
t = (xbar - mu0)/(s/sqrt(n))
%t = -4.7253
tcdf(t,n-1) %p-value
%ans = 1.3543e-004
tinv(alpha, n-1) %RR bound
%ans = -1.7531
% Find the power against alternative H_1: mu=5800
esizet = abs(7200-6000)/s;
powert = nctcdf( -tinv(1-alpha, n-1), n-1,-esizet*sqrt(n))
% powert = 0.8592
%Sample Size
%power 80%, alpha 5% one sided, for difference of size
% 600. Effect size 600/1682 =0.3567
beta = 0.2;
%Approx sample size
ss = (norminv(1-beta) + norminv(1-alpha))^2/0.4^2
%ss = 38.6410
%Exact sample size
f = @(n) nctcdf( -tinv(1-alpha, n-1), n-1, -sqrt(n)*0.4 )-(1-beta);
sss = fzero(f,ss)
%sss = 40.0291
%%