Journal of the Geological Society of India

, Volume 77, Issue 4, pp 377–380 | Cite as

A MATLAB™ code to perform weighted linear regression with (correlated or uncorrelated) errors in bivariate data

  • Kaustubh ThirumalaiEmail author
  • Arvind Singh
  • R. Ramesh


MATLAB™ is a powerful, easy to use, software package suitable for many mathematical operations, which finds plenty of scientific applications. One such application is the fitting of trend lines for a given data set so as to interpret the relationship of the variance of the parameters involved. We provide here a code in MATLAB™ that performs the weighted linear regression with (correlated or uncorrelated) errors in bivariate data which can handle ‘force-fit’ regression as well.


Weighted linear regression Correlated errors Force fit Trend line Bivariate regression 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Supplementary material

12594_2011_44_MOESM1_ESM.pdf (530 kb)
Supplementary material, approximately 530 KB.


  1. Cantrell, C.A. (2008) Technical Note: Review of methods for linear least-squares fitting of data and application to atmospheric chemistry problems. Atmospheric Chemistry and Physics Discussions, v.8, pp.6409–6436.CrossRefGoogle Scholar
  2. Huesken, G. (2006) errorbar_x, MATLAB™ Central., [accessed 17 December 2009].
  3. Pearson, K. (1901) On Lines and planes of closest fit to systems of points in space, Philosophical Magz., v.2(6), pp.559–572.Google Scholar
  4. Srinivasan, G., Goswami, J.N. and Bhandari, N. (1999) 26Al in Eucrite Piplia Kalan: Plausible Heat Source and Formation Chronology. Science, v.284, 1348. doi: 10.1126/science.284.5418.1348.CrossRefGoogle Scholar
  5. York, D., Evensen, N. M., Martinez, M.L. and Delgado, J.D.B. (2004) Unified equations for the slope, intercept, and standard errors of the best straight line. American Jour. Physics, v.72(3), pp.367–375.CrossRefGoogle Scholar
  6. York, D. (1966) Least-squares fitting of a straight line, Canadian Jour. Physics, v.44, pp.1079–1086.CrossRefGoogle Scholar

Copyright information

© Geological Society of India 2011

Authors and Affiliations

  1. 1.Jackson School of GeosciencesUT AustinAustinUSA
  2. 2.Physical Research LaboratoryAhmedabadIndia

Personalised recommendations