# Simple Linear Regression Analysis

 Chapter 3: Simple Linear Regression Analysis

 Chapter 3 Simple Linear Regression Analysis

Available Software:
Weibull++

Experiment Design & Analysis (*.pdf)

Regression analysis is a statistical technique that attempts to explore and model the relationship between two or more variables. For example, an analyst may want to know if there is a relationship between road accidents and the age of the driver. Regression analysis forms an important part of the statistical analysis of the data obtained from designed experiments and is discussed briefly in this chapter. Every experiment analyzed in a Weibull++ DOE foilo includes regression results for each of the responses. These results, along with the results from the analysis of variance (explained in the One Factor Designs and General Full Factorial Designs chapters), provide information that is useful to identify significant factors in an experiment and explore the nature of the relationship between these factors and the response. Regression analysis forms the basis for all Weibull++ DOE folio calculations related to the sum of squares used in the analysis of variance. The reason for this is explained in Appendix B. Additionally, DOE folios also include a regression tool to see if two or more variables are related, and to explore the nature of the relationship between them.

This chapter discusses simple linear regression analysis while a subsequent chapter focuses on multiple linear regression analysis.

## Simple Linear Regression Analysis

A linear regression model attempts to explain the relationship between two or more variables using a straight line. Consider the data obtained from a chemical process where the yield of the process is thought to be related to the reaction temperature (see the table below).

This data can be entered in the DOE folio as shown in the following figure:

And a scatter plot can be obtained as shown in the following figure. In the scatter plot yield, ${\displaystyle y_{i}\,\!}$ is plotted for different temperature values, ${\displaystyle x_{i}\,\!}$.

It is clear that no line can be found to pass through all points of the plot. Thus no functional relation exists between the two variables ${\displaystyle x\,\!}$ and ${\displaystyle Y\,\!}$. However, the scatter plot does give an indication that a straight line may exist such that all the points on the plot are scattered randomly around this line. A statistical relation is said to exist in this case. The statistical relation between ${\displaystyle x\,\!}$ and ${\displaystyle Y\,\!}$ may be expressed as follows:

${\displaystyle Y=\beta _{0}+\beta _{1}{x}+\epsilon \,\!}$

The above equation is the linear regression model that can be used to explain the relation between ${\displaystyle x\,\!}$ and ${\displaystyle Y\,\!}$ that is seen on the scatter plot above. In this model, the mean value of ${\displaystyle Y\,\!}$ (abbreviated as ${\displaystyle E(Y)\,\!}$) is assumed to follow the linear relation:

${\displaystyle E(Y)=\beta _{0}+\beta _{1}{x}\,\!}$

The actual values of ${\displaystyle Y\,\!}$ (which are observed as yield from the chemical process from time to time and are random in nature) are assumed to be the sum of the mean value, ${\displaystyle E(Y)\,\!}$, and a random error term, ${\displaystyle \epsilon \,\!}$:

{\displaystyle {\begin{aligned}Y=&E(Y)+\epsilon \\=&\beta _{0}+\beta _{1}{x}+\epsilon \end{aligned}}\,\!}

The regression model here is called a simple linear regression model because there is just one independent variable, ${\displaystyle x\,\!}$, in the model. In regression models, the independent variables are also referred to as regressors or predictor variables. The dependent variable, ${\displaystyle Y\,\!}$ , is also referred to as the response. The slope, ${\displaystyle \beta _{1}\,\!}$, and the intercept, ${\displaystyle \beta _{0}\,\!}$ , of the line ${\displaystyle E(Y)=\beta _{0}+\beta _{1}{x}\,\!}$ are called regression coefficients. The slope, ${\displaystyle \beta _{1}\,\!}$, can be interpreted as the change in the mean value of ${\displaystyle Y\,\!}$ for a unit change in ${\displaystyle x\,\!}$.

The random error term, ${\displaystyle \epsilon \,\!}$, is assumed to follow the normal distribution with a mean of 0 and variance of ${\displaystyle \sigma ^{2}\,\!}$. Since ${\displaystyle Y\,\!}$ is the sum of this random term and the mean value, ${\displaystyle E(Y)\,\!}$, which is a constant, the variance of ${\displaystyle Y\,\!}$ at any given value of ${\displaystyle x\,\!}$ is also ${\displaystyle \sigma ^{2}\,\!}$. Therefore, at any given value of ${\displaystyle x\,\!}$, say ${\displaystyle x_{i}\,\!}$, the dependent variable ${\displaystyle Y\,\!}$ follows a normal distribution with a mean of ${\displaystyle \beta _{0}+\beta _{1}{x_{i}}\,\!}$ and a standard deviation of ${\displaystyle \sigma \,\!}$. This is illustrated in the following figure.

### Fitted Regression Line

The true regression line is usually not known. However, the regression line can be estimated by estimating the coefficients ${\displaystyle \beta _{1}\,\!}$ and ${\displaystyle \beta _{0}\,\!}$ for an observed data set. The estimates, ${\displaystyle {\hat {\beta }}_{1}\,\!}$ and ${\displaystyle {\hat {\beta }}_{0}\,\!}$, are calculated using least squares. (For details on least square estimates, refer to Hahn & Shapiro (1967).) The estimated regression line, obtained using the values of ${\displaystyle {\hat {\beta }}_{1}\,\!}$ and ${\displaystyle {\hat {\beta }}_{0}\,\!}$, is called the fitted line. The least square estimates, ${\displaystyle {\hat {\beta }}_{1}\,\!}$ and ${\displaystyle {\hat {\beta }}_{0}\,\!}$, are obtained using the following equations:

${\displaystyle {\hat {\beta }}_{1}={\frac {\sum _{i=1}^{n}y_{i}x_{i}-{\frac {(\sum _{i=1}^{n}y_{i})(\sum _{i=1}^{n}x_{i})}{n}}}{\sum _{i=1}^{n}(x_{i}-{\bar {x}})^{2}}}\,\!}$
${\displaystyle {\hat {\beta }}_{0}={\bar {y}}-{\hat {\beta }}_{1}{\bar {x}}\,\!}$

where ${\displaystyle {\bar {y}}\,\!}$ is the mean of all the observed values and ${\displaystyle {\bar {x}}\,\!}$ is the mean of all values of the predictor variable at which the observations were taken. ${\displaystyle {\bar {y}}\,\!}$ is calculated using ${\displaystyle {\bar {y}}=(1/n)\sum )_{i=1}^{n}y_{i}\,\!}$ and ${\displaystyle {\bar {x}}\,\!}$ is calculated using ${\displaystyle {\bar {x}}=(1/n)\sum )_{i=1}^{n}x_{i}\,\!}$.

Once ${\displaystyle {\hat {\beta }}_{1}\,\!}$ and ${\displaystyle {\hat {\beta }}_{0}\,\!}$ are known, the fitted regression line can be written as:

${\displaystyle {\hat {y}}={\hat {\beta }}_{0}+{\hat {\beta }}_{1}x\,\!}$

where ${\displaystyle {\hat {y}}\,\!}$ is the fitted or estimated value based on the fitted regression model. It is an estimate of the mean value, ${\displaystyle E(Y)\,\!}$. The fitted value,${\displaystyle {\hat {y}}_{i}\,\!}$, for a given value of the predictor variable, ${\displaystyle x_{i}\,\!}$, may be different from the corresponding observed value, ${\displaystyle y_{i}\,\!}$. The difference between the two values is called the residual, ${\displaystyle e_{i}\,\!}$:

