%
% A new, hand-held device for assessing cholesterol in blood is
% presented for approval to FDA. The variability of measurements
% obtained by the device
% for people with normal level of LDL cholesterol is one of the measures of interest.
% A calibrated sample of size n=224 of serum specimens with a fixed 130-level of LDS-C
% are measured by the device and the variability
% of measurements assessed.
%
% (i) If s^2 = 2.47, test the hypothesis that the population variance
% of such measurements is 2 (as achieved by a clinical computerized
% Hitachi 717 analyzer,
% with enzymatic, colorimetric detection schemes) against one-sided alternative.
% Use alpha = 0.05.
%
% (ii) Find the power of this test against alternative H_1: sigma^2 = 2.5
%
% (iii) What sample size is needed to achieve a power of 90% in testing
% against H_1: sigma^2 = 2.5, at level alpha=0.05
n = 224; s2 = 2.47; sigmasq0 = 2; sigmasq1 = 2.5; alpha = 0.05;
%(i)
chisq = (n-1)*s2 /sigmasq0 %test statistics, 275.4050
chi2crit = chi2inv( 1-alpha, n-1 ) %one sided upper tail RR:[258.8365,+inf)
pvalue = 1- chi2cdf(chisq, n-1) %0.0096
%
%(ii)
power = 1-chi2cdf(sigmasq0/sigmasq1 * chi2inv(1-alpha, n-1), n-1 ) % 0.7708
%(iii)
alpha = 0.05; ratio = sigmasq0/sigmasq1; %ratio=0.8
pf = @(n) 1-chi2cdf( ratio * chi2inv(1-alpha, n-1), n-1 ) - 0.90;
ssize = fzero(pf, 300) %342.5993 approx 343