1 Regression
As we have already noted, relationship(s) between variables are of interest to engineers who may wish to determine the degree of association existing between independent and dependent variables. Knowing this often helps engineers to make predictions and, on this basis, to forecast and plan. Essentially, regression analysis provides a sound knowledge base from which accurate estimates of the values of a dependent variable may be made once the values of related independent variables are known.
It is worth noting that in practice the choice of independent variable(s) may be made by the engineer on the basis of experience and/or prior knowledge since this may indicate to the engineer which independent variables are likely to have a substantial influence on the dependent variable. In summary, we may state that the principle objectives of regression analysis are:
- to enable accurate estimates of the values of a dependent variable to be made from known values of a set of independent variables;
- to enable estimates of errors resulting from the use of a regression line as a basis of prediction.
Note that if a regression line is represented as where is the independent variable, then the actual function used (linear, quadratic, higher degree polynomial etc.) may be obtained via the use of a theoretical analysis or perhaps a scatter diagram (see below) of some real data. Note that a regression line represented as is called a regression line of on .
1.1 Scatter diagrams
A useful first step in establishing the degree of association between two variables is the plotting of a scatter diagram . Examples of pairs of measurements which an engineer might plot are:
- volume and pressure;
- acceleration and tyre wear;
- current and magnetic field;
- torsion strength of an alloy and purity.
If there exists a relationship between measured variables, it can take many forms. Even though an outline introduction to non-linear regression is given at the end of this Workbook, we shall focus on the linear relationship only.
In order to produce a good scatter diagram you should follow the steps given below:
- Give the diagram a clear title and indicate exactly what information is being displayed;
- Choose and clearly mark the axes;
- Choose carefully and clearly mark the scales on the axes;
- Indicate the source of the data.
Examples of scatter diagrams are shown below.
- Figure 1 shows an association which follows a curve, possibly exponential, quadratic or cubic;
- Figure 2 shows a reasonable degree of linear association where the points of the scatter diagram lie in an area surrounding a straight line;
- Figure 3 represents a randomly placed set of points and no linear association is present between the variables.
Note that in Figure 2, the word ‘reasonable’ is not defined and that while points ‘close’ to the indicated straight line may be explained by random variation, those ‘far away’ may be due to assignable variation.
The rest of this Section will deal with linear association only although it is worth noting that techniques do exist for transforming many non-linear relationships into linear ones. We shall investigate linear association in two ways, firstly by using educated guess work to obtain a regression line ‘by eye’ and secondly by using the well-known technique called the method of least squares.
1.2 Regression lines by eye
Note that at a very simple level, we may look at the data and, using an ‘educated guess’, draw a line of regression ‘by eye’ through a set of points. However, finding a regression line by eye is unsatisfactory as a general statistical method since it involves guess-work in drawing the line with the associated errors in any results obtained. The guess-work can be removed by the method of least squares in which the equation of a regression line is calculated using data. Essentially, we calculate the equation of the regression line by minimising the sum of the squared vertical distances between the data points and the line.
1.3 The method of least squares - an elementary view
We assume that an experiment has been performed which has resulted in pairs of values, say and that these results have been checked for approximate linearity on the scatter diagram given below.
Figure 4
The vertical distances of each point from the line are easily calculated as
These distances are squared to guarantee that they are positive and calculus is used to minimise the sum of the squared distances. Effectively we are minimizing the sum of a two-variable expression and need to use partial differentiation. If you wish to follow this up and look in more detail at the technique, any good book (engineering or mathematics) containing sections on multi-variable calculus should suffice. We will not look at the details of the calculations here but simply note that the process results in two equations in the two unknowns and being formed. These equations are:
(i)
and
(ii)
The second of these equations (ii) immediately gives a useful result. Rearranging the equation we get
or, put more simply
where is the mean of the array of data points .
This shows that the mean of the array always lies on the regression line. Since the mean is easily calculated, the result forms a useful check for a plotted regression line. Ensure that any regression line you draw passes through the mean of the array of data points.
Eliminating from the equations gives a formula for the gradient of the regression line, this is:
often written as
The quantity is, of course, the variance of the -values. The quantity is known as the covariance (of and ) and will appear again later in this Workbook when we measure the degree of linear association between two variables.
Knowing the value of enables us to obtain the value of from the equation
Key Point 1
Least Squares Regression - on
The least squares regression line of on has the equation , where
and is given by the equation
It should be noted that the coefficients and obtained here will give us the regression line of on . This line is used to predict values given values. If we need to predict the values of from given values of we need the regression line of on . The two lines are not the same except in the (very) special case where all of the points lie exactly on a straight line. It is worth noting however, that the two lines cross at the point . It can be shown that the regression line of on is given by Key Point 2:
Example 1
A warehouse manager of a company dealing in large quantities of steel cable needs to be able to estimate how much cable is left on his partially used drums. A random sample of twelve partially used drums is taken and each drum is weighed and the corresponding length of cable measured. The results are given in the table below:
Weight of drum and cable ( ) kg. | Measured length of cable ( ) m. |
30 | 70 |
40 | 90 |
40 | 100 |
50 | 120 |
50 | 130 |
50 | 150 |
60 | 160 |
70 | 190 |
70 | 200 |
80 | 200 |
80 | 220 |
80 | 230 |
Find the least squares regression line in the form and use it to predict the lengths of cable left on drums whose weights are:
(i) 35 kg (ii) 85 kg (iii) 100 kg
In the latter case state any assumptions which you make in order to find the length of cable left on the drum.
Solution
Excel calculations give so that the formulae
and
give and . Our regression line is so .
Hence, the required predicted values are:
all results being in metres.
To obtain the last result we have assumed that the linearity of the relationship continues beyond the range of values actually taken.
Task!
An article in the Journal of Sound and Vibration 1991 (151) explored a possible relationship between hypertension (defined as blood pressure rise in mm of mercury) and exposure to noise levels (measured in decibels). Some data given is as follows:
Noise Level ( ) | Blood pressure rise ( ) | Noise Level ( ) | Blood pressure rise ( ) |
60 | 1 | 85 | 5 |
63 | 0 | 89 | 4 |
65 | 1 | 90 | 6 |
70 | 2 | 90 | 8 |
70 | 5 | 90 | 4 |
70 | 1 | 90 | 5 |
80 | 4 | 94 | 7 |
90 | 6 | 100 | 9 |
80 | 2 | 100 | 7 |
80 | 3 | 100 | 6 |
- Draw a scatter diagram of the data.
- Comment on whether a linear model is appropriate for the data.
- Calculate a line of best fit of on for the data given.
- Use your regression line predict the expected rise in blood pressure for a exposure to a noise level of 97 decibels.
-
Entering the data into Microsoft Excel and plotting gives
Blood Pressure increase versus recorded sound level
- A linear model is appropriate.
- Excel calculations give so that and . Our regression line is .
- The predicted value is: mm mercury.
1.4 The method of least squares - a modelling view
We take the dependent variable to be a random variable whose value, for a fixed value of depends on the value of and a random error component say and we write
Adopting the notation of conditional probability, we are looking for the expected value of for a given value of . The expected value of for a given value of is denoted by
The variance of for a given value of is given by the relationship
, assuming independence.
If represents the true mean value of for a given value of then
, assuming a linear relationship holds,
is a straight line of mean values. If we now assume that the errors are distributed with mean 0 and variance we may write
since .
and
since .
This implies that for each value of , is distributed with mean and variance . Hence when the variance is small the observed values of will be close to the regression line and when the variance is large, at least some of the observed values of may not be close to the line. Note that the assumption that the errors are distributed with mean 0 may be made without loss of generality. If the errors had any other mean, we could subtract it and then add the mean to the value of . The ideas are illustrated in the following diagram.
Figure 5
The regression line is shown passing through the means of the distributions for the individual values of . The value of corresponding to the -value can be represented by the equation
where is the error of the observed value of that is the difference from its expected value, namely
Now, if we estimate and with and , the residual , or estimated error, becomes
so that the sum of the squares of the residuals is given by
and we may minimize the quantity by using the method of least squares as before. The mathematical details are omitted as before and the equations obtained for and are as before, namely
and .
Note that since the error in the th observation essentially describes the error in the fit of the model to the th observation, the sum of the squares of the errors will now be used to allow us to comment on the adequacy of fit of a linear model to a given data set.
1.5 Adequacy of fit
We now know that the variance is the key to describing the adequacy of fit of our simple linear model. In general, the smaller the variance, the better the fit although you should note that it is wise to distinguish between ‘poor fit’ and a large error variance. Poor fit may suggest, for example, that the relationship is not in fact linear and that a fundamental assumption made has been violated. A large value of does not necessarily mean that a linear model is a poor fit.
It can be shown that the sum of the squares of the errors say can be used to give an unbiased estimator of via the formula
where is the number of independent variables used in the regression equation. In the case of simple linear regression since we are using just and and the estimator becomes:
The quantity is usually used explicitly in formulae whose purpose is to determine the adequacy of a linear model to explain the variability found in data. Two ways in which the adequacy of a regression model may be judged are given by the so-called Coefficient of Determination and the Adjusted Coefficient of Determination .
1.6 The coefficient of determination
Denoted by , the Coefficient of Determination is defined by the formula
where is the sum of the squares of the errors and is the sum of the squares of the totals given by . The value of is sometimes described as representing the amount of variability explained or accounted for by a regression model. For example, if after a particular calculation it was found that , we could say that the model accounts for about 88% of the variability found in the data. However, deductions made on the basis of the value of should be treated cautiously, the reasons for this are embedded in the following properties of the statistic. It can be shown that:
- a large value of does not necessarily imply that a model is a good fit;
- adding a regressor variable (simple regression becomes multiple regression) always increases the value of . This is one reason why a large value of does not necessarily imply a good model;
- models giving large values of can be poor predictors of new values if the fitted model does not apply at the appropriate -value.
Finally, it is worth noting that to check the fit of a linear model properly, one should look at plots of residual values. In some cases, tests of goodness-of-fit are available although this topic is not covered in this Workbook.
1.7 The adjusted coefficient of determination
Denoted (often) by , the Adjusted Coefficient of Determination is defined as
where is the number of variables in the regression equation. For the simple linear model, since we have two unknown parameters in the regression equation, the intercept and the coefficient of . It can be shown that:
- is a better indicator of the adequacy of predictive power than since it takes into account the number of regressor variables used in the model;
- does not necessarily increase when a new regressor variable is added.
Both coefficients claim to measure the adequacy of the predictive power of a regression model and their values indicate the proportion of variability explained by the model. For example a value of
may be interpreted as indicating that a model explains 97.51% of the variability it describes. For example, the drum and cable example considered previously gives the results outlined below with
In general, is (perhaps) more useful than for comparing alternative models. In the context of a simple linear model, is easier to interpret. In the drum and cable example we would claim that the linear model explains some 96.2% of the variation it describes.
Drum & Cable | Cable Length | Predicted Values | Error Squares | |||
30 | 900 | 70 | 4900 | 2100 | 70 | 0.00 |
40 | 1600 | 90 | 8100 | 3600 | 100 | 100.00 |
40 | 1600 | 100 | 10000 | 4000 | 100 | 0.00 |
50 | 2500 | 120 | 14400 | 6000 | 130 | 100.00 |
50 | 2500 | 130 | 16900 | 6500 | 130 | 0.00 |
50 | 2500 | 150 | 22500 | 7500 | 130 | 400.00 |
60 | 3600 | 160 | 25600 | 9600 | 160 | 0.00 |
70 | 4900 | 190 | 36100 | 1330 | 190 | 0.00 |
70 | 4900 | 200 | 40000 | 14000 | 190 | 100.00 |
80 | 6400 | 200 | 40000 | 16000 | 220 | 400.00 |
80 | 6400 | 220 | 48400 | 17600 | 220 | 0.00 |
80 | 6400 | 230 | 52900 | 18400 | 220 | 100.00 |
Sum of | Sum of | Sum of | Sum of | Sum of | SSE | |
SST | ||||||
Task!
Use the drum and cable data given in Example 1 (page 7) and set up a spreadsheet to verify the values of the Coefficient of Determination and the Adjusted Coefficient of Determination calculated on page 12.
As per the table on page 12 giving and .
1.8 Significance testing for regression
Note that the results in this Section apply to the simple linear model only. Some additions are necessary before the results can be generalized.
The discussions so far pre-suppose that a linear model adequately describes the relationship between the variables. We can use a significance test involving the distribution to decide whether or not is linearly dependent on . We set up the following hypotheses:
Key Point 3
Significance Test for Regression
The test statistic is
where and rejection at the 5% level of significance occurs if
Note that we have one degree of freedom since we are testing only one parameter ( ) and that denotes the number of pairs of values. A set of tables giving the 5% values of the -distribution is given at the end of this Workbook (Table 1).
Example 2
Test to determine whether a simple linear model is appropriate for the data previously given in the drum and cable example above.
Solution
We know that
where is the total sum of squares (of ) so that (from the spreadsheet above) we have:
Hence
From Table 1, the critical value is .
Hence, since , we reject the null hypothesis and conclude that .
1.9 Regression curves
The Section should be regarded as introductory only. The reason for including non-linear regression is to demonstrate how the method of least squares can be extended to deal with cases where the relationship between variables is, for example, quadratic or exponential.
A regression curve is defined to be the curve passing through the expected value of for a set of given values of . The idea is illustrated by the following diagram.
Figure 6
We will look at the quadratic and exponential cases in a little detail.
1.10 The quadratic case
We are looking for a functional relation of the form
and so, using the method of least squares, we require the values of and which minimize the expression
Note here that the regression described by the form
is actually a linear regression since the expression is linear in and .
Omitting the subscripts and using partial differentiation gives
At a minimum we require
which results in the three linear equations
which can be solved to give the values of and .
1.11 The exponential case
We use the same technique to look for a functional relation of the form
As before, using the method of least squares, we require the values of and which minimize the expression
Again omitting the subscripts and using partial differentiation gives
At a minimum we require
which results in the two non-linear equations
which can be solved by iterative methods to give the values of and .
Note that it is possible to combine (for example) linear and exponential regression to obtain a regression equation of the form
The method of least squares may then be used to find estimates of .