${\displaystyle e_{i}=y_{i}-{\hat {y}}_{i}\,\!}$

#### Calculation of the Fitted Line Using Least Square Estimates

The least square estimates of the regression coefficients can be obtained for the data in the preceding table as follows:

{\displaystyle {\begin{aligned}{\hat {\beta }}_{1}=&{\frac {\sum _{i=1}^{n}y_{i}x_{i}-{\frac {(\sum _{i=1}^{n}y_{i})(\sum _{i=1}^{n}x_{i})}{n}}}{\sum _{i=1}^{n}(x_{i}-{\bar {x}})^{2}}}\\=&{\frac {322516-{\frac {4158x1871}{25}}}{5697.36}}\\=&1.9952\approx 2.00\end{aligned}}\,\!}

{\displaystyle {\begin{aligned}{\hat {\beta }}_{0}=&{\bar {y}}-{\hat {\beta }}_{1}{\bar {x}}\\=&166.32-2x74.84\\=&17.0016\approx 17.00\end{aligned}}\,\!}

Knowing ${\displaystyle {\hat {\beta }}_{0}\,\!}$ and ${\displaystyle {\hat {\beta }}_{1}\,\!}$, the fitted regression line is:

{\displaystyle {\begin{aligned}{\hat {y}}=&{\hat {\beta }}_{0}+{\hat {\beta }}_{1}x\\=&17.0016+1.9952\times x\\\approx &17+2{x}\end{aligned}}\,\!}

This line is shown in the figure below.

Once the fitted regression line is known, the fitted value of ${\displaystyle Y\,\!}$ corresponding to any observed data point can be calculated. For example, the fitted value corresponding to the 21st observation in the preceding table is:

{\displaystyle {\begin{aligned}{\hat {y}}_{21}=&{\hat {\beta }}_{0}+{\hat {\beta }}_{1}x_{21}\\=&(17.0016)+(1.9952)\times 93\\=&202.6\end{aligned}}\,\!}

The observed response at this point is ${\displaystyle y_{21}=194\,\!}$. Therefore, the residual at this point is:

{\displaystyle {\begin{aligned}e_{21}=&y_{21}-{\hat {y}}_{21}\\=&194-202.6\\=&-8.6\end{aligned}}\,\!}

In DOE folios, fitted values and residuals can be calculated. The values are shown in the figure below.

## Hypothesis Tests in Simple Linear Regression

The following sections discuss hypothesis tests on the regression coefficients in simple linear regression. These tests can be carried out if it can be assumed that the random error term, ${\displaystyle \epsilon \,\!}$, is normally and independently distributed with a mean of zero and variance of ${\displaystyle \sigma ^{2}\,\!}$.

### t Tests

The ${\displaystyle t\,\!}$ tests are used to conduct hypothesis tests on the regression coefficients obtained in simple linear regression. A statistic based on the ${\displaystyle t\,\!}$ distribution is used to test the two-sided hypothesis that the true slope, ${\displaystyle \beta _{1}\,\!}$, equals some constant value, ${\displaystyle \beta _{1,0}\,\!}$. The statements for the hypothesis test are expressed as:

{\displaystyle {\begin{aligned}H_{0}&:&\beta _{1}=\beta _{1,0}\\H_{1}&:&\beta _{1}\neq \beta _{1,0}\end{aligned}}\,\!}

The test statistic used for this test is:

${\displaystyle T_{0}={\frac {{\hat {\beta }}_{1}-\beta _{1,0}}{se({\hat {\beta }}_{1})}}\,\!}$

where ${\displaystyle {\hat {\beta }}_{1}\,\!}$ is the least square estimate of ${\displaystyle \beta _{1}\,\!}$, and ${\displaystyle se({\hat {\beta }}_{1})\,\!}$ is its standard error. The value of ${\displaystyle se({\hat {\beta }}_{1})\,\!}$ can be calculated as follows:

${\displaystyle se({\hat {\beta }}_{1})={\sqrt {\frac {\frac {\displaystyle \sum _{i=1}^{n}e_{i}^{2}}{n-2}}{\displaystyle \sum _{i=1}^{n}(x_{i}-{\bar {x}})^{2}}}}\,\!}$

The test statistic, ${\displaystyle T_{0}\,\!}$ , follows a ${\displaystyle t\,\!}$ distribution with ${\displaystyle (n-2)\,\!}$ degrees of freedom, where ${\displaystyle n\,\!}$ is the total number of observations. The null hypothesis, ${\displaystyle H_{0}\,\!}$, is accepted if the calculated value of the test statistic is such that:

