Calculate Uncertainties from X, Y and Y error

52 ビュー (過去 30 日間)
George
George 2022 年 12 月 2 日
回答済み: Gokul Nath S J 2023 年 5 月 23 日
I am trying to calculate the uncertainty to at least 4 decimal places for a set of data including x, y and error in y. I've been able to create a regression line (using the 'errorbar' function) for the data and an equation, but I can't find out how to calculate the uncertainties in the gradient and y intercept. I can't use the software 'LineFit' since I use MacOS, so am trying to find another way to get the same result but with the same extent of accuracy (to at least 4 dp).
Is there a way to do this on Matlab, or indeed on any other software which works for MacOS.
  1 件のコメント
KSSV
KSSV 2022 年 12 月 2 日
REad about polyfit

サインインしてコメントする。

回答 (1 件)

Gokul Nath S J
Gokul Nath S J 2023 年 5 月 23 日
Hi George,
I understand that you would like to calculate uncertainty to atleast 4 decimal places.
As you have mentioned, please note that you can use MATLAB to calculate the uncertainties in the gradient and y-intercept of your regression line. Kindly follow the mentioned steps:
  1. Use the polyfit function in MATLAB to perform linear regression on your data with the error bars. This function returns two output arguments: the slope and the y-intercept of the regression line.
  2. Calculate the residuals, i.e., the differences between the y-values of your data and the predicted y-values of your regression line.
  3. Calculate the mean squared error (MSE) of the residuals by summing the squares of the residuals and dividing by the degrees of freedom (DOF), which is the number of data points minus 2.
  4. Calculate the variance of the residuals as the MSE times the inverse of the sum of the squared differences between the x-values of your data and their mean.
  5. Calculate the standard error of the slope, which is the square root of the variance of the residuals divided by the sum of the squared differences between the x-values of your data and their mean.
  6. Calculate the standard error of the y-intercept, which is the square root of the variance of the residuals times the inverse of the sum of the squared differences between the x-values of your data and their mean.
  7. Multiply the standard errors of the slope and y-intercept by the t-value corresponding to the desired confidence level and the DOF. For example, if you want a 95% confidence interval with 10 DOF, use a t-value of 2.306.
  8. Add and subtract the values obtained in step 7 to and from the slope and y-intercept, respectively, to obtain the upper and lower bounds of the confidence interval.
By following these steps, you can calculate the uncertainties in the gradient and y-intercept of your regression line to at least 4 decimal places in MATLAB.
with regards,
Gokul Nath S J

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by