Login Register

Access the GIFSQ Portal

Select your user type to log in or register a new account.

Student Portal

Access your food safety courses, certifications, and exams.

Instructor Portal

Manage courses, view student submissions, and grade quizzes.

Company Portal

Manage corporate setup, view employee logs, and access QA services.

SOP: Fitting a Linear Regression Equation with Linearity Test

GIFSQ — Global Institute for Food Safety & Quality

Principle

Regression deals with situations where the variation of one (dependent) variable is related to the variation of a second (independent) variable — for example, the increase in sugar content with maturity. When the paired observations plotted on a scatter diagram show a linear trend, a straight line y = a + bx is fitted to them; the regression coefficient b gives the rate of increase or decrease in y per unit change in x, and an analysis of variance tests whether the regression is significantly linear.

Materials

  • The n pairs of observations (x = independent variable, y = dependent variable)

Procedure

Record the n pairs of observations (x, y) and plot them on a scatter diagram to confirm a linear trend

↓

Compute the sums Σx, Σy, Σx², Σy² and Σxy

↓

Compute the corrected sum of squares for x, the corrected sum of squares for y, and the corrected sum of products using the expressions below

↓

Compute the regression coefficient b and the constant a, and write the regression equation y = a + bx

↓

Use the equation to compute the expected value of y for chosen values of x

↓

Test the linearity of the regression by analysis of variance: divide the corrected sum of squares for regression by the mean square error to obtain the F-ratio, and compare with the tabulated F-values

Calculation

Corrected sum of squares for x:

Σ(x − x̄)² = Σx² − (Σx)²/n

Corrected sum of squares for y:

Σ(y − ȳ)² = Σy² − (Σy)²/n

Corrected sum of products:

Σ(x − x̄)(y − ȳ) = Σxy − (Σx)(Σy)/n

Regression coefficient:

b = (corrected sum of products) / (corrected sum of squares for x)

Constant:

a = ȳ − b·x̄

Regression equation:

y = a + bx

Linearity test:

SS_regression = (corrected sum of products)² / (corrected sum of squares for x)

SS_error = (corrected sum of squares for y) − SS_regression

MS_error = SS_error / (n − 2)

F = SS_regression / MS_error

Where,

  • x = independent variable
  • y = dependent variable
  • a = value of y when x is zero
  • b = regression coefficient (slope)
  • x̄, ȳ = means of x and y
  • n = number of pairs of observations
  • The F-ratio has (1, n − 2) degrees of freedom

Worked example — total solids vs weight-by-length ratio of French beans

Thirty-four pairs of observations of weight-by-length (w/l) ratio (x) against total solids % (y) of French beans of different maturities show a strong positive association.

n = 34; Σx = 13.42; Σy = 277.68; x̄ = 0.3947; ȳ = 8.167

Corrected SS for x = 5.6634 − 13.42²/34 = 5.6634 − 5.2970 = 0.366

Corrected SS for y = 2285.6250 − 277.68²/34 = 2285.6250 − 2267.8289 = 17.7961

Corrected sum of products = 110.6561 − (13.42 × 277.68)/34 = 110.6561 − 109.6019 = 1.0542

b = 1.0542/0.366 = 2.88

a = 8.167 − 2.88 × 0.3947 = 7.0316 (as printed)

Regression equation: y = 7.0316 + 2.88x

Note: the rounded chain “8.167 − 2.88 × 0.3947” as displayed gives 7.0303, not the printed 7.0316; the book’s expected-value table below was computed with a ≈ 7.0303 (0.29 → 7.866, 0.36 → 8.067, 0.44 → 8.297, 0.50 → 8.470, 0.60 → 8.758) — all carried as printed.

Expected values of y (as printed):

x (w/l ratio)Expected y (total solids %)
0.297.866
0.368.067
0.448.297
0.508.470
0.608.758

Linearity test (analysis of variance):

Source of variationdfSum of squaresMean squareF
Total3317.7961—
Regression13.03643.03646.58
Error3214.75970.4612

SS_regression = (1.0542)²/0.366 = 3.0364; SS_error = 17.7961 − 3.0364 = 14.7597; MS_error = 14.7597/32 = 0.4612; F = 3.0364/0.4612 = 6.58.

The F-ratio for (1, 32) degrees of freedom is significant (0.01 < P < 0.05); the regression equation is significantly linear — a large and significant portion of the variance of y has been explained by regression on x.

Precautions

  • The regression coefficient may be positive or negative depending on the orientation of the line; b indicates the rate of increase or decrease in y per unit change in x.

References

Ranganna, S., Handbook of Analysis and Quality Control for Fruit and Vegetable Products, 2nd edition.