${\displaystyle -t_{\alpha /2,n-2}

where ${\displaystyle t_{\alpha /2,n-2}\,\!}$ and ${\displaystyle -t_{\alpha /2,n-2}\,\!}$ are the critical values for the two-sided hypothesis. ${\displaystyle t_{\alpha /2,n-2}\,\!}$ is the percentile of the ${\displaystyle t\,\!}$ distribution corresponding to a cumulative probability of ${\displaystyle (1-\alpha /2)\,\!}$ and ${\displaystyle \alpha \,\!}$ is the significance level.

If the value of ${\displaystyle \beta _{1,0}\,\!}$ used is zero, then the hypothesis tests for the significance of regression. In other words, the test indicates if the fitted regression model is of value in explaining variations in the observations or if you are trying to impose a regression model when no true relationship exists between ${\displaystyle x\,\!}$ and ${\displaystyle Y\,\!}$. Failure to reject ${\displaystyle H_{0}:\beta _{1}=0\,\!}$ implies that no linear relationship exists between ${\displaystyle x\,\!}$ and ${\displaystyle Y\,\!}$. This result may be obtained when the scatter plots of against are as shown in (a) of the following figure and (b) of the following figure. (a) represents the case where no model exits for the observed data. In this case you would be trying to fit a regression model to noise or random variation. (b) represents the case where the true relationship between ${\displaystyle x\,\!}$ and ${\displaystyle Y\,\!}$ is not linear. (c) and (d) represent the case when ${\displaystyle H_{0}:\beta _{1}=0\,\!}$ is rejected, implying that a model does exist between ${\displaystyle x\,\!}$ and ${\displaystyle Y\,\!}$. (c) represents the case where the linear model is sufficient. In the following figure, (d) represents the case where a higher order model may be needed.

A similar procedure can be used to test the hypothesis on the intercept. The test statistic used in this case is:

${\displaystyle T_{0}={\frac {{\hat {\beta }}_{0}-\beta _{0,0}}{se({\hat {\beta }}_{0})}}\,\!}$

where ${\displaystyle {\hat {\beta }}_{0}\,\!}$ is the least square estimate of ${\displaystyle \beta _{0}\,\!}$, and ${\displaystyle se({\hat {\beta }}_{0})\,\!}$ is its standard error which is calculated using:

${\displaystyle se({\hat {\beta }}_{0})={\sqrt {{\frac {\displaystyle \sum _{i=1}^{n}e_{i}^{2}}{n-2}}{\Bigg [}{\frac {1}{n}}+{\frac {{\bar {x}}^{2}}{\displaystyle \sum _{i=1}^{n}(x_{i}-{\bar {x}})^{2}}}{\Bigg ]}}}\,\!}$

Example

The test for the significance of regression for the data in the preceding table is illustrated in this example. The test is carried out using the ${\displaystyle t\,\!}$ test on the coefficient ${\displaystyle \beta _{1}\,\!}$. The hypothesis to be tested is ${\displaystyle H_{0}:\beta _{1}=0\,\!}$. To calculate the statistic to test ${\displaystyle H_{0}\,\!}$, the estimate, ${\displaystyle {\hat {\beta }}_{1}\,\!}$, and the standard error, ${\displaystyle se({\hat {\beta }}_{1})\,\!}$, are needed. The value of ${\displaystyle {\hat {\beta }}_{1}\,\!}$ was obtained in this section. The standard error can be calculated as follows:

{\displaystyle {\begin{aligned}se({\hat {\beta }}_{1})&={\sqrt {\frac {\frac {\displaystyle \sum _{i=1}^{n}e_{i}^{2}}{n-2}}{\displaystyle \sum _{i=1}^{n}(x_{i}-{\bar {x}})^{2}}}}\\=&{\sqrt {\frac {(371.627/23)}{5679.36}}}\\=&0.0533\end{aligned}}\,\!}

Then, the test statistic can be calculated using the following equation:

{\displaystyle {\begin{aligned}t_{0}&=&{\frac {{\hat {\beta }}_{1}-\beta _{1,0}}{se({\hat {\beta }}_{0})}}=&{\frac {1.9952-0}{0.0533}}=&37.4058\end{aligned}}\,\!}

The ${\displaystyle p\,\!}$ value corresponding to this statistic based on the ${\displaystyle t\,\!}$ distribution with 23 (n-2 = 25-2 = 23) degrees of freedom can be obtained as follows:

{\displaystyle {\begin{aligned}pvalue=&2\times (1-P(T\leq t_{0})\\=&2\times (1-0.999999)\\=&0\end{aligned}}\,\!}

Assuming that the desired significance level is 0.1, since ${\displaystyle p\,\!}$ value < 0.1, ${\displaystyle H_{0}:\beta _{1}=0\,\!}$ is rejected indicating that a relation exists between temperature and yield for the data in the preceding table. Using this result along with the scatter plot, it can be concluded that the relationship between temperature and yield is linear.

In Weibull++ DOE folios, information related to the ${\displaystyle t\,\!}$ test is displayed in the Regression Information table as shown in the following figure. In this table the ${\displaystyle t\,\!}$ test for ${\displaystyle \beta _{1}\,\!}$ is displayed in the row for the term Temperature because ${\displaystyle \beta _{1}\,\!}$ is the coefficient that represents the variable temperature in the regression model. The columns labeled Standard Error, T Value and P Value represent the standard error, the test statistic for the test and the ${\displaystyle p\,\!}$ value for the ${\displaystyle t\,\!}$ test, respectively. These values have been calculated for ${\displaystyle \beta _{1}\,\!}$ in this example. The Coefficient column represents the estimate of regression coefficients. The Effect column represents values obtained by multiplying the coefficients by a factor of 2. This value is useful in the case of two factor experiments and is explained in Two Level Factorial Experiments. Columns Low Confidence and High Confidence represent the limits of the confidence intervals for the regression coefficients and are explained in Confidence Interval on Regression Coefficients.

### Analysis of Variance Approach to Test the Significance of Regression

The analysis of variance (ANOVA) is another method to test for the significance of regression. As the name implies, this approach uses the variance of the observed data to determine if a regression model can be applied to the observed data. The observed variance is partitioned into components that are then used in the test for significance of regression.

#### Sum of Squares

The total variance (i.e., the variance of all of the observed data) is estimated using the observed data. As mentioned in Statistical Background, the variance of a population can be estimated using the sample variance, which is calculated using the following relationship:

${\displaystyle {{s}^{2}}={\frac {{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{y}_{i}}-{\bar {y}})}^{2}}}{n-1}}\,\!}$

The quantity in the numerator of the previous equation is called the sum of squares. It is the sum of the square of deviations of all the observations, ${\displaystyle {{y}_{i}}\,\!}$, from their mean, ${\displaystyle {\bar {y}}\,\!}$. In the context of ANOVA this quantity is called the total sum of squares (abbreviated ${\displaystyle S{{S}_{T}}\,\!}$) because it relates to the total variance of the observations. Thus:

${\displaystyle S{{S}_{T}}={\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{y}_{i}}-{\bar {y}})}^{2}}\,\!}$

The denominator in the relationship of the sample variance is the number of degrees of freedom associated with the sample variance. Therefore, the number of degrees of freedom associated with ${\displaystyle S{{S}_{T}}\,\!}$, ${\displaystyle dof(S{{S}_{T}})\,\!}$, is ${\displaystyle n-1\,\!}$. The sample variance is also referred to as a mean square because it is obtained by dividing the sum of squares by the respective degrees of freedom. Therefore, the total mean square (abbreviated ${\displaystyle M{{S}_{T}}\,\!}$) is:

${\displaystyle M{{S}_{T}}={\frac {S{{S}_{T}}}{dof(S{{S}_{T}})}}={\frac {S{{S}_{T}}}{n-1}}\,\!}$

When you attempt to fit a regression model to the observations, you are trying to explain some of the variation of the observations using this model. If the regression model is such that the resulting fitted regression line passes through all of the observations, then you would have a "perfect" model (see (a) of the figure below). In this case the model would explain all of the variability of the observations. Therefore, the model sum of squares (also referred to as the regression sum of squares and abbreviated ${\displaystyle S{{S}_{R}}\,\!}$) equals the total sum of squares; i.e., the model explains all of the observed variance:

${\displaystyle S{{S}_{R}}=S{{S}_{T}}\,\!}$

For the perfect model, the regression sum of squares, ${\displaystyle S{{S}_{R}}\,\!}$, equals the total sum of squares, ${\displaystyle S{{S}_{T}}\,\!}$, because all estimated values, ${\displaystyle {{\hat {y}}_{i}}\,\!}$, will equal the corresponding observations, ${\displaystyle {{y}_{i}}\,\!}$. ${\displaystyle S{{S}_{R}}\,\!}$ can be calculated using a relationship similar to the one for obtaining ${\displaystyle S{{S}_{T}}\,\!}$ by replacing ${\displaystyle {{y}_{i}}\,\!}$ by ${\displaystyle {{\hat {y}}_{i}}\,\!}$ in the relationship of ${\displaystyle S{{S}_{T}}\,\!}$. Therefore:

${\displaystyle S{{S}_{R}}={\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{\hat {y}}_{i}}-{\bar {y}})}^{2}}\,\!}$

The number of degrees of freedom associated with ${\displaystyle S{{S}_{R}}\,\!}$ is 1.

Based on the preceding discussion of ANOVA, a perfect regression model exists when the fitted regression line passes through all observed points. However, this is not usually the case, as seen in (b) of the following figure.

In both of these plots, a number of points do not follow the fitted regression line. This indicates that a part of the total variability of the observed data still remains unexplained. This portion of the total variability or the total sum of squares, that is not explained by the model, is called the residual sum of squares or the error sum of squares (abbreviated ${\displaystyle S{{S}_{E}}\,\!}$). The deviation for this sum of squares is obtained at each observation in the form of the residuals, ${\displaystyle {{e}_{i}}\,\!}$. The error sum of squares can be obtained as the sum of squares of these deviations:

${\displaystyle S{{S}_{E}}={\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,e_{i}^{2}={\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{y}_{i}}-{{\hat {y}}_{i}})}^{2}}\,\!}$

