Method of Linear Regression
- Page ID
- 77480
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)In the case that one believes that a series of two variables correlate linearly with each other, the method of least squares may be used to find the "best" straight line through the points. The method which follows assumes that one "knows" the variable on the x-axis more accurately than the variable on the y-axis. The y-axis variable is often referred to as the dependent variable and the x-axis variable the independent variable. Where a mathematical function y=f(x) is being considered, one might say that the value of x determines the value of y. Where y represents values measured with an instrument and there is only presumed to be a relationship between x and y, not only would one anticipate favorably that such a relationship will be exhibited, but that relationship might also be expected to be somewhat muddled by possible biases and random errors typical of the instrument which measured the y values and those typical of some other instrument responsible for establishing the x values.
In colorimetry for example the x-axis variable is concentration of a known solution and the y-axis variable is a measured absorbance of that solution. Once the relationship is established the absorbance of an unknown solution is measured and the line representing the relationship between the two variables can then be used to determine the concentration of the unknown. A melting point curve would show concentration or mole fraction or w/w % on the x-axis and melting point on the y-axis. There are many cases though in which a distinguishing feature such as knowing the x-axis variable more accurately is not clear or is not followed. A pressure/volume diagram is one in which both variables might be known with equal precision. When calibrating a buret, the volume customarily would be shown across the x-axis and the "corrected volume" obtained from a mass measured on an analytical balance would appear along the y-axis, even though the mass can be determined to 4-5 significant figures and the volume only to 3-4. In any case, one says for the method described below, that it is the y-axis variable which has a measurable error and the "residuals" or differences in a vertical direction between each measured y value and the best straight line between all the points are taken into account for this method. The method is to find m (the slope) and b (the y-intercept) for a relationship given by
\[ y = mx + b \nonumber \]
Five intermediate quantities are defined for the convenience of calculating various values associated with a least squares linear regression in two variables. Seven useful results can be calculated from these five intermediate quantities but for the purpose of this discussion only three will be shown: the method of finding m, the method of finding the (y-intercept) and the method of finding the standard deviation about the regression line. "N" in each equation below represents the number of xi and yi pairs, or the number of measurements.
The Five Intermediate Quantities
\[S_{xx} = \sum_i x_i^2 - \dfrac{\left(\sum x_i\right)^2}{N} \nonumber \]
\[S_{yy} = \sum_i y_i^2 - \dfrac{\left(\sum y_i\right)^2}{N} \nonumber \]
\[S_{xy} = \sum_i x_ix_i - \dfrac{\left(\sum x_i\right)\left(\sum y_i\right)}{N} \nonumber \]
\[ \bar{x} = \dfrac{\sum x_i}{N} \nonumber \]
\[ \bar{y} = \dfrac{\sum y_i}{N} \nonumber \]
Three of Seven Useful Results
The slope m may be calculated using the formula
\[ m =\dfrac{S_{xy}}{S_{xx}} \nonumber \]
The (y-intercept) may be calculated using the formula
\[b = \bar{y} - m \bar{x} \nonumber \]
The standard deviation \(s_r\) about the regression line may be calculated using the formula
\[ s_r = \sqrt{\dfrac{S_{yy} -m^2 S_xx}{N-2}} \nonumber \]
A number of calculators have built-in software to obtain these results. The process is often referred to as "linear regression" in calculator manuals. Spread sheet programs also offer this feature.
Contributors and Attributions
- Ulrich de la Camp and Oliver Seely (California State University, Dominguez Hills).