I have a line of experimental data and need to plot confidence interval
16 ビュー (過去 30 日間)
古いコメントを表示
I have a singular line and need to plot a 95% confidence interval, but where I plot it I get horizontal upper and lower bounds where as the line of best fit would clearly have a positive gradient.
I can't release the raw data so I have made an arbitrary line for this, but my code is below. I haven't really done statistics before and I am just helping out a friend so please no judgement and explanations on where I am wrong and how to fix very much appreciated
x = [1:1:100]
y = x
N = size(y,1); % Number of ‘Experiments’ In Data Set
yMean = mean(y); % Mean Of All Experiments At Each Value Of ‘x’
ySEM = std(y)/sqrt(N); % Compute ‘Standard Error Of The Mean’ Of All Experiments At Each Value Of ‘x’
CI95 = tinv([0.025 0.975], N-1); % Calculate 95% Probability Intervals Of t-Distribution
yCI95 = bsxfun(@times, ySEM, CI95(:)); % Calculate 95% Confidence Intervals Of All Experiments At Each Value Of ‘x’
plot(x, ones(size(x)).*yMean,'k') %Plot Mean Of All Experiments
hold on
plot(x, (ones(size(x)).*yCI95(1)+yMean),'m')
hold on
plot(x, (ones(size(x)).*yCI95(2)+yMean),'m')
0 件のコメント
回答 (2 件)
Star Strider
2022 年 12 月 6 日
I recognise my code (although it’s likely fairly old).
This calculates the plots the confidence intervals for a matrix of experiments where each column is a different experiment (although I’d have to see the entire code to be certain). It’s not intended to do curve-fitting.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!