The number of degrees of freedom associated with ${\displaystyle S{{S}_{E}}\,\!}$, ${\displaystyle dof(S{{S}_{E}})\,\!}$, is ${\displaystyle (n-2)\,\!}$. The total variability of the observed data (i.e., total sum of squares, ${\displaystyle S{{S}_{T}}\,\!}$) can be written using the portion of the variability explained by the model, ${\displaystyle S{{S}_{R}}\,\!}$, and the portion unexplained by the model, ${\displaystyle S{{S}_{E}}\,\!}$, as:

${\displaystyle S{{S}_{T}}=S{{S}_{R}}+S{{S}_{E}}\,\!}$

The above equation is also referred to as the analysis of variance identity and can be expanded as follows:

${\displaystyle {\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{y}_{i}}-{\bar {y}})}^{2}}={\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{\hat {y}}_{i}}-{\bar {y}})}^{2}}+{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{y}_{i}}-{{\hat {y}}_{i}})}^{2}}\,\!}$

#### Mean Squares

As mentioned previously, mean squares are obtained by dividing the sum of squares by the respective degrees of freedom. For example, the error mean square, ${\displaystyle M{{S}_{E}}\,\!}$, can be obtained as:

${\displaystyle M{{S}_{E}}={\frac {S{{S}_{E}}}{dof(S{{S}_{E}})}}={\frac {S{{S}_{E}}}{n-2}}\,\!}$

The error mean square is an estimate of the variance, ${\displaystyle {{\sigma }^{2}}\,\!}$, of the random error term, ${\displaystyle \epsilon \,\!}$, and can be written as:

${\displaystyle {{\hat {\sigma }}^{2}}={\frac {S{{S}_{E}}}{n-2}}\,\!}$

Similarly, the regression mean square, ${\displaystyle M{{S}_{R}}\,\!}$, can be obtained by dividing the regression sum of squares by the respective degrees of freedom as follows:

${\displaystyle M{{S}_{R}}={\frac {S{{S}_{R}}}{dof(S{{S}_{R}})}}={\frac {S{{S}_{R}}}{1}}\,\!}$

#### F Test

To test the hypothesis ${\displaystyle {{H}_{0}}:{{\beta }_{1}}=0\,\!}$, the statistic used is based on the ${\displaystyle F\,\!}$ distribution. It can be shown that if the null hypothesis ${\displaystyle {{H}_{0}}\,\!}$ is true, then the statistic:

${\displaystyle {{F}_{0}}={\frac {M{{S}_{R}}}{M{{S}_{E}}}}={\frac {S{{S}_{R}}/1}{S{{S}_{E}}/(n-2)}}\,\!}$

follows the ${\displaystyle F\,\!}$ distribution with ${\displaystyle 1\,\!}$ degree of freedom in the numerator and ${\displaystyle (n-2)\,\!}$ degrees of freedom in the denominator. ${\displaystyle {{H}_{0}}\,\!}$ is rejected if the calculated statistic, ${\displaystyle {{F}_{0}}\,\!}$, is such that:

${\displaystyle {{F}_{0}}>{{f}_{\alpha ,1,n-2}}\,\!}$

where ${\displaystyle {{f}_{\alpha ,1,n-2}}\,\!}$ is the percentile of the ${\displaystyle F\,\!}$ distribution corresponding to a cumulative probability of (${\displaystyle 1-\alpha \,\!}$) and ${\displaystyle \alpha \,\!}$ is the significance level.

Example

The analysis of variance approach to test the significance of regression can be applied to the yield data in the preceding table. To calculate the statistic, ${\displaystyle {{F}_{0}}\,\!}$, for the test, the sum of squares have to be obtained. The sum of squares can be calculated as shown next. The total sum of squares can be calculated as:

{\displaystyle {\begin{aligned}S{{S}_{T}}=&{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{y}_{i}}-{\bar {y}})}^{2}}\\=&{\underset {i=1}{\overset {25}{\mathop {\sum } }}}\,{{({{y}_{i}}-166.32)}^{2}}\\=&22979.44\end{aligned}}\,\!}

The regression sum of squares can be calculated as:

{\displaystyle {\begin{aligned}S{{S}_{R}}=&{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{\hat {y}}_{i}}-{\bar {y}})}^{2}}\\=&{\underset {i=1}{\overset {25}{\mathop {\sum } }}}\,{{({{\hat {y}}_{i}}-166.32)}^{2}}\\=&22607.81\end{aligned}}\,\!}

The error sum of squares can be calculated as:

{\displaystyle {\begin{aligned}S{{S}_{E}}=&{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{y}_{i}}-{{\hat {y}}_{i}})}^{2}}\\=&{\underset {i=1}{\overset {25}{\mathop {\sum } }}}\,{{({{y}_{i}}-{{\hat {y}}_{i}})}^{2}}\\=&371.63\end{aligned}}\,\!}

Knowing the sum of squares, the statistic to test ${\displaystyle {{H}_{0}}:{{\beta }_{1}}=0\,\!}$ can be calculated as follows:

{\displaystyle {\begin{aligned}{{f}_{0}}=&{\frac {M{{S}_{R}}}{M{{S}_{E}}}}\\=&{\frac {S{{S}_{R}}/1}{S{{S}_{E}}/(n-2)}}\\=&{\frac {22607.81/1}{371.63/(25-2)}}\\=&1399.20\end{aligned}}\,\!}

The critical value at a significance level of 0.1 is ${\displaystyle {{f}_{0.05,1,23}}=2.937\,\!}$. Since ${\displaystyle {{f}_{0}}>{{f}_{\alpha ,1,n-2}}\,\!}$, ${\displaystyle {{H}_{0}}:{{\beta }_{1}}=0\,\!}$ is rejected and it is concluded that ${\displaystyle {{\beta }_{1}}\,\!}$ is not zero. Alternatively, the ${\displaystyle p\,\!}$ value can also be used. The ${\displaystyle p\,\!}$ value corresponding to the test statistic, ${\displaystyle {{f}_{0}}\,\!}$, based on the ${\displaystyle F\,\!}$ distribution with one degree of freedom in the numerator and 23 degrees of freedom in the denominator is:

{\displaystyle {\begin{aligned}p{\text{ }}value=&1-P(F\leq {{f}_{0}})\\=&1-0.999999\\=&4.17E-22\end{aligned}}\,\!}

Assuming that the desired significance is 0.1, since the ${\displaystyle p\,\!}$ value < 0.1, then ${\displaystyle {{H}_{0}}:{{\beta }_{1}}=0\,\!}$ is rejected, implying that a relation does exist between temperature and yield for the data in the preceding table. Using this result along with the scatter plot of the above figure, it can be concluded that the relationship that exists between temperature and yield is linear. This result is displayed in the ANOVA table as shown in the following figure. Note that this is the same result that was obtained from the ${\displaystyle t\,\!}$ test in the section t Tests. The ANOVA and Regression Information tables in Weibull++ DOE folios represent two different ways to test for the significance of the regression model. In the case of multiple linear regression models these tables are expanded to allow tests on individual variables used in the model. This is done using extra sum of squares. Multiple linear regression models and the application of extra sum of squares in the analysis of these models are discussed in Multiple Linear Regression Analysis.

## Confidence Intervals in Simple Linear Regression

A confidence interval represents a closed interval where a certain percentage of the population is likely to lie. For example, a 90% confidence interval with a lower limit of ${\displaystyle A\,\!}$ and an upper limit of ${\displaystyle B\,\!}$ implies that 90% of the population lies between the values of ${\displaystyle A\,\!}$ and ${\displaystyle B\,\!}$. Out of the remaining 10% of the population, 5% is less than ${\displaystyle A\,\!}$ and 5% is greater than ${\displaystyle B\,\!}$. (For details refer to the Life Data Analysis Reference Book.) This section discusses confidence intervals used in simple linear regression analysis.

