Calculates slope and intercept for linear regression of data with errors in X and Y. The errors can be specified as varying point to point, as can the correlation of the errors in X and Y.
The uncertainty in the slope and intercept are also estimated.
This follows the method in D. York, N. Evensen, M. Martinez, J. Delgado "Unified equations for the slope, intercept, and standard errors of the best straight line" Am. J. Phys. 72 (3) March 2004.
The package includes an example and a Monte Carlo simulation verifying the estimated uncertainties.
For more info, visit http://blog.nutaksas.com
Hi Travis, thanks for this really awesome code, but I wonder how can I the correlation coefficient from the function?
Hi, similarly to Felix, I think the code is great and I'm wondering if it is possible to force the linear regression to go through the origin, i.e. a=0? Thank you
I was wondering if this code provides with an MSWD value for the isochron linear fit.
It looks like code is supposed to do exactly what I am after, unfortunately I am having problems with your York_fit.m code:
at 40 ==> tmp=Y/[X; ones(1,N)]; shouldn't it be tmp=[Y/X; ones(1,N)]; ?
but even if I change this I am still encountering more errors:
??? Error using ==> times
Matrix dimensions must agree.
Error in ==> york_fit at 58
I really like the code but is it possible to force the linear regression to go through the origin, i.e. a=0?
Rainer Boegle: This method is only for a single input.
Can I use multiple regression and
can I omit the offset in the model?
E.g. Y is explained by two betas corresponding with two different x (of same type of measurement, i.e. same error), but no offset is fitted?
Y = X*beta + error
where X = [x1; x2]
Create scripts with code, output, and formatted text in a single executable document.