error bars of measures
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hello everybody, i have a value table with different measures at some different points e.g
x y
0 1
0 2
0 1.5
1 3
1 5
1 4
etc....
i would like to know if there is a non brute way of find the errors of the measures, what i mean.... i have the x,y values and i have fitted with fitlm so, i have y=a*x (i forced to pass by the (0,0) wiht ,'intercept',false) and with the data i would like to put the error bars that depends of the data. for example that it searchs the max difference between, the predicted value with the fit(in that x) and the differents values in that same x. and then make an error bar with that difference in each x. i think i could do it by brute force something like: with some loops and conditionals,search the max abs(difference in y(measures)) for each different x and stock it in a vector err and then use errorbar(x,Function.Coefficients.Estimate*x,err) where Function is the fitlm of the x and y values. (note. the idea is that this data is going to increase in time, so, it is going to be more than 3 values for the same x) (also the matrix is arranged in cresent way so, all the same x are together).sorry if i wanst clear or if i made any gramatical error... any help would be appreciated.
0 Kommentare
Antworten (1)
Star Strider
am 8 Dez. 2016
I am not certain what you refer to by ‘errors in the measures’.
This code calculates the ‘standard error of the mean’ for your data, and presents them for the two values of ‘x’ in your table:
xy = [0 1
0 2
0 1.5
1 3
1 5
1 4];
[Ux,~,ix] = unique(xy(:,1),'stable'); % Get Unique Values Of ‘x’
N = accumarray(ix, 1); % Count Them
stdev = accumarray(ix, xy(:,2), [], @std); % Calculate Standard Deviations
sem = stdev./sqrt(N); % Calculate Standard Errors Of The Mean
Result = [Ux, sem] % Table Of Results
If you want to calculate the ‘standard errors of the estimate’ from the regression line, use the residuals (deviations from the fitted regression line) for ‘y’. That becomes your data for the errorbar function.
2 Kommentare
Star Strider
am 9 Dez. 2016
Those look like 95% confidence intervals. The easy solution is to multiply the ‘sem’ vector by 1.96. A more correct solution is to use an inverse t-distribution to calculate the confidence intervals. You might have to do that on each ‘sem’ value. In this instance, you would use (N-1) for the appropriate degrees-of-freedom ‘nu’ for the t-statistic, and 0.975 for ‘p’. Use the Statistics and Machine Learning Toolbox tinv function.
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!