### Confidence Interval on Regression Coefficients

A 100 (${\displaystyle 1-\alpha \,\!}$) percent confidence interval on ${\displaystyle {{\beta }_{1}}\,\!}$ is obtained as follows:

${\displaystyle {{\hat {\beta }}_{1}}\pm {{t}_{\alpha /2,n-2}}\cdot se({{\hat {\beta }}_{1}})\,\!}$

Similarly, a 100 (${\displaystyle 1-\alpha \,\!}$) percent confidence interval on ${\displaystyle {{\beta }_{0}}\,\!}$ is obtained as:

${\displaystyle {{\hat {\beta }}_{0}}\pm {{t}_{\alpha /2,n-2}}\cdot se({{\hat {\beta }}_{0}})\,\!}$

### Confidence Interval on Fitted Values

A 100 (${\displaystyle 1-\alpha \,\!}$) percent confidence interval on any fitted value, ${\displaystyle {{\hat {y}}_{i}}\,\!}$, is obtained as follows:

${\displaystyle {{\hat {y}}_{i}}\pm {{t}_{\alpha /2,n-2}}{\sqrt {{{\hat {\sigma }}^{2}}\left[{\frac {1}{n}}+{\frac {{({{x}_{i}}-{\bar {x}})}^{2}}{{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{x}_{i}}-{\bar {x}})}^{2}}}}\right]}}\,\!}$

It can be seen that the width of the confidence interval depends on the value of ${\displaystyle {{x}_{i}}\,\!}$ and will be a minimum at ${\displaystyle {{x}_{i}}={\bar {x}}\,\!}$ and will widen as ${\displaystyle \left|{{x}_{i}}-{\bar {x}}\right|\,\!}$ increases.

### Confidence Interval on New Observations

For the data in the preceding table, assume that a new value of the yield is observed after the regression model is fit to the data. This new observation is independent of the observations used to obtain the regression model. If ${\displaystyle {{x}_{p}}\,\!}$ is the level of the temperature at which the new observation was taken, then the estimate for this new value based on the fitted regression model is:

{\displaystyle {\begin{aligned}{{\hat {y}}_{p}}=&{{\hat {\beta }}_{0}}+{{\hat {\beta }}_{1}}{{x}_{p}}\\=&17.0016+1.9952\times {{x}_{p}}\\\end{aligned}}\,\!}

If a confidence interval needs to be obtained on ${\displaystyle {{\hat {y}}_{p}}\,\!}$, then this interval should include both the error from the fitted model and the error associated with future observations. This is because ${\displaystyle {{\hat {y}}_{p}}\,\!}$ represents the estimate for a value of ${\displaystyle Y\,\!}$ that was not used to obtain the regression model. The confidence interval on ${\displaystyle {{\hat {y}}_{p}}\,\!}$ is referred to as the prediction interval. A 100 (${\displaystyle 1-\alpha \,\!}$) percent prediction interval on a new observation is obtained as follows:

${\displaystyle {{\hat {y}}_{p}}\pm {{t}_{\alpha /2,n-2}}{\sqrt {{{\hat {\sigma }}^{2}}\left[1+{\frac {1}{n}}+{\frac {{({{x}_{p}}-{\bar {x}})}^{2}}{{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{x}_{p}}-{\bar {x}})}^{2}}}}\right]}}\,\!}$

Example

To illustrate the calculation of confidence intervals, the 95% confidence intervals on the response at ${\displaystyle x=93\,\!}$ for the data in the preceding table is obtained in this example. A 95% prediction interval is also obtained assuming that a new observation for the yield was made at ${\displaystyle x=91\,\!}$.

The fitted value, ${\displaystyle {{\hat {y}}_{i}}\,\!}$, corresponding to ${\displaystyle x=93\,\!}$ is:

{\displaystyle {\begin{aligned}{{\hat {y}}_{21}}=&{{\hat {\beta }}_{0}}+{{\hat {\beta }}_{1}}{{x}_{21}}\\=&17.0016+1.9952\times 93\\=&202.6\end{aligned}}\,\!}

The 95% confidence interval ${\displaystyle (\alpha =0.05)\,\!}$ on the fitted value, ${\displaystyle {{\hat {y}}_{21}}=202.6\,\!}$, is:

{\displaystyle {\begin{aligned}=&{{\hat {y}}_{i}}\pm {{t}_{\alpha /2,n-2}}{\sqrt {{{\hat {\sigma }}^{2}}\left[{\frac {1}{n}}+{\frac {{({{x}_{i}}-{\bar {x}})}^{2}}{{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{x}_{i}}-{\bar {x}})}^{2}}}}\right]}}\\=&202.6\pm {{t}_{0.025,23}}{\sqrt {M{{S}_{E}}\left[{\frac {1}{25}}+{\frac {{(93-74.84)}^{2}}{5679.36}}\right]}}\\=&202.6\pm 2.069{\sqrt {16.16\left[{\frac {1}{25}}+{\frac {{(93-74.84)}^{2}}{5679.36}}\right]}}\\=&202.6\pm 2.602\end{aligned}}\,\!}

The 95% limits on ${\displaystyle {{\hat {y}}_{21}}\,\!}$ are 199.95 and 205.2, respectively. The estimated value based on the fitted regression model for the new observation at ${\displaystyle x=91\,\!}$ is:

{\displaystyle {\begin{aligned}{{\hat {y}}_{p}}=&{{\hat {\beta }}_{0}}+{{\hat {\beta }}_{1}}{{x}_{p}}\\=&17.0016+1.9952\times 91\\=&198.6\end{aligned}}\,\!}

The 95% prediction interval on ${\displaystyle {{\hat {y}}_{p}}=198.6\,\!}$ is:

{\displaystyle {\begin{aligned}=&{{\hat {y}}_{p}}\pm {{t}_{\alpha /2,n-2}}{\sqrt {{{\hat {\sigma }}^{2}}\left[1+{\frac {1}{n}}+{\frac {{({{x}_{p}}-{\bar {x}})}^{2}}{{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{({{x}_{p}}-{\bar {x}})}^{2}}}}\right]}}\\=&198.6\pm {{t}_{0.025,23}}{\sqrt {M{{S}_{E}}\left[1+{\frac {1}{25}}+{\frac {{(93-74.84)}^{2}}{5679.36}}\right]}}\\=&198.6\pm 2.069{\sqrt {16.16\left[1+{\frac {1}{25}}+{\frac {{(93-74.84)}^{2}}{5679.36}}\right]}}\\=&198.6\pm 2.069\times 4.1889\\=&198.6\pm 8.67\end{aligned}}\,\!}

The 95% limits on ${\displaystyle {{\hat {y}}_{p}}\,\!}$ are 189.9 and 207.2, respectively. In Weibull++ DOE folios, confidence and prediction intervals can be calculated from the control panel. The prediction interval values calculated in this example are shown in the figure below as Low Prediction Interval and High Prediction Interval, respectively. The columns labeled Mean Predicted and Standard Error represent the values of ${\displaystyle {{\hat {y}}_{p}}\,\!}$ and the standard error used in the calculations.

It is important to analyze the regression model before inferences based on the model are undertaken. The following sections present some techniques that can be used to check the appropriateness of the model for the given data. These techniques help to determine if any of the model assumptions have been violated.

