Calculate Uncertainties from X, Y and Y error
35 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
Respuestas (1)
Gokul Nath S J
el 23 de Mayo de 2023
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:
- 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.
- Calculate the residuals, i.e., the differences between the y-values of your data and the predicted y-values of your regression line.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
0 comentarios
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!