MBARI creates and globally scales the visionary technologies required to explore, map, and understand our changing ocean.
Resources for educators, students, and anyone aspiring to learn how science and technology brings us closer to the ocean.
Integrate MBARI data with lesson plans and workshops.
Discover deep-sea critters, including exclusive footage and info.
Dive into topics about ocean health and its fascinating features.
Explore deep-sea observations with this interactive guide.
Learn about the MLML/MBARI Research Library.
Access more educational resources from the teams at MBARI.
MBARI is a non-profit oceanographic research center advancing marine science and engineering to understand our changing ocean.
Learn about MBARI’s mission, vision, and values.
Learn about our strategic priorities for the years ahead.
Meet our staff, leadership, and board of directors.
Find job openings and postdoc and internship opportunities.
Follow MBARI on social media and stay updated.
See upcoming seminars, lectures, and public events.
Access the latest annual reports and financial information.
Explore MBARI’s rich history spanning over three decades.
Get media-specific information and assets.
Find the latest job openings and join the team.
Learn about our summer internship program.
Meet our leadership and staff.
Discover deep-sea critters of all types.
Search MBARI’s library of data.
Learn about our technologies.
It has now been 8+ years since any edits were made to these scripts: time to check to see if there are any problems or issues due to the many updates to the Matlab code.
I corrected an error in the y-intercept uncertainty calculation for the major axis algorithm:
Additional minor changes were made to the lsqfit algorithms:
A minor change was made to the names of the Model I regressions:
The m-files for the Model I regressions were renamed to better reflect their applications:
At this time, it was also noticed that the standard deviations for the slope and intercept of the weighted model I regression, lsqfityw.m (formerly known as lsqfit1w.m), were considerably smaller than the standard deviations calculated by the other regression algorithms (see: results).
The algorithms for the Model II regressions were not changed although the header information for these files was revised for the purposes of clarity and completeness.
A new Model II regression algorithm was added, known here as the “least squares bisector:”lsqbisec.m.
And lastly, the test data file, data.txt, was edited and new results were calculated:
For situations where the X-parameter is controlled, as in making-up standards for instrument calibration or doing laboratory experiments where only one variable is changed, then the standard model-I regressions are required.
When comparing two methods that measure the same quantity [e.g., DOC(per) vs DOC(htc)] then the major axis [lsqfitma] provides the most simple, easy to calculate and straight-forward solution.
For comparing two different measured parameters (like DOC vs TCO2, AOU, etc.) and especially when the parameters have different units or widely varying metrics, then the reduced major axis is the method of choice.
When the analytical methods for the different parameters have disparate uncertainties or experimental precision, then a weighted Model II method may be required.
Here are the results from the MATLAB® shell-script routines for fitting a line to the example datasets from Bevington and Robinson (2003):
Here are the results from my MATLAB® shell-script routines for fitting a line to the example dataset (data.txt) using the various linear regression models:
Here are the figures for my MATLAB® shell-script routines for fitting a line to the example dataset (data.txt) using the various linear regression models:
For Excel®, MATLAB® and most other commercial programs the inherent line fitting method is the model-I regression.
To determine whether you are using a model-I or a model-II regression
Note that for either model, r^2 = m(y) / m(x). This is known as the Pearson product-moment correlation coefficient. It is a measure of the linearity of the data, not the fit of the line to the data.
To quickly calculate the model-II geometric mean regression slope, m(gm), first determine the model-I regression slope, m(y), and the correlation coefficient, r. The geometric mean slope is then calculated as: m(gm) = m(y) / r. Or, you can use the MATLAB® script file lsqfitgm.
Also note that for datasets where r = 1, m(y) = m(x) = m(gm). In those cases, this test will not tell you which method you are using.