### Coefficient of Determination (${\displaystyle R^{2}}$)

The coefficient of determination is a measure of the amount of variability in the data accounted for by the regression model. As mentioned previously, the total variability of the data is measured by the total sum of squares, ${\displaystyle SS_{T}\,\!}$. The amount of this variability explained by the regression model is the regression sum of squares, ${\displaystyle SS_{R}\,\!}$. The coefficient of determination is the ratio of the regression sum of squares to the total sum of squares.

${\displaystyle R^{2}={\frac {SS_{R}}{SS_{T}}}\,\!}$

${\displaystyle R^{2}\,\!}$ can take on values between 0 and 1 since ${\displaystyle R^{2}={\frac {SS_{R}}{SS_{T}}}\,\!}$ . For the yield data example, ${\displaystyle R^{2}\,\!}$ can be calculated as:

{\displaystyle {\begin{aligned}{{R}^{2}}=&{\frac {S{{S}_{R}}}{S{{S}_{T}}}}\\=&{\frac {22607.81}{22979.44}}\\=&0.98\end{aligned}}\,\!}

Therefore, 98% of the variability in the yield data is explained by the regression model, indicating a very good fit of the model. It may appear that larger values of ${\displaystyle {{R}^{2}}\,\!}$ indicate a better fitting regression model. However, ${\displaystyle {{R}^{2}}\,\!}$ should be used cautiously as this is not always the case. The value of ${\displaystyle {{R}^{2}}\,\!}$ increases as more terms are added to the model, even if the new term does not contribute significantly to the model. Therefore, an increase in the value of ${\displaystyle {{R}^{2}}\,\!}$ cannot be taken as a sign to conclude that the new model is superior to the older model. Adding a new term may make the regression model worse if the error mean square, ${\displaystyle M{{S}_{E}}\,\!}$, for the new model is larger than the ${\displaystyle M{{S}_{E}}\,\!}$ of the older model, even though the new model will show an increased value of ${\displaystyle {{R}^{2}}\,\!}$. In the results obtained from the DOE folio, ${\displaystyle {{R}^{2}}\,\!}$ is displayed as R-sq under the ANOVA table (as shown in the figure below), which displays the complete analysis sheet for the data in the preceding table.

The other values displayed with are S, R-sq(adj), PRESS and R-sq(pred). These values measure different aspects of the adequacy of the regression model. For example, the value of S is the square root of the error mean square, ${\displaystyle MS_{E}\,\!}$, and represents the "standard error of the model." A lower value of S indicates a better fitting model. The values of S, R-sq and R-sq(adj) indicate how well the model fits the observed data. The values of PRESS and R-sq(pred) are indicators of how well the regression model predicts new observations. R-sq(adj), PRESS and R-sq(pred) are explained in Multiple Linear Regression Analysis.

### Residual Analysis

In the simple linear regression model the true error terms, ${\displaystyle {{\epsilon }_{i}}\,\!}$, are never known. The residuals, ${\displaystyle {{e}_{i}}\,\!}$, may be thought of as the observed error terms that are similar to the true error terms. Since the true error terms, ${\displaystyle {{\epsilon }_{i}}\,\!}$, are assumed to be normally distributed with a mean of zero and a variance of ${\displaystyle {{\sigma }^{2}}\,\!}$, in a good model the observed error terms (i.e., the residuals, ${\displaystyle {{e}_{i}}\,\!}$) should also follow these assumptions. Thus the residuals in the simple linear regression should be normally distributed with a mean of zero and a constant variance of ${\displaystyle {{\sigma }^{2}}\,\!}$. Residuals are usually plotted against the fitted values, ${\displaystyle {{\hat {y}}_{i}}\,\!}$, against the predictor variable values, ${\displaystyle {{x}_{i}}\,\!}$, and against time or run-order sequence, in addition to the normal probability plot. Plots of residuals are used to check for the following:

1. Residuals follow the normal distribution.
2. Residuals have a constant variance.
3. Regression function is linear.
4. A pattern does not exist when residuals are plotted in a time or run-order sequence.
5. There are no outliers.

Examples of residual plots are shown in the following figure. (a) is a satisfactory plot with the residuals falling in a horizontal band with no systematic pattern. Such a plot indicates an appropriate regression model. (b) shows residuals falling in a funnel shape. Such a plot indicates increase in variance of residuals and the assumption of constant variance is violated here. Transformation on ${\displaystyle Y\,\!}$ may be helpful in this case (see Transformations). If the residuals follow the pattern of (c) or (d), then this is an indication that the linear regression model is not adequate. Addition of higher order terms to the regression model or transformation on ${\displaystyle x\,\!}$ or ${\displaystyle Y\,\!}$ may be required in such cases. A plot of residuals may also show a pattern as seen in (e), indicating that the residuals increase (or decrease) as the run order sequence or time progresses. This may be due to factors such as operator-learning or instrument-creep and should be investigated further.

Example

Residual plots for the data of the preceding table are shown in the following figures. One of the following figures is the normal probability plot. It can be observed that the residuals follow the normal distribution and the assumption of normality is valid here. In one of the following figures the residuals are plotted against the fitted values, ${\displaystyle {{\hat {y}}_{i}}\,\!}$, and in one of the following figures the residuals are plotted against the run order. Both of these plots show that the 21st observation seems to be an outlier. Further investigations are needed to study the cause of this outlier.

### Lack-of-Fit Test

As mentioned in Analysis of Variance Approach, ANOVA, a perfect regression model results in a fitted line that passes exactly through all observed data points. This perfect model will give us a zero error sum of squares (${\displaystyle S{{S}_{E}}=0\,\!}$). Thus, no error exists for the perfect model. However, if you record the response values for the same values of ${\displaystyle {{x}_{i}}\,\!}$ for a second time, in conditions maintained as strictly identical as possible to the first time, observations from the second time will not all fall along the perfect model. The deviations in observations recorded for the second time constitute the "purely" random variation or noise. The sum of squares due to pure error (abbreviated ${\displaystyle S{{S}_{PE}}\,\!}$) quantifies these variations. ${\displaystyle S{{S}_{PE}}\,\!}$ is calculated by taking repeated observations at some or all values of ${\displaystyle {{x}_{i}}\,\!}$ and adding up the square of deviations at each level of ${\displaystyle x\,\!}$ using the respective repeated observations at that ${\displaystyle x\,\!}$ value.

Assume that there are ${\displaystyle n\,\!}$ levels of ${\displaystyle x\,\!}$ and ${\displaystyle {{m}_{i}}\,\!}$ repeated observations are taken at each ${\displaystyle i\,\!}$ the level. The data is collected as shown next:

{\displaystyle {\begin{aligned}&{{y}_{11}},{{y}_{12}},....,{{y}_{1{{m}_{1}}}}{\text{ repeated observations at }}{{x}_{1}}\\&{{y}_{21}},{{y}_{22}},....,{{y}_{2{{m}_{2}}}}{\text{ repeated observations at }}{{x}_{2}}\\&...\\&{{y}_{i1}},{{y}_{i2}},....,{{y}_{i{{m}_{i}}}}{\text{ repeated observations at }}{{x}_{i}}\\&...\\&{{y}_{n1}},{{y}_{n2}},....,{{y}_{n{{m}_{n}}}}{\text{ repeated observations at }}{{x}_{n}}\end{aligned}}\,\!}

