error bars of measures
30 views (last 30 days)
hello everybody, i have a value table with different measures at some different points e.g
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.
Star Strider on 8 Dec 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
[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.