error bars of measures
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Star Strider
2016 年 12 月 8 日
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 件のコメント
Star Strider
2016 年 12 月 9 日
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.
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!