The sum of squares of the deviations from the mean of the observations at ${\displaystyle i\,\!}$ the level of ${\displaystyle x\,\!}$, ${\displaystyle {{x}_{i}}\,\!}$, can be calculated as:

${\displaystyle {\underset {j=1}{\overset {{m}_{i}}{\mathop {\sum } }}}\,{{({{y}_{ij}}-{{\bar {y}}_{i}})}^{2}}\,\!}$

where ${\displaystyle {{\bar {y}}_{i}}\,\!}$ is the mean of the ${\displaystyle {{m}_{i}}\,\!}$ repeated observations corresponding to ${\displaystyle {{x}_{i}}\,\!}$ (${\displaystyle {{\bar {y}}_{i}}=(1/{{m}_{i}})\mathop {} _{j=1}^{{m}_{i}}{{y}_{ij}}\,\!}$). The number of degrees of freedom for these deviations is (${\displaystyle {{m}_{i}}-1\,\!}$ ) as there are ${\displaystyle {{m}_{i}}\,\!}$ observations at ${\displaystyle i\,\!}$ the level of ${\displaystyle x\,\!}$ but one degree of freedom is lost in calculating the mean, ${\displaystyle {{\bar {y}}_{i}}\,\!}$.

The total sum of square deviations (or ${\displaystyle S{{S}_{PE}}\,\!}$) for all levels of ${\displaystyle x\,\!}$ can be obtained by summing the deviations for all ${\displaystyle {{x}_{i}}\,\!}$ as shown next:

