CS395T/CAM383M Computational Statistics

CS395T/CAM383M Computational Statistics (http://shale.ices.utexas.edu/forum/index.php)
-   HW 5 (http://shale.ices.utexas.edu/forum/forumdisplay.php?f=40)
-   -   Hw5 (http://shale.ices.utexas.edu/forum/showthread.php?t=455)

Yanan 05-12-2011 12:16 PM

Hw5
 
1 Attachment(s)
Proof for Problem 1 is attached. Code for Problem 2.
Code:

data = load('hw5_data.txt','-ASCII');
[N,M] = size(data);

% mu and sigma
mu = mean(data);
sigma = cov(data);

%chi-square and p-value
chi2 = zeros(N,1);
p = zeros(N,1);
for i = 1:N
    chi2(i) = (data(i,:)-mu)*inv(sigma)*(data(i,:)-mu)';
    p(i) = 1-chi2cdf(chi2(i),5);
end

%FDR
[rank, index] = sort(p);
alpha = 0.1;
rej = [];
j = 1;
for i = 1:N
    if p(index(i)) < i*alpha/N
        rej(j) = index(i);
        j = j+1;
    end
end



All times are GMT -6. The time now is 08:54 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.