# Plotting error bars in both dimensions for straight line model [duplicate]

I want to fit a straight line model of the form $y_i = a+ b\ x_i$ to the list of $(x, y)$ pairs given below. How can I plot the data with error bars in both coordinates?

Fit[
{{-5, -1.22}, {-4, -3.28}, {-3, -2.52}, {-2, 3.74}, {-1, 3.01}, {0, -1.8}, {1, 2.49},
{2, 5.48}, {3, 0.42}, {4, 4.80}, {5,4.22}},
{1, x}, {x}
]


The data have Gaussian distributed errors in both the $x$ and $y$ coordinates with $\sigma_x = 1$ and $\sigma_y = 2$.

The code gives a straight line fitted for the data. However, I cant plot the error bars from the data. Can anyone help please?

• How are your defining error bars for the $x$'s? The regression is conditional on the fixed $x$'s and there are no error bars for the $x$'s. Or do you just want to run $y_i=a+b x_i + error_i$ and $x_i = c+d y_i + error_i$ ? – JimB Mar 16 '16 at 4:44
• The data have Gaussian distributed errors in both the $x$ and $y$ coordinates with $\sigma_x = 1$ and $\sigma_y = 2$. – jhon_wick Mar 16 '16 at 4:48
• @jhon_wick This makes the situation quite a bit more complicated. For starters, the linear regression methods available to Fit etc assume no error in the independent variable. You will want to take a look at the following older discussion: Estimate error on slope of linear regression given data with associated uncertainty. Even then, those answers assume that you know the values of the uncertainties associated with the measurements that you are trying to fit, not just their distribution. – MarcoB Mar 16 '16 at 4:53
• You might want to look up errors-in-variables: (1) stats.stackexchange.com/questions/137095/… and (2) en.wikipedia.org/wiki/Errors-in-variables_models. – JimB Mar 16 '16 at 4:57
• And this very recent post might also be helpful: stats.stackexchange.com/questions/201859/…. – JimB Mar 16 '16 at 5:10