${\displaystyle S{{S}_{PE}}={\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{\underset {j=1}{\overset {{m}_{i}}{\mathop {\sum } }}}\,{{({{y}_{ij}}-{{\bar {y}}_{i}})}^{2}}\,\!}$

The total number of degrees of freedom associated with ${\displaystyle S{{S}_{PE}}\,\!}$ is:

{\displaystyle {\begin{aligned}=&{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,({{m}_{i}}-1)\\=&{\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{{m}_{i}}-n\end{aligned}}\,\!}

If all ${\displaystyle {{m}_{i}}=m\,\!}$, (i.e., ${\displaystyle m\,\!}$ repeated observations are taken at all levels of ${\displaystyle x\,\!}$), then ${\displaystyle \mathop {} _{i=1}^{n}{{m}_{i}}=nm\,\!}$ and the degrees of freedom associated with ${\displaystyle S{{S}_{PE}}\,\!}$ are:

${\displaystyle =nm-n\,\!}$

The corresponding mean square in this case will be:

${\displaystyle M{{S}_{PE}}={\frac {S{{S}_{PE}}}{nm-n}}\,\!}$

When repeated observations are used for a perfect regression model, the sum of squares due to pure error, ${\displaystyle S{{S}_{PE}}\,\!}$, is also considered as the error sum of squares, ${\displaystyle S{{S}_{E}}\,\!}$. For the case when repeated observations are used with imperfect regression models, there are two components of the error sum of squares, ${\displaystyle S{{S}_{E}}\,\!}$. One portion is the pure error due to the repeated observations. The other portion is the error that represents variation not captured because of the imperfect model. The second portion is termed as the sum of squares due to lack-of-fit (abbreviated ${\displaystyle S{{S}_{LOF}}\,\!}$) to point to the deficiency in fit due to departure from the perfect-fit model. Thus, for an imperfect regression model:

${\displaystyle S{{S}_{E}}=S{{S}_{PE}}+S{{S}_{LOF}}\,\!}$

Knowing ${\displaystyle S{{S}_{E}}\,\!}$ and ${\displaystyle S{{S}_{PE}}\,\!}$, the previous equation can be used to obtain ${\displaystyle S{{S}_{LOF}}\,\!}$:

${\displaystyle S{{S}_{LOF}}=S{{S}_{E}}-S{{S}_{PE}}\,\!}$

The degrees of freedom associated with ${\displaystyle S{{S}_{LOF}}\,\!}$ can be obtained in a similar manner using subtraction. For the case when ${\displaystyle m\,\!}$ repeated observations are taken at all levels of ${\displaystyle x\,\!}$, the number of degrees of freedom associated with ${\displaystyle S{{S}_{PE}}\,\!}$ is:

${\displaystyle dof(S{{S}_{PE}})=nm-n\,\!}$

Since there are ${\displaystyle nm\,\!}$ total observations, the number of degrees of freedom associated with ${\displaystyle S{{S}_{E}}\,\!}$ is:

${\displaystyle dof(S{{S}_{E}})=nm-2\,\!}$

Therefore, the number of degrees of freedom associated with ${\displaystyle S{{S}_{LOF}}\,\!}$ is:

{\displaystyle {\begin{aligned}=&dof(S{{S}_{E}})-dof(S{{S}_{PE}})\\=&(nm-2)-(nm-n)\\=&n-2\end{aligned}}\,\!}

The corresponding mean square, ${\displaystyle M{{S}_{LOF}}\,\!}$, can now be obtained as:

${\displaystyle M{{S}_{LOF}}={\frac {S{{S}_{LOF}}}{n-2}}\,\!}$

The magnitude of ${\displaystyle S{{S}_{LOF}}\,\!}$ or ${\displaystyle M{{S}_{LOF}}\,\!}$ will provide an indication of how far the regression model is from the perfect model. An ${\displaystyle F\,\!}$ test exists to examine the lack-of-fit at a particular significance level. The quantity ${\displaystyle M{{S}_{LOF}}/M{{S}_{PE}}\,\!}$ follows an ${\displaystyle F\,\!}$ distribution with ${\displaystyle (n-2)\,\!}$ degrees of freedom in the numerator and ${\displaystyle (nm-n)\,\!}$ degrees of freedom in the denominator when all ${\displaystyle {{m}_{i}}\,\!}$ equal ${\displaystyle m\,\!}$. The test statistic for the lack-of-fit test is:

${\displaystyle {{F}_{0}}={\frac {M{{S}_{LOF}}}{M{{S}_{PE}}}}\,\!}$

If the critical value ${\displaystyle {{f}_{\alpha ,n-2,mn-n}}\,\!}$ is such that:

${\displaystyle {{F}_{0}}>{{f}_{\alpha ,n-2,nm-n}}\,\!}$

it will lead to the rejection of the hypothesis that the model adequately fits the data.

Example

Assume that a second set of observations are taken for the yield data of the preceding table. The resulting observations are recorded in the following table. To conduct a lack-of-fit test on this data, the statistic ${\displaystyle {{F}_{0}}=M{{S}_{LOF}}/M{{S}_{PE}}\,\!}$, can be calculated as shown next.

Calculation of Least Square Estimates

The parameters of the fitted regression model can be obtained as:

{\displaystyle {\begin{aligned}{{\hat {\beta }}_{1}}=&{\frac {{\underset {i=1}{\overset {50}{\mathop {\sum } }}}\,{{y}_{i}}{{x}_{i}}-{\frac {\left({\underset {i=1}{\overset {50}{\mathop {\sum } }}}\,{{y}_{i}}\right)\left({\underset {i=1}{\overset {50}{\mathop {\sum } }}}\,{{x}_{i}}\right)}{50}}}{{\underset {i=1}{\overset {50}{\mathop {\sum } }}}\,{{({{x}_{i}}-{\bar {x}})}^{2}}}}\\=&{\frac {648532-{\frac {8356\times 3742}{50}}}{11358.72}}\\=&2.04\end{aligned}}\,\!}

{\displaystyle {\begin{aligned}{{\hat {\beta }}_{0}}=&{\bar {y}}-{{\hat {\beta }}_{1}}{\bar {x}}\\=&167.12-2.04\times 74.84\\=&14.47\end{aligned}}\,\!}

Knowing ${\displaystyle {{\hat {\beta }}_{1}}\,\!}$ and ${\displaystyle {{\hat {\beta }}_{0}}\,\!}$, the fitted values, ${\displaystyle {{\hat {y}}_{i}}\,\!}$, can be calculated.

Calculation of the Sum of Squares

Using the fitted values, the sum of squares can be obtained as follows:

{\displaystyle {\begin{aligned}S{{S}_{T}}=&{\underset {i=1}{\overset {50}{\mathop {\sum } }}}\,{{({{y}_{i}}-{\bar {y}})}^{2}}\\=&47907.28\end{aligned}}\,\!}

{\displaystyle {\begin{aligned}S{{S}_{R}}=&{\underset {i=1}{\overset {50}{\mathop {\sum } }}}\,{{({{\hat {y}}_{i}}-{\bar {y}})}^{2}}\\=&47258.91\end{aligned}}\,\!}

{\displaystyle {\begin{aligned}S{{S}_{E}}=&{\underset {i=1}{\overset {50}{\mathop {\sum } }}}\,{{({{y}_{i}}-{{\hat {y}}_{i}})}^{2}}\\=&648.37\end{aligned}}\,\!}

Calculation of ${\displaystyle M{{S}_{LOF}}\,\!}$

The error sum of squares, ${\displaystyle S{{S}_{E}}\,\!}$, can now be split into the sum of squares due to pure error, ${\displaystyle S{{S}_{PE}}\,\!}$, and the sum of squares due to lack-of-fit, ${\displaystyle S{{S}_{LOF}}\,\!}$. ${\displaystyle S{{S}_{PE}}\,\!}$ can be calculated as follows considering that in this example ${\displaystyle n=25\,\!}$ and ${\displaystyle m=2\,\!}$:

{\displaystyle {\begin{aligned}S{{S}_{PE}}&={\underset {i=1}{\overset {n}{\mathop {\sum } }}}\,{\underset {j=1}{\overset {{m}_{i}}{\mathop {\sum } }}}\,{{({{y}_{ij}}-{{\bar {y}}_{i}})}^{2}}\\&={\underset {i=1}{\overset {25}{\mathop {\sum } }}}\,{\underset {j=1}{\overset {2}{\mathop {\sum } }}}\,{{({{y}_{ij}}-{{\bar {y}}_{i}})}^{2}}\\&=350\end{aligned}}\,\!}

The number of degrees of freedom associated with ${\displaystyle S{{S}_{PE}}\,\!}$ is:

{\displaystyle {\begin{aligned}dof(S{{S}_{PE}})&=nm-n\\&=25\times 2-25\\&=25\end{aligned}}\,\!}

The corresponding mean square, ${\displaystyle M{{S}_{PE}}\,\!}$, can now be obtained as:

{\displaystyle {\begin{aligned}M{{S}_{PE}}&={\frac {S{{S}_{PE}}}{dof(S{{S}_{PE}})}}\\&={\frac {350}{25}}\\&=14\end{aligned}}\,\!}

${\displaystyle S{{S}_{LOF}}\,\!}$ can be obtained by subtraction from ${\displaystyle S{{S}_{E}}\,\!}$ as:

{\displaystyle {\begin{aligned}S{{S}_{LOF}}&=S{{S}_{E}}-S{{S}_{PE}}\\&=648.37-350\\&=298.37\end{aligned}}\,\!}

Similarly, the number of degrees of freedom associated with ${\displaystyle S{{S}_{LOF}}\,\!}$ is:

{\displaystyle {\begin{aligned}dof(S{{S}_{LOF}})&=dof(S{{S}_{E}})-dof(S{{S}_{PE}})\\&=(nm-2)-(nm-n)\\&=23\end{aligned}}\,\!}

The lack-of-fit mean square is:

{\displaystyle {\begin{aligned}M{{S}_{LOF}}&={\frac {M{{S}_{LOF}}}{dof(M{{S}_{LOF}})}}\\&={\frac {298.37}{23}}\\&=12.97\end{aligned}}\,\!}

Calculation of the Test Statistic

The test statistic for the lack-of-fit test can now be calculated as:

{\displaystyle {\begin{aligned}{{f}_{0}}&={\frac {M{{S}_{LOF}}}{M{{S}_{PE}}}}\\&={\frac {12.97}{14}}\\&=0.93\end{aligned}}\,\!}

The critical value for this test is:

${\displaystyle {{f}_{0.05,23,25}}=1.97\,\!}$

Since ${\displaystyle {{f}_{0}}<{{f}_{0.05,23,25}}\,\!}$, we fail to reject the hypothesis that the model adequately fits the data. The ${\displaystyle p\,\!}$ value for this case is:

{\displaystyle {\begin{aligned}p{\text{ }}value&=1-P(F\leq {{f}_{0}})\\&=1-0.43\\&=0.57\end{aligned}}\,\!}

Therefore, at a significance level of 0.05 we conclude that the simple linear regression model, ${\displaystyle y=14.47+2.04x\,\!}$, is adequate for the observed data. The following table presents a summary of the ANOVA calculations for the lack-of-fit test.

## Transformations

The linear regression model may not be directly applicable to certain data. Non-linearity may be detected from scatter plots or may be known through the underlying theory of the product or process or from past experience. Transformations on either the predictor variable, ${\displaystyle x\,\!}$, or the response variable, ${\displaystyle Y\,\!}$, may often be sufficient to make the linear regression model appropriate for the transformed data. If it is known that the data follows the logarithmic distribution, then a logarithmic transformation on ${\displaystyle Y\,\!}$ (i.e., ${\displaystyle {{Y}^{*}}=\log(Y)\,\!}$) might be useful. For data following the Poisson distribution, a square root transformation (${\displaystyle {{Y}^{*}}={\sqrt {Y}}\,\!}$) is generally applicable.

Transformations on ${\displaystyle Y\,\!}$ may also be applied based on the type of scatter plot obtained from the data. The following figure shows a few such examples.

For the scatter plot labeled (a), a square root transformation (${\displaystyle {{Y}^{*}}={\sqrt {Y}}\,\!}$) is applicable. While for the plot labeled (b), a logarithmic transformation (i.e., ${\displaystyle {{Y}^{*}}=\log(Y)\,\!}$) may be applied. For the plot labeled (c), the reciprocal transformation (${\displaystyle {{Y}^{*}}=1/Y\,\!}$) is applicable. At times it may be helpful to introduce a constant into the transformation of ${\displaystyle Y\,\!}$. For example, if ${\displaystyle Y\,\!}$ is negative and the logarithmic transformation on ${\displaystyle Y}$ seems applicable, a suitable constant, ${\displaystyle k\,\!}$, may be chosen to make all observed ${\displaystyle Y\,\!}$ positive. Thus the transformation in this case would be ${\displaystyle {{Y}^{*}}=\log(k+Y)\,\!}$ .

The Box-Cox method may also be used to automatically identify a suitable power transformation for the data based on the relation:

${\displaystyle {{Y}^{*}}={{Y}^{\lambda }}\,\!}$

Here the parameter ${\displaystyle \lambda \,\!}$ is determined using the given data such that ${\displaystyle S{{S}_{E}}\,\!}$ is minimized (details on this method are presented in One Factor Designs).