
how can I find the CI for non normal data
6 views (last 30 days)
Show older comments
Dear all
I need to find the 1-tailed 90% confidence interval (actually the lower limit of 90% confidence interval) of my attached non-normal data. (I tested the normality using adtest and lillietest.)
First, I transferred the data into normal using boxcox, then computed the CI, and reverse-transferred the LCI limit. But the limit value wLB looks very high to me.
My knowledge of statistics is limited. Could you please check my code and give a feedback? Is this the correct way of doing it? Here is my code:
load('dData.mat');
[dDataB,lambda] = boxcox(dData'); % normalize
% compute confidence interval:
pdB = fitdist(dDataB, 'Normal');
ciB = paramci(pdB, 'Alpha', 0.10); % for 1-tailed 90%
lclB = ciB(1,1); % get the lower confidence limit
wLB = (1 + lclB * lambda)^(1 / lambda); % reverse-transfer
Thanks
3 Comments
Adam Danz
on 27 Jun 2018
Edited: Adam Danz
on 27 Jun 2018
The script below sorts your dData and then finds the first value that exceeds the lower confidence interval (which is hard coded in the script).
% Assumes dData is loaded in workspace
CI = [0.35309 0.35446]; % CI of the mean
[dDataSort, sortIdx] = sort(dData); % dData sorted
%index of first sorted point greater than lower CI
idx = find(dDataSort > CI(1), 1);
% The first data point past the lower CI is...
firstAccepted = dDataSort(idx);
%... and it's location in dData is....
firstAcceptedIdx = sortIdx(idx);
% Plot results, circle first accepted
figure
subplot(2,1,1)
plot(dDataSort, 'b.'); %plot your sorted data
hold on
refline(0, CI(1)); %plot the lower CI
plot(idx, firstAccepted, 'ro') %circle the first point past within CI
title('dData sorted')
subplot(2,1,2)
plot(dDataSort, 'b.');
hold on
refline(0, CI(1));
plot(idx, firstAccepted, 'ro')
xlim([idx-10, idx+10])
ylim([firstAccepted-.01, firstAccepted+.01])
title('Zoomed in')
legend('dData', 'lower CI', 'First in CI', 'location', 'NorthWest')
The plot generated above (shown below) shows your raw dData sorted and the 2nd subplot shows the same data zoomed in so you can see that the first point after the lower CI is chosen.

Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!