Matlab shell-scripts for linear regression analysis

Model I regressions

  • lsqfityStandard Model I linear regression
    • [Y-on-X regression]
    • Sometimes referred to as ordinary least squares (OLS).
    • Fit line by minimizing y-residuals only
    • All data points are given equal weight
    • Use whenever X is controlled and Y is measured
  • lsqfitxAlternate or Reversed Model I regression
    • [X-on-Y regression]
    • Fit line by minimizing x-residuals only
    • All data points are given equal weight
  • lsqfitywWeighted Model I regression
    • [wY-on-X regression]
    • Fit line by minimizing y-residuals only
    • Data points are given varying weight
    • Use whenever X is controlled and Y is measured with varying uncertainty
    • Please note that:
      • This m-file gives the correct results for all parameters (See table 6.2 in Bevington and Robinson, 2003); but,
      • the uncertainties in the slope and intercept are much smaller than the same uncertainties calculated by lsqfity.m or lsqfitx.m (see the results table).
      • Also note that if the values for the uncertainties in the y-data (sY) are constant, then the slope and intercept will be the same as that calculated with lsqfity.m, but the uncertainties in these parameters (sm & sb) will be different.
  • lsqfityzWeighted Model I regression – revised Jan 2000
    • [zY-on-X regression]
    • This is the same regression as lsqfityw.m, except that:
      • York’s (1966) equations for the uncertainties in weighted slope and intercept are used.
      • The revised uncertainties are more in line with those from lsqfity.m.

Model II regressions

  • lsqfitmaPearson’s Major Axis
    • aka: first principal component
    • [Correlation of X & Y]
    • Line is fit by minimizing BOTH x- and y-residuals simultaneously
    • All data are given equal weight
    • Use when units and range of X and Y are the same or very similar
  • lsqfitgmGeometric Mean regression
    • aka: reduced major axis or standard major axis
    • [Correlation of X & Y]
    • Slope of line is the geometric mean of the two slopes determined by regressing Y-on-X and X-on-Y
    • All data are given equal weight
    • Use when units or range of X and Y are different
    • Please note that:
      • This algorithm uses both lsqfity.m and lsqfitx.m for determining the slope.
      • The uncertainties in the slope and intercept are estimated by analogy with the symmetrical uncertainty limits for a model I regression following the treatment by Ricker (1973).
  • lsqbisecLeast Squares Bisector
    • [Regression/correlation of X & Y]
    • Slope of line is determined by bisecting the minor angle between the two model I regressions:
      Y-on-X and X-on-Y
    • All data are given equal weight
    • Use when units or range of X and Y are different
    • Please note that:
      • This algorithm uses both lsqfity.m and lsqfitx.m for determining the slope.
      • The uncertainties in the slope and intercept are estimated by analogy with the symmetrical uncertainty limits for a model I regression following the treatment by Ricker (1973).
  • lsqcubicLeast-Squares-Cubic
    • [Regression/correlation of wX & wY.]
    • Line is fit by minimizing both x- and y-residuals simultaneously for WEIGHTED data points.
    • Each data point can be given its own weight either as the inverse-square of the actual measurement precision or as the inverse-square of the product of the relative measurement precision for the method times concentration.
    • Use when the measurement error of X and/or Y varies.
    • Please note that:
      • This algorithm uses lsqfitma.m for the first estimate of the slope.
      • Iteration proceeds until the change in the slope is less than the user defined limit.

Download a text version of this page.

Products

Data repository
Data policy
What is happening in Monterey Bay today?
Central and Northern California Ocean Observing System
Chemical data
Ocean float data
Slough data
Mooring ISUS measurements
M1 ISUS CTD Data Display
Southern Ocean Data
Mooring data
M1 Mooring Summary Data
M1 ADCP (CeNCOOS)
M1 Asimet
M1 Download Info
M1 EMeter
M1 Flourometer (CeNCOOS)
M1 GPS Location
Molecular and genomics data
ESP Web Portal
Seafloor mapping
Upper ocean data
Spatial Temporal Oceanographic Query System (STOQS) Data
Tide prediction
Image gallery
Video library
Seminars
Previous seminars
David Packard Distinguished Lecturers
Research software
Video Annotation and Reference System
System Overview
Knowledgebase
Installation
Annotation Interface
Video Tape User Guide
Video File User Guide
Still Images User Guide
Installation
Annotation Glossary
Query Interface
Basic User Guide
Advanced User Guide
Results
Installation
Query Glossary
FAQ
VARS Publications
Oceanographic Decision Support System
MB-System seafloor mapping software
MB-System Documentation
MB-System Announcements
MB-System Announcements (Archive)
How to Download and Install MB-System
MB-System Discussion Lists
MB-System FAQ
Matlab scripts: Linear regressions
Introduction to Model I and Model II linear regressions
A brief history of Model II regression analysis
Index of downloadable files
Summary of modifications
Regression rules of thumb
Results for Model I and Model II regressions
Graphs of the Model I and Model II regressions
Which regression: Model I or Model II?
Matlab scripts: Oceanographic calculations
Matlab scripts: Sound velocity
Visual Basic for Excel: Oceanographic calculations
Educational resources
MBARI Summer Internship Program
Education and Research: Testing Hypotheses (EARTH)
EARTH workshops
2016—New Brunswick, NJ
2015—Newport, Oregon
2016 Satellite workshop—Pensacola, FL
2016 Satellite workshop—Beaufort, NC
EARTH resources
EARTH lesson plans
Lesson plans—published
Lesson plans—development
Lesson drafts—2015
Lesson drafts—2016 Pensacola
Center for Microbial Oceanography: Research and Education (C-MORE) Science Kits
Publications
Sample archive