I have a line of experimental data and need to plot confidence interval
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Star Strider
el 6 de Dic. de 2022
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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!