Regression Analysis 4 of 6
On this page

Regression Analysis

4.3 Residual Analysis

Chapter 3 of 5 51 min read

In both Simple Linear Regression and Multiple Regression, the assumptions of the fitted model need to be validated for the results to be reliable. We call it Waste Analysis a set of techniques used to investigate the suitability of a regression model based on residuals. As seen previously, the residue $(e_i)$ is given by the difference between the observed response variable $(Y_i)$ and the estimated response variable $(\widehat{Y}_i)$, that is

$$ e_i=Y_i-\widehat{Y_i}=Y_i-\widehat{\beta_0}-\widehat{\beta_1}x_{1i}-\dots-\widehat{\beta_p} x_{pi}\quad i=1,\dots,n.$$

The basic idea of residual analysis is that, if the model is appropriate, the residuals should reflect the properties imposed by the model’s error term. Such assumptions are

$$Y = X \beta + \varepsilon,$$

in which $\varepsilon = (\varepsilon_1, \varepsilon_2, \cdots,\varepsilon_n)^\prime,$ with

i. $\varepsilon_i$ and $\varepsilon_j$ are independent $(i\neq j)$;

ii. $Var(\varepsilon_i) = \sigma^2$ (constant);

iii. $\varepsilon_i \sim N(0,\sigma^2)$ (normality);

iv. Model is linear;

v. There are no influential outliers (atypical points).

In Multiple Regression, in addition to the assumptions listed above, we need to diagnose collinearity and multicollinearity between the input variables so that the relationship between them does not interfere with the results, causing erroneous or unreliable inferences.

The techniques used to verify the assumptions described above can be informal (such as graphics) or formal (like tests). Graphic techniques, as they are visual, can be subjective and therefore formal techniques are more suitable for decision making. The ideal is to combine available techniques, both formal and informal, to diagnose problems in the model’s assumptions.

Some graphical techniques for analyzing waste are:

  • Graph of residuals versus adjusted values: checks the homoscedasticity of the model, that is, constant σ².

  • Graph of residuals versus order of data collection: evaluate the hypothesis of data independence.

  • Normal probability paper: check the normality of the data. See details in Probability Paper in the Inference content.

  • Graph of Studentized Residuals versus adjusted values: checks if there are outliers in Y.

  • Plot of Standardized Residuals versus adjusted values: checks whether there are outliers in Y.

  • Leverage Chart (Diagonal of Matrix H): checks if there are outliers in X.

For formal waste analysis, we can perform the following tests:

  • Normality Tests in which details are contained in the Inference content.

  • Durbin-Watson test to test independence of residuals.

  • Breusch-Pagan and Goldfeld-Quandt test to test whether the residuals are homoscedastic.

  • Lack of fit test to check whether the fitted model is truly linear.

For each model assumption, we will show the diagnostic techniques in detail.

4.3.1 Normality Diagnosis

The normality of the residuals is an essential assumption for the linear regression model adjustment results to be reliable. We can verify this assumption through the Probability Paper graph and through tests such as Shapiro-Wilk, Anderson-Darling and Kolmogorov-Smirnov. For more details, see Normality Tests in the Inference content.

Example 3.1.1

  • Motivation 1:

Considering the fit of the simple linear model to the example data in “Motivation 1”, let’s make the Probability Paper graph and the Shapiro-Wilk, Anderson-Darling and Kolmogorov-Smirnov tests to test the normality of the residuals.

Solution:

  • Probability Paper

The vector with the residues ordered in ascending order, considering the fit of the linear model, is given by

$$e=(-2,82; -2,66; -2,14; -1,14; -0,82; -0,82; -0,14; -0,14; -0,14; 0,02; 0,34; 0,34; 0,34; 0,34;$$ $$\quad 1,02; 1,02; 1,02; 1,18; 2,18; 3,02).$$

The vector with the values of $\Phi^{-1}(d_i)^\prime s$ is given by

$$\Phi^{-1}(d)=(-1,82; -1,38; -1,12; -0,91; -0,74; -0,58; -0,44; -0,31; -0,19; -0,06; 0,06; 0,19; 0,31;$$ $$\quad 0,44; 0,58; 0,74; 0,91; 1,12; 1,38; 1,82),$$

in which $d_i=(i-0,3)/(n+0,4)$ for $i=1,\dots,n$ and $\Phi^{-1}(d_{(i)})$ is the quantile of the standard normal distribution calculated in $d_{(i)}$. In this example, $n=20$. So, drawing the points $(e_i,\Phi^{-1}(d_i))$, $i=1,\dots,20$, we obtain the Probability Paper graph. If the normality assumption is adequate, we expect linear behavior of the points.

Using the Action software we have the following result:

Figura4.3.1

Figure 4.3.1: Probability Paper Plot for the residuals of the adjusted simple linear model - Motivation 1.

As the points follow the behavior of the straight line (they are not far from it), we have evidence that the errors are normally distributed.

Normality Tests

Regarding Normality Tests, we need to find the values of $F_{n}(e_i)$ and $F(e_i),$ $i=1,\dots,n.$ $F_{n}(e_{(i)})$ represents the empirical accumulated distribution function of the data and is given by the ratio between the position $i$ and the total value of waste, i.e.

$$F_{n}(e_{(i)})=i/n \hbox{(distribuição empírica acumulada)}.$$

$F(e_{(i)})$ represents the accumulated distribution function assumed for the data and its value is obtained from the standard normal distribution table after transforming the data by the relation

$$Z_{(i)}=\dfrac{e_{(i)}-\overline{e}}{s},$$

in which $\overline{e}$ is the arithmetic mean and s is the standard deviation of the residuals. In Table 4.3.1 we present the values of $F_{n}(e_{(i)})$ and $F(e_{(i)})$ for the analyzed waste.

$e$ $F(e)$ $F_n(e)$ $F_n(e)-F(e)$ $F(e)-F_n(e-1)$ $ln(F(e))$ $ln(1-F(e))$
-2,82 0,028 0,05 0,022 0,028 -3,587 -0,028
-2,66 0,035 0,1 0,065 -0,015 -3,342 -0,036
-2,14 0,073 0,15 0,077 -0,027 -2,618 -0,076
-1,14 0,219 0,2 -0,019 0,069 -1,517 -0,248
-0,82 0,289 0,25 -0,039 0,089 -1,242 -0,341
-0,82 0,289 0,3 0,011 0,039 -1,242 -0,341
-0,14 0,462 0,35 -0,112 0,162 -0,772 -0,620
-0,14 0,462 0,4 -0,062 0,112 -0,772 -0,620
-0,14 0,462 0,45 -0,012 0,062 -0,772 -0,620
0,02 0,505 0,5 -0,005 0,055 -0,682 -0,704
0,34 0,591 0,55 -0,041 0,091 -0,525 -0,895
0,34 0,591 0,6 0,009 0,041 -0,525 -0,895
0,34 0,591 0,65 0,059 -0,009 -0,525 -0,895
0,34 0,591 0,7 0,109 -0,059 -0,525 -0,895
1,02 0,756 0,75 -0,006 0,056 -0,280 -1,410
1,02 0,756 0,8 0,044 0,006 -0,280 -1,410
1,02 0,756 0,85 0,094 -0,044 -0,280 -1,410
1,18 0,789 0,9 0,111 -0,061 -0,237 -1,554
2,18 0,931 0,95 0,019 0,031 -0,072 -2,670
3,02 0,980 1 0,020 0,030 -0,020 -3,90

Table 4.3.1: Values ​​for calculating Normality test statistics in the “Motivation1” example.

  • Kolmogorov-Smirnov

The test statistic for the Kolmogorov-Smirnov test is given by

$$D_n=\max(0,11;0,162)=0,162.$$

Considering $\alpha = 0,05$ and $n = 20$, we find from the table of critical values that the critical value in this case is approximately $0,29$. How $Dn = 0,162 < 0,29$, we have no evidence to reject the hypothesis of normality of the residuals.

  • Anderson-Darling

Using the formula $(\star)$ in the Anderson-Darling test on the content of Inference, we have to $$D=\sum_{i=1}^n[(2i-1)\ln(F(e_i))+(2(n-i)+1)\ln(1-F(e_i))]=-408,11.$$

So,

$$\displaystyle A^2=-n-\frac{D}{n}=-20-\frac{(-408,11)}{20}=0,405.$$

To calculate the p-value, we need to find the modified Anderson Darling statistic. Considering μ and σ unknown, we have

$$A_m^2=A^2\times(1+(0,75/n)+(2,25/n^2))=0,405\times(1+(0,75/20)+(2,25/20^2))=0,405\times 1,043=0,422.$$

In this way, we obtain the approximate p-value and analyze the Table with quantiles and values of the Anderson Darling statistic. How $A_m^2=0,422~<~0,56$ we have that p_value is greater than 15%. In R an approximate value of the p-value is found through interpolation.

As p_value is greater than 15%, there is strong evidence from the Anderson-Darling test that the residuals are normally distributed.

  • Shapiro-Wilk

To calculate the Shapiro-Wilk test statistic, we need the values contained in Table 4.3.2, as presented in the Shapiro-Wilk test in the Inference content.

$i$ $n-i+1$ $a$ $e_{n-i+1}$ $e_i$ $a(e_{n-i+1}-e_i)$
1 20 0,4734 3,02 -2,82 2,76
2 19 0,3211 2,18 -2,66 1,55
3 18 0,2565 1,18 -2,14 0,85
4 17 0,2085 1,02 -1,14 0,45
5 16 0,1686 1,02 -0,82 0,31
6 15 0,1334 1,02 -0,82 0,25
7 14 0,1013 0,34 -0,14 0,05
8 13 0,0711 0,34 -0,14 0,03
9 12 0,0422 0,34 -0,14 0,02
10 11 0,014 0,34 0,02

Table 4.3.2: Measurements for calculating the Shapiro-Wilk statistic

The test statistic is given by

$$W=\dfrac{b^2}{\sum\limits_{i=1}^n(e_i-\bar{e})^2},$$

in which

$$b=\sum_{i=1}^{n/2}a_{n-i+1}\times (e_{n-i+1}-e_i).$$

Thus, it follows that

$$W=\dfrac{(6,2839)^2}{41,16}=\dfrac{39,4872}{41,16}=0,959.$$

How $W_{calc}=0,959 > W_{(0,05;20)}=0,905$, in which $W_{(0,05;20)}$ is obtained from the table of critical values, we say that the residuals are normally distributed with a significance level of 5%.

Using the Action software we have the following results:

Statistics P-value
Anderson-Darling 0.4053853 0.3202935
Shapiro-Wilk 0.9594731 0.5333777
Kolmogorov-Smirnov 0.1621102 0.1827284

Table 4.3.3: Normality Tests

  • Motivation 2:

Now considering the data in “Motivation 2”, we check whether the residuals obtained by adjusting the multiple linear regression model follow a normal distribution using the Probability Paper graph and the normality tests, as mentioned above.

  • Probability Paper

For the Probability Paper graph, we must first order the residuals $e_i$, find the values of $\Phi^{-1}(d_i)$ and then present the points on the graph $(e_i,\Phi^{-1}(d_i))$, $i=1,\dots,n.$ If the normality assumption is adequate, we expect linear behavior of the points on the graph. The vector with the ordered residues, for the data in “Motivation 2” is

$$e=(-44,58; -37,09; -30,36; -25,01; -23,23; -19,88; -11,87; 5,34; 15,48; 15,65; 24,56; 30,35;$$

$$37,46; 63,20).$$

The vector with the values of $\Phi^{-1}(d_i)$ is given by

$$\Phi^{-1}(d)=(-1,66;-1,18;-0,89;-0,65;-0,45;-0,26;-0,09; 0,09; 0,26; 0,45; 0,65; 0,89; 1,18; 1,66),$$

in which $d_i=(i-0,3)/(n+0,4)$ for $i=1,\dots,n$ and $\Phi^{-1}(d_{(i)})$ is the quantile of the standard normal distribution calculated at the point $d_{(i)}$.

Using the Action software we have the following result:

Figura4.3.2

Figure 4.3.2: Probability Paper Plot for the residuals of the adjusted simple linear model - Motivation 2.

As the points follow the behavior of the straight line (they are not far from it), we have evidence that the errors are normally distributed.

Normality Tests

Regarding normality tests, we need to obtain the values of $F_{n}(e_{(i)})$ and of $F(e_{(i)})$. The first is calculated by taking the ratio between position i and the total value of residues, in this case $n=14$ (cumulative empirical distribution). The second is found in the standard normal distribution table, considering the data transformation given by the relation

$$Z_{(i)}=\frac{e_{(i)}-\overline{e}}{s}$$

in which $\overline{e}$ is the arithmetic mean and s is the standard deviation of the residuals. We summarize in table 3.1.3 the values ​​used in calculating the normality test statistics.

$e$ $F(e_i)$ $F_n(e)$ $F_n(e_i)-F(e_i)$ $F(e_i)-F_n(e_{i-1})$ $ln(F(e_i))$ $ln(1-F(e_i))$
-44,58 0,0826 0,0714 -0,0112 0,0826 -2,493 -0,086
-37,08 0,1242 0,1428 0,0187 0,0528 -2,086 -0,132
-30,36 0,1723 0,2143 0,0419 0,0295 -1,758 -0,189
-25 0,2181 0,2857 0,0675 0,0038 -1,5224 -0,246
-23,23 0,2348 0,3571 0,1223 -0,0509 -1,449 -0,267
-19,87 0,268 0,4286 0,1605 -0,0891 -1,316 -0,312
-11,87 0,3558 0,5 0,1441 -0,0728 -1,033 -0,439
5,34 0,5660 0,5714 0,0054 0,066 -0,569 -0,835
15,47 0,685 0,6428 -0,0421 0,1136 -0,378 -1,155
15,65 0,6869 0,7142 0,0274 0,0441 -0,376 -1,161
24,55 0,7776 0,7857 0,0081 0,0634 -0,251 -1,503
30,34 0,8275 0,8571 0,0296 0,0418 -0,189 -1,757
37,45 0,8781 0,9286 0,0504 0,021 -0,129 -2,105
63,2 0,9754 1 0,0246 0,0468 -0,0249 -3,705

Table 4.2.4: Values for calculating Normality test statistics

  • Kolmogorov-Smirnov

For the Kolmogorov-Smirnov test, we have that the test statistic is given by

$$D_n=\max(0,1605;0,1136)=0,1605.$$

Considering $\alpha=0,05$ and n = 14, we find from the critical value table that the critical value is approximately 0.34. As Dn = 0.1605 < 0,34, não temos evidências para rejeitar a hipótese de normalidade dos resíduos.

  • Anderson-Darling

Utilizando a fórmula $(\star)$ no teste de Anderson-Darling no conteúdo de Inferência, temos que

$$D=\sum_{i=1}^n[(2i-1)\ln(F(e_i))+(2(n-i)+1)\ln(1-F(e_i))]= -200,3.$$

Assim, segue que $$\displaystyle A^2=-n-\frac{D}{n}=-14-\frac{(-200,3)}{14}=0,308.$$

Para o cálculo do p-valor, precisamos encontrar a estatística de Anderson Darling modificada. Considerando μ e σ desconhecidos, temos que a estatística modificada é dada por

$$A_m^2=A^2\times(1+(0,75/n)+(2,25/n^2))=0,308^2\times(1+(0,75/14)+(2,25/14^2))=0,308\times 1,065=0,328.$$

Novamente, para obter o P-valor aproximado analisamos a Tabela com quantis e valores da estatística de Anderson Darling. Como $A_m^2=0,328~<~0,56$ temos que p_valor é maior do que 15%. No R um valor aproximado do p-valor é obtido fazendo interpolação.

Como p_valor é maior do que 15%, existe forte evidência pelo teste de Anderson-Darling de que os resíduos são normalmente distribuídos.

  • Shapiro Wilk

Para o cálculo da estatística de teste, precisamos dos valores contidos na Tabela 4.2.5.

$i$ $n-i+1$ $a$ $e_{n-i+1}$ $e_i$ $a(e_{n-i+1}-e_i)$
1 14 0,5251 63,201 -44,5841 56,59796
2 13 0,3318 37,4588 -37,0884 24,73476
3 12 0,246 30,3464 -30,3643 14,93483
4 11 0,1802 24,5563 -25,009 8,931667
5 10 0,124 15,6505 -23,2338 4,821653
6 9 0,0727 15,4769 -19,8784 2,57033
7 8 0,024 5,3414 -11,8735 0,413158

Table 4.2.5: Measures for calculating the Shapiro-Wilk statistic of Motivation 2

The Shapiro-Wilk test statistic is given by

$$W=\frac{b^2}{\sum\limits_{i=1}^n(e_i-\bar{e})^2},$$

in which

$$b=\sum_{i=1}^{n/2}a_{n-i+1}\times (e_{n-i+1}-e_i).$$

So, we have to

$$W=\frac{113,0043^2}{13.421,12}=0,9515,$$

How $W_{calc}=0,9515 > W_{(0,05;14)}=0,874$, in which $W_{(0,05;14)}$ is given by the table of critical values, we do not reject the assumption of normality. Therefore, we conclude that at a 5% significance level, the residuals are normally distributed.

Using the Action software we have the following results:

Statistics P-value
Anderson-Darling 0.3076533977 0.5183067119
Shapiro-Wilk 0.9514879996 0.5840384217
Kolmogorov-Smirnov 0.160504667 0.4235051205

Table 4.2.6: Normality Test

4.3.2 Homoscedasticity Diagnosis

Homoscedasticity is the term to designate constant variance of experimental errors $\varepsilon_i$ for different observations. If the homoscedasticity assumption is not valid, we can list some effects on the model adjustment:

  • The standard errors of the estimators, obtained by the Least Squares Method, are incorrect and therefore the statistical inference is not valid.
  • We can no longer say that Least Squares Estimators are the best minimum variance estimators for β, although they may still be unbiased.

It is worth mentioning that the absence of homoscedasticity is called heteroscedasticity. With this, we tested the hypotheses:

$$ \begin{cases} H_0: \sigma^2_1=\sigma^2_2 = … =\sigma^2_n \cr H_1: \hbox{ pelo menos um dos } \sigma_i^{2^\prime} \hbox{s diferente, } \quad i=1,\ldots,n. \end{cases} $$

Given a linear regression model $$y_i = \beta_0 + \beta_1 x_{1,i} + \cdots + \beta_p x_{p,i} + \varepsilon_i, \quad i=1, \cdots , n,$$ the homoscedasticity hypothesis implies that $$Var(\varepsilon \mid x_{1,i}, \cdots , x_{p,i}) = \sigma^2.$$ In this case, the variance of the experimental error is the same for all observations. Throughout this section, we will present the various tests proposed in the literature. When the homoscedasticity assumption is violated, we have

$$Var(\varepsilon \mid x_{1,i}, \cdots , x_{p,i}) = \sigma^2_i, \quad i=1, \cdots , n$$

In this case, the variance of each observation may be different. Visually, this means that if we graph the residuals using the adjusted values, the behavior should not be the same throughout the adjusted values.

4.3.2.1 Graph of Residuals versus Adjusted Values

Plotting residuals versus fitted values (predicted values) is one of the main techniques used to check residual assumptions. In addition to detecting heteroskedasticity, this graph can indicate that there is no linear relationship between the explanatory variables and the response variable through some trend in the points. For example, if the points on the graph form a parabola, it is indicative that quadratic terms are necessary.

To diagnose heteroscedasticity, we try to find some trend in the graph. Therefore, if the points are randomly distributed around 0, without any behavior or trend, we have evidence that the variance of the residuals is homoscedastic. The presence of a “funnel” is an indication of the presence of heteroscedasticity.

Example 3.2.1.1

Considering the example in “Motivation 1”, let’s graph the residuals versus adjusted values.

Using the Action software we have the following result:

Figura4.3.3

Figure 4.3.3: Graph of residuals versus adjusted values (Motivation 1)

Example 3.2.1.2

Considering the example in “Motivation 2”, let’s graph the residuals versus adjusted values.

Using the Action software we have the following result:

Figura4.3.4

Figure 4.3.4: Graph of residuals versus adjusted values (Motivation 2)

4.3.2.2 Breusch-Pagan test

Based on the Lagrange multiplier test, the Breusch-Pagan test is widely used to test the null hypothesis that the error variances are equal (homoscedasticity) versus the alternative hypothesis that the error variances are a multiplicative function of one or more variables, and this variable(s) may or may not belong to the model in question. It is indicated for large samples and when the assumption of normality in errors is assumed.

The test statistic in this case is obtained as follows:

Initially, we fit the linear regression model (simple or multiple) and find the residuals $e=(e_1,\dots,e_n)$ and the adjusted values $\widehat{y}=(\widehat{y_1},\dots,\widehat{y}_n)$. We then consider the squared residuals and standardize them so that the mean of the vector of standardized residuals, which we will denote by u, is 1. This standardization is done by dividing each squared residual by the SQE/n where SQE is the Sum of Squares of the Residuals of the fitted model and n is the number of observations. In this way, we have that each standardized residue is given by

$$u_i=\dfrac{e_i^2}{SQE/n},~~i=1,\dots,n,$$

in which $SQE=\displaystyle\sum\limits_{i=1}^{n}{e_i^2}.$

Finally, we regress between $u=(u_1,…,u_n)$ (response variable) and the vector $\widehat{y}$ (explanatory variable) and we obtain the statistics $\chi^2_{BP}$ calculating the Sum of Squares of the Regression of u on $\widehat{y}$ and dividing the value found by 2. The statistic used in the test is the $\chi_{B P}^{2}$ studentized which is given by

$$\chi_{B P \text { studentizada}}^{2}=\frac{\chi_{B P}^{2}}{\lambda}$$

in which $\lambda=\frac{\operatorname{Var}\left(\varepsilon^{2}\right)}{2 \operatorname{Var}(\varepsilon)^{2}}$.

Under the null hypothesis, this statistic has a chi-square distribution with 1 degree of freedom. Briefly, if there is no heteroskedasticity, it is expected that the squared residuals will not increase or decrease with the increase in the predicted value, $\widehat{y}$ and thus, the test statistic should be insignificant.

Example 3.2.2.1

Considering the example in “Motivation 1”, let’s perform the Breusch Pagan test to test the homoscedasticity of the residuals.

The SQE (Sum of Squares of Error) of the regression of the variable Hardness (response) on the explanatory variable Temperature is 41.16. Furthermore, we have that n=20. Thus, dividing the squared residuals by $\dfrac{41,16}{20}=2,058$, we find the standardized residuals.

The SQR (Sum of Squares Regression) obtained from the regression of $u$ (standardized residual vector) on the adjusted value of the regression of the Hardness variable on the Temperature variable, $\widehat{y}$, is given by 0.151. Therefore, the value of the test statistic is given by $\chi^2_{BP}=\dfrac{0,151}{2}=0,0784$.

The p_value for this example, that is, $P(\chi^2> 0,0784)$ is $0,7794$. Considering a significance level of 5%, we do not reject the hypothesis of homoscedasticity of errors.

Using the Action software we have the following results:

Statistics GL P-value
0.0784452527 1 0.7794155173

Table 4.3.7: Homoscedasticity Test - Breusch Pagan (Motivation 1)

Example 3.2.2.2

In the example in “Motivation 2”, we will calculate the Breusch Pagan statistic to test the homoscedasticity of the residuals.

The SQE (Sum of Squares of Error) of the regression of the variable Gain (response) on the explanatory variables Time and Dose_of_ions is 13.421. Furthermore, we have that n=14. Thus, dividing the squared residuals by $\dfrac{13.421}{14}=958,643$, we find the standardized residuals.

The SQR (Sum of Squares Regression) obtained from the regression of $u$ (standardized residual vector) on the adjusted value of the regression of the Gain variable on the Time and Ion_Dose variables, $\widehat{y}$, is given by 0.866. Therefore, the value of the test statistic is given by $\chi^2_{BP studentizada}=0,7993$.

The p_value for this example, that is, $P(\chi^2 > 0,7993)$ is 0.3713. Considering a significance level of 5%, we do not reject the hypothesis of homoscedasticity of errors.

Using the Action software we have the following results:

Statistics GL P-value
0.7992707163 1 0.3713115028

Table 4.3.8: Homoscedasticity Test - Breusch Pagan (Motivation 2)

4.3.2.3 Goldfeld-Quandt test

The Goldfeld-Quandt test is also used to test the homoscedasticity of residuals. Among the limitations of this test is the requirement that the sample be relatively large.

The test initially consists of ordering the observations according to the explanatory variable believed to be responsible for heteroscedasticity. After this, the ordered sample is divided into 3 parts in such a way that the middle part has approximately 20% of the data and that parts 1 and 3 have a similar amount of data. Then, a regression model is adjusted with the data from part 1 (containing the lowest values ​​of the explanatory variable used in the ordination) and another regression model with the data from part 3 (containing the highest values ​​of the explanatory variable used in the ordination). Finally, the hypothesis that the error variances in both regressions are equal is tested against the hypothesis that the error variance in part 3 is greater than the error variance in part 1, using the F test.

The test statistic in this case is given by

$$F_{GQ}=\frac{SQE^b/(n_{3}-(p+1))}{SQE^a/(n_{1}-(p+1))},$$

in which $SQE^a$ and $SQE^b$ are the sums of squares of the regression residuals for the lower group (part 1) and the upper group (part 3), respectively, $n_{1}$ is the number of observations from part 1 and $n_{3}$ is the number of observations from part 3. We call d the number of omitted observations (part 2). This statistic has distribution $F_{(n_{3}-(p+1),n_{1}-(p+1))}$. In this way, considering a level of significance $\alpha=0,05$, we reject the null hypothesis, that is, the hypothesis that the variances are equal if $F_{GQ} > F_{\frac{\alpha}{2}}$.

Example 3.2.3.1

Considering the example in “Motivation 1”, let’s perform the Goldfeld-Quandt test to test the homoscedasticity of the residuals.

We only have one explanatory variable, Temperature $(p=1)$. This way, we will order the data in relation to this variable. How $n=20$, we discard $d=4$ observations, i.e. 20% of the data. In this way, part 1 has $n_1=8$ observations and part 3 has $n_3=8$ observations. The sum of squares of the residuals in the upper group (part 3) is 13.2 while the sum of squares of the residuals in the lower group (part 1) is 7.867. Therefore, the test statistic is

$$F_{GQ}=\frac{13,2/(8-2)}{7,867/(8-2)}=1,678.$$

$$\text{p-valor} = 2\min{\mathbb{P}[F \ > \ 1,678 | H_0];\mathbb{P}[F \ < \ 1,678 | H_0]}=0,545208844.$$

The p-value of the test is 0.5452. Considering a 95% confidence level, we do not reject the hypothesis of homoscedasticity of the residuals.

Using the Action software we have the following results:

Variable Statistics GL1 GL2 P-value
Temperature 1.67796610169501 6 6 0.54520884

Table 4.3.9: Homoscedasticity Test - Goldfeld Quandt (Motivation 1)

Example 3.2.3.2

In the example in “Motivation 2”, we will calculate the Goldfeld-Quandt statistic to test the homoscedasticity of the residuals.

In this example we have two explanatory variables $(p=2)$. In this way, we applied the Goldfeld-Quandt test, initially ordering the data in relation to the Time variable and subsequently ordering it in relation to the Ion_Dose variable. In this way, we are able to detect which of the two explanatory variables is responsible for heteroscedasticity, if any.

In both cases (ordering by Time or Ion_Dose), we discarded approximately 20% of the observations, that is, 4 observations. This way, we have that the number of remaining observations is 11. When the number of observations is odd, we always leave part 3 with one more observation than part 1. This way, we have $n_1=5$ and $n_3=6$.

Considering the Time variable in ordering the data, we have that the sum of squares of the residuals of the lower group (part 1) is 780.126 while that of the upper group (part 3) is 849.822. Therefore, the test statistic is

$$F_{GQ}=\frac{849,822/(6-3)}{780,126/(5-3)}=0,726.$$

$$\text{p-valor} = 2\min{\mathbb{P}[F \ > \ 0,726 | H_0];\mathbb{P}[F \ < \ 0,726 | H_0]}=0,752941559.$$

The p-value of the test is 0.753. Therefore, at a confidence level of 95%, we do not reject the hypothesis of homoscedasticity of the residues of Motivation 2.

Regarding the ordering of the data by the variable Dose_de_ions, we have that the sum of squares of the residues of the lower group (part 1) is 2,592 while that of the upper group (part 3) is 8,837.965. Therefore, the test statistic is

$$F_{GQ}=\frac{8.837,965/(6-3)}{2.592/(5-3)}=2,286.$$

$$\text{p-valor} = 2\min{\mathbb{P}[F \ > \ 2,286 | H_0];\mathbb{P}[F \ < \ 2,286 | H_0]}=0,637566748.$$

The p-value of the test is 0.638. Therefore, at a 95% confidence level, we also do not reject the hypothesis of homoscedasticity of the residues of Motivation 2.

Using the Action software we have the following results:

Variable Statistics GL1 GL2 P-value
Ion dose 2.27313910924677 3 2 6401498344179
Time 0.72622614253487 3 2 0.752941558959312

Table 4.3.9: Homoscedasticity Test - Goldfeld Quandt (Motivation 1)

4.3.3 Independence Diagnosis

To check whether the residuals are independent, we can use graphical techniques and tests. Next, we have the diagnosis of independence in these two ways.

4.3.3.1 Waste Chart versus Collection Order

A graphical analysis to verify the hypothesis of independence of residues can be done using a graph of residues versus the order of data collection. If, when evaluating the graph, we notice a trend in the points, that is, if the points have a behavior that is repeated at a certain point in the graph, we have evidence of dependence on the residuals.

Example 3.3.1.1

For the example data in “Motivation 1”, plot the residuals of the fitted model versus the order of collection and evaluate the assumption of independence of the residuals.

Using the Action software we have the following result:

Figura 4.3.5

Figure 4.3.5: Waste graph versus collection order considering the data from the example in Motivation 1.

Analyzing the graph we see that the points do not seem to have a trend and therefore we have evidence of independence of the errors.

Example 3.3.1.2

Considering the transformed data from the example in “Motivation 2”, graph the residuals of the adjusted model versus the order of collection and evaluate the assumption of independence of the residuals.

Using the Action software we have the following result:

Figura 4.3.6

Figure 4.3.6: Waste graph versus collection order considering the data from the example in Motivation 2.

Again, we see from the graph that the points do not seem to have a trend and therefore we have evidence of independence of the errors.

4.3.3.2 Durbin-Watson test

The Durbin-Watson test is used to detect the presence of autocorrelation (dependence) in the residuals of a regression analysis. This test is based on the assumption that errors in the regression model are generated by a first-order autoregressive process, according to $$\varepsilon_i=\rho\varepsilon_{i-1}+a_i,$$

in which $\varepsilon_i$ is the model error term in the ith observation, $a_i\overset{iid}{\sim}N(0,\sigma_{a}^2)$ and $\rho$ ($|\rho|< 1$) is the autocorrelation parameter. We tested the presence of autocorrelation using the hypotheses

$$\begin{cases} H_{0}: \rho=0. \cr H_{1}:\rho \neq 0. \end{cases}.$$

Being $e_i$ the residue associated with the ith observation, we have that the Durbin-Watson test statistic is given by

$$dw=\frac{\sum\limits_{i=2}^n(e_i-e_{i-1})^2}{\sum\limits_{i=1}^{n}e_i^2},$$

where 0 ≤ $dw$ ≤ 4. The distribution of $dw$ depends on the matrix $X$. However, we can make the decision by comparing the value of $dw$ with critical values $dL$ and $dU$ from the Durbin-Watson Table (Table 4.3.10). So,

if $0$ ≤ $dw$ < $dL$ então rejeitamos $H_0$ (dependência);

  • se $dL$ ≤ $dw$ ≤ $dU$ então o teste é inconclusivo;

  • se $dU$ < $dw$ < $4-dU$ então não rejeitamos $H_0$ (independência);

  • se $4-dU$ ≤ $dw$ ≤ $4-dL$ então o teste é inconclusivo;

  • se $4-dL$ < $dw$ ≤ $4$ então rejeitamos $H_0$ (dependência).

Quando $0~\leq~dw~<~d_L$ temos evidência de uma correlação positiva. Já quando $4-d_L ~<~dw~\leq~4$, a correlação é negativa. No caso em que não rejeitamos $H_0$, temos que não existe autocorrelação, ou seja, os resíduos são independentes. Podemos também tomar a decisão pelo p-valor.

Os valores críticos tabelados apresentados na Tabela 4.3.10 são geralmente utilizados para testar $\rho~=~0$ versus $\rho~>~0$. Desta forma, se para um determinado $\alpha$ utilizarmos os valores da Tabela 4.3.10 para testar $\rho~=~0$ versus $\rho~\neq~0$, o erro tipo I do teste em questão será $2\alpha$.

Significance level 1 1 2 2 3 3 4 4 5 5
$n$ $d_L$ $d_U$ $d_L$ $d_U$ $d_L$ $d_U$ $d_L$ $d_U$ $d_L$ $d_U$
0,01 0,81 1,07 0,7 1,25 0,59 1,46 0,49 1,7 0,39 1,96
15 0,025 0,95 1,23 0,83 1,4 0,71 1,61 0,59 1,84 0,48 2,09
0,05 1,08 1,36 0,95 1,54 0,82 1,75 0,69 1,97 0,56 2,21
0,01 0,95 1,15 0,86 1,27 0,77 1,41 0,63 1,57 0,6 1,74
20 0,025 1,08 1,28 0,99 1,41 0,89 1,55 0,79 1,7 0,7 1,87
0,05 1,2 1,41 1,1 1,54 1 1,68 0,9 1,83 0,79 1,99
0,01 1,05 1,21 0,98 1,3 0,9 1,41 0,83 1,52 0,75 1,65
25 0,025 1,13 1,34 1,1 1,43 1,02 1,54 0,94 1,65 0,86 1,77
0,05 1,2 1,45 1,21 1,55 1,12 1,66 1,04 1,77 0,95 1,89
0,01 1,13 1,26 1,07 1,34 1,01 1,42 0,94 1,51 0,88 1,61
30 0,025 1,25 1,38 1,18 1,46 1,12 1,54 1,05 1,63 0,98 1,73
0,05 1,35 1,49 1,28 1,57 1,21 1,65 1,14 1,74 1,07 1,83
0,01 1,25 1,34 1,2 1,4 1,15 1,46 1,1 1,52 1,05 1,58
40 0,025 1,35 1,45 1,3 1,51 1,25 1,57 1,2 1,63 1,15 1,69
0,05 1,44 1,54 1,39 1,6 1,34 1,66 1,29 1,72 1,23 1,79
0,01 1,32 1,4 1,28 1,45 1,24 1,49 1,2 1,54 1,16 1,59
50 0,025 1,42 1,5 1,38 1,54 1,34 1,59 1,3 1,64 1,26 1,69
0,05 1,5 1,59 1,46 1,63 1,42 1,67 1,38 1,72 1,34 1,7

Table 4.3.10: Critical values of the Durbin-Watson test.

Example 3.3.2.1

Using the Durbin Watson test, check whether the residuals of the adjusted model in the example in “Motivation 1” are independent.

To calculate the Durbin Watson statistic, we need the values ​​from Table 4.3.11.

$e$ $e_{t}-e_{t-1}$ ${(e_{t}-e_{t-1})}^2$ $e_t^2$
-0,14 - - 0,0196
-0,14 0 0 0,0196
-0,14 0 0 0,0196
-1,14 -1 1 1,2996
-2,14 -1 1 4,5796
3,02 5,16 26,62 9,1204
1,02 -2 4 1,0404
0,02 -1 1 0,0004
1,02 1 1 1,0404
1,02 0 0 1,0404
1,18 0,16 0,0256 1,3924
-2,82 -4 16 7,9524
-0,82 2 4 0,6724
2,18 3 9 4,7524
-0,82 -3 9 0,6724
0,34 1,16 1,34 0,1156
0,34 0 0 0,1156
0,34 0 0 0,1156
-2,66 -3 9 7,0756
0,34 3 9 0,1156
Sum: 91,99 41,16

Table 4.3.11: Measurements for calculating the Durbin-Watson statistic.

The test statistic is given by $$dw=\frac{91,99}{41,16}=2,235.$$

To find the critical values $d_L$ and $d_U$ in Table 4.3.10, we must consider $\alpha=\alpha^*/2$, in which $\alpha^*$ is the significance level of the test. For $\alpha^*=0,05$ we have to $\alpha=0,025$. So, with $n=20$ and $k=1$ explanatory variable, we have $d_L=1,08$ and $d_U=1,28$. How $d_U = 1,28<2,235\leq4-d_U=2,72$, we do not reject $H_0$ and therefore, we can state that with a 95% confidence level, the residuals are independent.

Using the Action software we have the following results:

Statistics P-value
2.2351 0.7686

Table 4.3.12: Independence Test - Durbin-Watson (Motivation 1)

Example 3.3.2.2

Analogously to example 3.3.2.1, we will test using the Durbin Watson test whether the residuals of the adjusted model in the example in “Motivation 2” are independent.

To calculate the statistics, we need the values ​​from Table 4.3.13.

$e$ $e_t-e_{t-1}$ ${(e_t-e_{t-1})}^2$ $e_t^2$
30,3464 - - 920,9
15,4769 -14,8695 221,1 239,53
-30,3643 -45,8412 2101,42 921,99
-23,2338 7,1305 50,84 539,81
5,3414 28,5752 816,54 28,53
-11,8735 -17,2149 296,35 140,98
63,201 75,0744 5636,17 3994,36
-25,009 -88,2099 7780,99 625,45
-19,8784 5,1305 26,32 395,15
-37,0884 -17,2099 296,18 1375,55
-44,5841 -7,4958 56,19 1987,75
24,5563 69,1405 4780,4 603,01
37,4588 12,9025 166,48 1403,16
15,6505 -21,8083 475,6 244,94
Sum 22704,58 13421,11

Table 4.3.13: Measurements for calculating the Durbin-Watson statistic

The test statistic is given by $$dw=\frac{22704,58}{13421,11}=1,6917.$$

Analyzing Table 4.3.10 we see that there are no critical values $d_U$ and $d_L$ for $n=14$. In this way, we consider approximate values ​​for n=15. With a level of significance $\alpha^{*}=0,05$ $(\alpha=0,025)$ and $k=2$ explanatory variables, we have $d_L~\approx~0,83$ and $d_U~\approx~1,40$. How $d_L~\approx~1,40~<~1,69~<~2,60~\approx4-d_L$, with a significance level of 5%, we do not reject $H_0$. Thus, we say that the residues are independent.

Using the Action software we have the following results:

Statistics P-value
1.691706 0.709529

Table 4.3.14: Independence Test - Durbin-Watson (Motivation 2)

4.3.4 Influential points and extreme values

The extreme value or outlier is an observation with a “high” residual. In this case, we have an observation whose dependent variable is unexpected given the value of the explanatory variable. On the other hand, we say that an observation is a leverage point (or high leverage) if the explanatory variable is extreme. When we have only one explanatory variable, an extreme value means a low and/or high value for the explanatory variable. If we have a vector of explanatory variables, an extreme point means a combination of unexpected values ​​for the explanatory variables. Therefore, we will use the residual to detect extreme values ​​in the response and the leverage point to detect extreme or unexpected values ​​for the explanatory variable.

An influential point is an observation that can influence any part of the regression analysis, such as predicting a response, the slope, or the result of hypothesis testing. The inclusion or not of this observation in the analysis influences some part of the regression analysis. Extreme values ​​and leverage points have the potential to be influential, but we have to investigate to assess how influential they are. If an extreme value is influential, it interferes with the adjusted regression function (whether or not the point is included substantially modifies the adjusted values). But an observation can be considered an extreme value and not be an influential point. Likewise, we may have points that influence the regression analysis but are not extreme values ​​or leverage points.

4.3.4.1 Leverage point

The location of the points in the space of the explanatory variables is important for determining properties of the regression model. Leverage points or extreme values in the explanatory variable ($X$) are detected using the hat matrix $H$. The hat matrix is given by

$$H=X(X^\prime X)X^\prime,$$

in which $X$ is the matrix of explanatory variables or the planning matrix. We know that the hat matrix $H$ determines the variances and covariances of the estimated response $\hat{y}$ and waste $e$,

$$Var(\hat{y})=\sigma^2H\quad \text{e} \quad Var(e)=\sigma^2(I-H).$$

We denote by $h_{ii}$ is the ith element of the main diagonal of the hat matrix $H$, which is called the leverage point of the observation $i$. This element can be interpreted as the lever exercised by the ith observation $y_i$ in the expected response $\hat{y}_i$. The leverage point $h_{ii}$ can be calculated in the form

$$h_{ii}=x_i^{^\prime }(X^\prime X)^{-1}x_i,$$

in which $x_i^\prime $ is the ith row of the matrix $X$. The diagonal of the hat matrix $H$ is a standardized measure of the distance from the ith observation to the center of the space defined by the explanatory variables. Therefore, high value for $h_{ii}$ means that the point is distant from the other observations in relation to the explanatory variables.

How $\sum_{i=1}^nh_{ii}=posto(X)=p+1$, the average of $h_{ii}$ is $(p+1)/n$. It is recommended to highlight observations for which $h_{ii}> 2(p+1)/n$. We can also identify high leverage points through the box-plot of the $h_{ii}$. It is important to highlight that not every observation with $h_{ii}$ high is influential in regression analysis. Note that the diagonal of the hat matrix evaluates the location of the observation in the space of explanatory variables. As a consequence, we may have observations with a high leverage point, but they have no influence on the parameter estimates. Therefore, it is interesting to evaluate the leverage points together with the standardized or studentized residuals.

Example 3.4.1.1

In the example of “Motivation 1”, we will calculate the values of $h_{ii}$ to check whether any observation is an extreme value in X.

For the first individual, we have $x_1^{^\prime }=[1~~220]$, where the first value refers to the intercept and the second is the value of the individual’s observed temperature.

The matrix $(X^\prime X)^{-1}$ is:

$$(X^\prime X)^{-1}~= \begin{bmatrix} 82,86 \quad -0,36 \cr -0,36 \quad 0,0016 \end{bmatrix} $$

With this,

$$h_{11}=[1 \quad 220] \begin{bmatrix} 82,86 \quad -0,36 \cr -0,36 \quad 0,0016 \cr \end{bmatrix} \begin{bmatrix} 1 \cr 220 \end{bmatrix} =0,14.$$

For the remaining observations, we calculated the values of $h_{ii}$ in a similar way and we obtain the following values:

$h_{ii}$ values
$h_1$ 0,14
$h_2$ 0,14
$h_3$ 0,14
$h_4$ 0,14
$h_5$ 0,14
$h_6$ 0,06
$h_7$ 0,06
$h_8$ 0,06
$h_9$ 0,06
$h_{10}$ 0,06
$h_{11}$ 0,06
$h_{12}$ 0,06
$h_{13}$ 0,06
$h_{14}$ 0,06
$h_{15}$ 0,06
$h_{16}$ 0,14
$h_{17}$ 0,14
$h_{18}$ 0,14
$h_{19}$ 0,14
$h_{20}$ 0,14

Table 4.3.15: Values of the main diagonal of the H matrix of Motivation 1.

Using the Action software we have the following result:

Figura4.3.7

Figure 4.3.7: Graph of values of $h_{ii}$ considering the data from the example in Motivation 1.

We observed from Table 4.3.15 and Figure 4.3.7 that none $h_{ii}$ is greater than $2(p+1)/n=2(2)/20= 0,2$. Therefore, we have that no observation is considered an outlier in $X$.

Example 3.4.1.2

For the example in “Motivation 2” we will calculate the main diagonal of the matrix H ($h_{ii}$) to check whether any observation is an outlier in X. We consider the transformed data.

For the first individual, we have $x_1^\prime=[1~~-1~~-1]$, where the first value refers to the intercept, the second refers to time and the third refers to the ion dose. Furthermore,

$$(X^\prime X)^{-1}~= \begin{bmatrix} 0,0720 \quad -0,0019 \quad 0,0091 \cr -0,0019 \quad 0,1660 \quad 0,0004 \cr 0,0091 \quad 0,004 \quad 0,1429 \end{bmatrix} $$

So,

$$h_{11}=[1 \quad -1 \quad -1] \begin{bmatrix} 0,0720 \quad -0,0019 \quad 0,0091 \cr -0,0019 \quad 0,1660 \quad 0,0004 \cr 0,0091 \quad 0,004 \quad 0,1429 \end{bmatrix} \begin{bmatrix} 1 \cr -1 \cr -1 \end{bmatrix} =0,367$$

Calculating the $h_{ii}$ for the other observations we obtain the following values:

$h_{ii}$ values
$h_1$ 0,36744
$h_2$ 0,35801
$h_3$ 0,316927
$h_4$ 0,310215
$h_5$ 0,092191
$h_6$ 0,133456
$h_7$ 0,147617
$h_8$ 0,242964
$h_9$ 0,234893
$h_{10}$ 0,19677
$h_{11}$ 0,216595
$h_{12}$ 0,072974
$h_{13}$ 0,233037
$h_{14}$ 0,07691

Table 4.3.16: Values of the main diagonal of matrix H.

Using the Action software we have the following result:

Figura4.3.8

Figure 4.3.8: Graph of values of $h_{ii}$ considering the data from the example in Motivation 2.

We observed from Table 4.3.16 and Figure 4.3.8 that none $h_{ii}$ is greater than $2(p+1)/n=2(3)/14=0,428$. Therefore, we have that no observation is considered an outlier in $X$.

4.3.4.2 Extreme values in the response: high residuals

In regression analysis, the observed response in some cases may not correspond to the model fitted to the data, in this case, we say that this response is an outlier or extreme value. In simple linear regression, the scatterplot can show us which observations do not match the fitted model. However, when dealing with multiple regression models, we must perform a more careful analysis. Waste is defined as $e_i=Y_i-\hat{Y}_i$, which corresponds to the difference between the observed value and the value adjusted by the model. However, for better detection of outliers in Y, several “standardized” ways have been proposed.

4.3.4.2.1 Standardized Waste

The normalized residue, $d_i$, corresponds to the residual divided by the estimated standard deviation of the residuals, $\sqrt{QME}$. $$d_i=\frac{e_i}{\sqrt{QME}}.$$

If the errors are normally distributed, then approximately 95% of the residuals are normalized $(d_i)$ must be in the range of (-2,2). Residuals outside this range may indicate the presence of outliers.

4.3.4.2.2 Standardized Waste

There are numerous ways to express the residue vector “e” that will be useful to us. $$e=Y-\hat{Y}=Y-X\hat{\beta}=Y - HY=(I-H)Y.$$

The covariance matrix of the residuals is,

$$Cov[e]=Cov[(I-H)Y]=(I-H)Var(Y)(I-H)^\prime$$

$$=\sigma^2(I-H)(I-H)^\prime$$

$$=\sigma^2(I-H),$$

in which $H=X(X^\prime X)^{-1} X^\prime$ is the hat matrix and $X$ the model matrix.

Thus, we define the standardized residuals by

$$r_i =\dfrac{e_i}{\sqrt{QME(1-h_{ii})}}, \qquad \qquad i=1,2,\ldots,n,$$

with $\hat{\sigma}^2=QME$ and $h_{ii}$ the $i$-th element of the hat array $H$.

Standardized residuals have constant variances $Var(r_i)=1$ which consequently makes the search for outliers, which are observations distant from the others, very practical. In general, observations with a standardized residual outside the range $-3\leq r_i \leq 3$ should be considered outliers.

4.3.4.2.3 Studentized Residue

One of the most used tests to detect outliers is the mean change test. Suppose the $i$-th answer is a candidate for outlier. For all other answers we assume that $\mathbb{E} [Y \mid X=x_j] = x_j^\prime \beta$, but in case $i$ the average function is given by $\mathbb{E} [Y \mid X=x_i] = x_i^\prime \beta + \delta$. The expected response to the case $i$ is modified by the parameter $\delta$. So, we can perform the test $H_0 : \delta = 0$ versus $H_1 : \delta \ne 0$ to check if the $i$-th response is an outlier. We assume that the variance is constant, that is, $Var(Y \mid X) = \sigma^2$.

Responses with high residual values are candidates for outliers, however, not every observation with a high residual is an outlier. High residuals must occur according to the probability distribution of the data (normal). Furthermore, not every outlier is bad, as the outlier is detected depending on the fitted model, which may not be suitable for the data.

Suppose the observation $i$ be suspected of being an outlier. To verify this suspicion, we proceed as follows:

  1. We take the observation $i$ of the data, leaving the $n-1$ remaining observations;

  2. With the reduced data, we estimate the parameters $\beta$ and $\sigma^2$. We denote the estimates by $\beta_{(i)}$ and $\sigma_{(i)}$ to show that we removed the observation $i$ of the dataset. In this case, the estimator for $\sigma^2_{(i)}$ has $n-1-p-1$ degrees of freedom, for the model with the intercept. If we denote by $p^\prime$ the number of rows in the matrix $X$, we obtain that $p^\prime = p+1$ in the case with intercept and $p^\prime = p$ in the case without the intercept. In this case, we have to $\hat{\sigma}^2_{(i)}$ has $n-p^{\prime} -1$ degrees of freedom.

  3. For data without observation $i$, we calculate the adjusted value $\hat{Y} _{i(i)} = x_i^\prime \beta_{(i)}$. Since the $i$-th observation was not used to estimate the parameters $\beta_{(i)}$ we conclude that $Y_i$ and $\hat{Y} _{i(i)}$ are independent. As a consequence, we obtain that

$$Var [Y_i - \hat{Y} _{i(i)}] = \sigma^2 + \sigma^2 x_i^\prime (X_{(i)}^\prime X_{(i)})^{-1} x_i,$$

in which $X_{(i)}$ It’s the matrix $X$ without the line $i$. The variance is estimated by substituting $\sigma^2$ by $\hat{\sigma}^2_{(i)}$ in the expression above.

  1. We know that $\mathbb{E} [Y_i - \hat{Y}_{i(i)}] = \delta$ which is zero under $H_0$ and non-zero under $H_1$. Assuming normal distribution for the residuals, we have that under $H_0: \delta = 0$, the test statistic

$$ t_i = \frac{Y_i - \hat{Y} _{i(i)}}{\hat{\sigma}\sqrt{1+x_i^\prime(X_{(i)}^\prime X_{(i)})^{-1} x_{i}}},$$

has distribution $t$-Student with $n-p^\prime -1$ degrees of freedom. This statistic can be written in the form

$$ t_i = r_i \sqrt{\frac{n-p^\prime -1}{n-p^\prime -r_{i}^2}} = \frac{e_i}{\hat{\sigma}_{(i)} \sqrt{1-h_{ii}}},$$

in which $e_i$ is the residue and $r_i$ the standardized residue.

Next, we will show that the above formula is valid. Suppose the model matrix $X$ have linearly independent columns. We denote by $X_{(i)}$ the model matrix without the line $i$. We know that

$$ (X_{(i)}^\prime X_{(i)})^{-1} = (X^{\prime} X)^{-1} - \frac{(X^\prime X)^{-1} x_{i}^\prime x_i (X^\prime X)^{-1}}{1-h_{ii}}.$$

This formula has been known since Gauss in 1821 and has a long history of applications in statistics. From this formula, we have

$$\hat{\beta} _{(i)} = \hat{\beta} - \frac{(X^\prime X)^{-1} x_{i}^\prime e_i}{1-h_{ii}}.$$

Thus, an estimate of the variance is given by

$$ \hat{\sigma}^2_{(i)} = \hat{\sigma}^2 \left( \frac{n-p^\prime -1}{n - p^\prime - r_i^2}\right)^{-1},$$

which leads us to the formula for the studentized residue $t_i$. Note that the standardized residue $r_i$ and the studentized residue $t_i$ carry the same information. Thus, when we consider that the degree of freedom $n - p^\prime -1$ is high, we know that $t_i$ behaves approximately like the normal distribution and therefore, $\mid t_i \mid \geq 3$ is considered an extreme observation (outlier).

Example 3.4.2.1

For the data in “Motivation 1” we will calculate the studentized and standardized residuals.

Solution: As we saw in “Estimation of Linear Model Parameters”, the QME of the example in motivation 1 is calculated in “Example 1.2.2” and is given by 2.286. The diagonal of matrix H was calculated in the “Diagnosis of Outliers in X”. Thus, the waste is:

Waste Studentized Waste Standardized Waste
-0.14 -0.097 -0.0998
-0.14 -0.097 -0.0998
-0.14 -0.097 -0.0998
-1.14 -0.8049 -0.8129
-2.14 -1.5894 -1.526
3.02 2.2898 2.0599
1.02 0.6854 0.6957
0.02 0.0133 0.0136
1.02 0.6854 0.6957
1.02 0.6854 0.6957
1.18 0.7966 0.8049
-2.82 -2.0972 -1.9235
-0.82 -0.5483 -0.5593
2.18 1.5429 1.4869
-0.82 -0.5483 -0.5593
0.34 0.236 0.2425
0.34 0.236 0.2425
0.34 0.236 0.2425

Table 4.3.17: Residues of Motivation 1.

Using the Action software we have the following results:

Figura4.3.9

Figure 4.3.9: Standardized and Studentized Residuals vs Adjusted Values (Motivation 1)

Example 3.4.2.2

We will again use the example of “Motivation 2” to make the standardized and studentized residuals.

Solution: The QME in this case was calculated in “Example 2.3.1” and is given by $QME=1.220,1$. Furthermore, the matrix H referring to the data set is given by

$$ H = \begin{bmatrix} \mathbf{0,37} & 0,03 & 0,14 & -0,19 & 0,13 & 0,16 & -0,03 & 0,26 & -0,08 & 0,20 & -0,06 & 0,09 & -0,07 & 0,06 \cr 0,03 & \mathbf{0,36} & -0,19 & 0,14 & 0,12 & 0,16 & -0,03 & -0,08 & 0,25 & 0,19 & -0,07 & 0,08 & -0,07 & 0,11 \cr 0,14 & -0,19 & \mathbf{0,32} & -0,02 & 0,03 & 0,01 & 0,15 & 0,23 & -0,11 & -0,02 & 0,18 & 0,06 & 0,18 & 0,04 \cr -0,19 & 0,14 & -0,02 & \mathbf{0,31} & 0,03 & 0,00 & 0,15 & -0,11 & 0,22 & -0,03 & 0,18 & 0,06 & 0,18 & 0,09 \cr 0,13 & 0,12 & 0,03 & 0,09 & \mathbf{0,09} & 0,11 & 0,03 & 0,08 & 0,08 & 0,12 & 0,02 & 0,08 & 0,01 & 0,08 \cr 0,16 & 0,16 & 0,01 & 0,00 & 0,11 & \mathbf{0,13} & 0,00 & 0,08 & 0,08 & 0,16 & -0,02 & 0,08 & -0,03 & 0,08 \cr -0,03 & -0,03 & 0,15 & 0,15 & 0,03 & 0,00 & \mathbf{0,15} & 0,06 & 0,06 & -0,03 & 0,18 & 0,06 & 0,18 & 0,06 \cr 0,26 & -0,08 & 0,23 & -0,11 & 0,08 & 0,08 & 0,06 & \mathbf{0,24} & -0,09 & 0,09 & 0,06 & 0,08 & 0,06 & 0,05 \cr -0,08 & 0,25 & -0,11 & 0,22 & 0,08 & 0,08 & 0,06 & -0,09 & \mathbf{0,24} & 0,08 & 0,06 & 0,07 & 0,05 & 0,10 \cr 0,20 & 0,19 & -0,02 & -0,03 & 0,12 & 0,16 & -0,03 & 0,09 & 0,08 & \mathbf{0,20} & -0,06 & 0,09 & -0,07 & 0,09 \cr -0,06 & -0,07 & 0,18 & 0,18 & 0,02 & -0,02 & 0,18 & 0,06 & 0,06 & -0,06 & \mathbf{0,22} & 0,06 & 0,23 & 0,06 \cr 0,09 & 0,08 & 0,06 & 0,06 & 0,08 & 0,08 & 0,06 & 0,08 & 0,07 & 0,09 & 0,06 & \mathbf{0,07} & 0,06 & 0,07 \cr -0,07 & -0,07 & 0,18 & 0,18 & 0,01 & -0,03 & 0,18 & 0,06 & 0,05 & -0,07 & 0,23 & 0,06 & \mathbf{0,23} & 0,06 \cr 0,06 & 0,11 & 0,04 & 0,09 & 0,08 & 0,08 & 0,06 & 0,05 & 0,10 & 0,09 & 0,06 & 0,07 & 0,06 & \mathbf{0,08} \end{bmatrix} $$

In this way, the waste is:

Waste Studentized Waste Standardized Waste
30.3464 1.103 1.0923
15.4769 0.5347 0.553
-30.3643 -1.0574 -1.0518
-23.2338 -0.7869 -0.8009
5.3414 0.1532 0.1605
-11.8735 -0.3503 -0.3652
63.201 2.3162 1.9598
-25.009 -0.8099 -0.8229
-19.8784 -0.6326 -0.6506
-37.0883 -1.2094 -1.1847
-44.5841 -1.5269 -1.4421
24.5563 0.7137 0.7302
37.4588 1.2563 1.2245
15.6505 0.4491 0.4663

Table 4.3.18: Residues of Motivation 2.

Using the Action software we have the following results:

Figura4.3.10

Figure 4.3.10: Standardized and Studentized Residuals vs Adjusted Values of Motivation 2

Note t-Value P-value Bonferroni P-value
7 2.3162 0.0431 0.6027

Table 4.3.19: Outliers (atypical points) of Motivation 2

4.3.4.3 Influential Points

A point is influential if its exclusion from the regression fit causes a substantial change in the regression analysis, for example, in the fitted values or model coefficient estimates. Therefore, techniques have been developed to identify these influential observations.

4.3.4.3.1 DFFITS

The DFFITS measure measures the influence that observation $i$ has over its own adjusted value. In this case, we measure the influence of excluding the ith observation on its predicted or adjusted value. Let us consider the measure

$$DFFITS_{(i)}=\frac{\hat{Y}_i-\hat{Y}_{i(i)}}{\sqrt{QME_{(i)}h_{ii}}},$$

that is, the difference between the predicted values of $Y_i$ with and without observation $i$ (if $i$ is in parentheses, it means we excluded observation $i$), expressed in units of standard deviations of the predicted values of $Y_i$. Thus, this technique measures how much the exclusion of observation $i$ increases or decreases its predicted value. We say that an observation is an influential point according to the DFFITS measure if:

(1) $|DFFITS_{(i)}|~>~ 1$, for small or medium samples.

(2) $|DFFITS_{(i)}|~>~ 2\sqrt{(p+1)/n}$, for large samples, in which $(p+1)$ is the number of parameters.

4.3.4.3.2 DFBETA

The DFBETA measure measures the influence of observation $i$ about the coefficient of $X_j$. This measure of influence is deined by $$DFBETA_{j(i)}=\frac{\hat{\beta}_j-\hat{\beta}_{j(i)}}{\sqrt{QME_{i}c_{jj}}},~~~~~~~~j=0,1,…,p,$$

in which $c_{jj}$ is the jth element of the diagonal of $(X^\prime X)^{-1}$. A high value for the DFBETA influence measure indicates that the observation influences the estimate of the angular coefficient of the explanatory variable $X_j$. Influential observations are considered to be those that

(1) $|DFBETA|~>~1$, for small samples.

(2) $|DFBETA|~>~2/\sqrt{n}$, for large samples.

4.3.4.3.3 Cook’s Distance

Cook’s distance measures the influence of observation $i$ about everyone $n$ adjusted values $\hat{Y}_i$. This measure of influence is defined by:

$$D_i=\frac{e_i^2}{(p+1)QME}\frac{h_{ii}}{(1-h_{ii})^2}.$$

We realize that $D_i$ is great when or the residue $e_i$ It’s big, the leverage $h_{ii}$ is large or both. We highlight the observations when $D_i~>~1$.

Example 3.4.3.1

Let’s check whether the observations from “Motivation 1” are influential points. It is worth mentioning that in the analysis of residues we are considering the model $$\hbox{Dureza}=\beta_0+\beta_1\hbox{Temperatura}.$$

Solution:

Observations DFFIT DF $\beta_0$ DF $\beta_1$ DCOOK
1 -0,039 -0,032 0,031 8.11E-04
2 -0,039 -0,032 0,031 8.11E-04
3 -0,039 -0,032 0,031 8.11E-04
4 -0,325 -0,265 0,260 5.38E-02
5 -0,641 -0,523 0,514 1.90E-01
6 0,579 0,249 -0,236 1.35E-01
7 0,173 0,075 -0,071 1.54E-02
8 0,003 0,001 -0,001 5.94E-06
9 0,173 0,075 -0,071 1.54E-02
10 0,173 0,075 -0,071 1.54E-02
11 0,201 -0,078 0,082 2.07E-02
12 -0,530 0,204 -0,216 1.18E-01
13 -0,139 0,053 -0,057 9.98E-03
14 0,390 -0,150 0,159 7.06E-02
15 -0,139 0,053 -0,057 9.98E-03
16 0,095 -0,075 0,076 4.78E-03
17 0,095 -0,075 0,076 4.78E-03
18 0,095 -0,075 0,076 4.78E-03
19 -0,831 0,654 -0,667 2.93E-01
20 0,095 -0,075 0,076 4.78E-03

Table 4.3.20: Measures of Influence of the example on “Motivation 1”.

Using the Action software we have the following results:

Figura4.3.11

Figure 4.3.11: Graphs with the values of DFFITS, D-COOK and DFBETAS considering the data from Motivation 1.

From the results in Table 4.3.20 and Figure 4.3.11, we have that no DFFITS, D-COOK and DFBETAS is, in modulus, greater than 1. Thus, we have that no observation from the example in “Motivation 1” is an influential point.

Example 3.4.3.2

We will again use the example of “Motivation 2” to check whether the observations are influential points. It is worth highlighting that in the analysis of residues we are considering the following model

$\hbox{Ganho} = \beta_0 + \beta_1 \hbox{Dose de íons} + \beta_2 \hbox{Tempo}.$

Solution:

Observations DFFITS DF $\beta_0$ DF $\beta_1$ DF $\beta_2$ DCOOK
1 0,841 0,745 -0,492 -0,573 0,231
2 0,399 0,055 -0,236 0,268 0,057
3 -0,720 -0,018 -0,352 0,526 0,171
4 -0,528 0,418 -0,262 -0,382 0,096
5 0,049 0,022 -0,023 -0,001 0,001
6 -0,137 -0,084 0,094 0,002 0,007
7 0,964 -0,535 0,692 -0,010 0,222
8 -0,459 -0,257 0,037 0,384 0,072
9 -0,351 0,130 0,027 -0,291 0,043
10 -0,599 -0,417 0,478 0,008 0,115
11 -0,803 0,518 -0,657 0,007 0,192
12 0,200 0,036 -0,029 -0,004 0,014
13 0,693 -0,456 0,577 -0,005 0,152
14 0,130 0,005 -0,018 0,029 0,006

Table 4.3.21: Measures of Influence of the example in “Motivation 2”.

Using the Action software we have the following results:

Figura4.3.12.svg

Figure 4.3.12: Graphs with the values of DFFITS, D-COOK and DFBETAS considering the data from Motivation 2.

From the results in Table 4.3.21 and Figure 4.3.12 we have that no DFFITS, D-COOK and DFBETAS is, in modulus, greater than 1. Thus, we have that no observation from the example in “Motivation 2” is an influential point.

4.3.5 Lack of Fit Test

In this module we present a statistical test to assess lack of fit in a regression model. The test assumes that the normality, independence and homoscedasticity of the variance of the residuals are valid. Therefore, after adjustment, it is important to check whether the linear model is adequate. Figures 3.5.1 and 3.5.2 exemplify regression models that were well adjusted and models with adjustment problems.

In Figure 4.3.13, the expected value of $Y$ given $X$ ($E[Y\mid X]$) is aligned with the sample mean for each level. In this situation, we say that the lack of adjustment of a linear model practically does not exist, as the sample variation around the regression line is the random error due to the variation in the observations of the replicates.

Figura4.3.13

Figure 4.3.13: Perfectly fitted regression line without Lack of Fit

In Figure 4.3.14, the regression line does not fit the data perfectly and there is a large variance around the incorrect fit, in this case we observe a lack of fit. Note that the straight line does not pass through the average of each replicate.

Figura 4.3.14

Figure 4.3.14: Regression line with Lack of Fit

A formal way to check the fit of a linear model is through the lack of fit test.

This test requires repeated measurements for one or more levels of $X$. Below we present the test for both the linear and multiple models.

4.3.5.1 Analysis of lack of fit in Simple Linear Regression models

The simple linear model is:

$$Y_{ij}=\beta_0+\beta_1~x_i + \varepsilon \begin{cases}i=1,2,\ldots,m\cr j=1,2,\ldots,n_i \end{cases} \tag{3.5.1}$$

in which,

  • $Y_{ij}$ : represents the j-th observation for the ith value of the variable;

  • $\beta_0$ : where the line intersects the y axis;

  • $\beta_1$ : represents the slope of the regression line;

  • $x_i$: represents the ith value of the explanatory variable;

  • $\varepsilon_{ij}$: represents the random error associated with the ith and jth observation;

  • $n_i$ represents the number of observations for the ith value of x.

Assuming we have $m$ different values of the explanatory variable $(x_1,~x_2,~\ldots,~x_m)$ and that we have $n_i$ replicas of the response variable for each value of the explanatory variable, that is,

$$\begin{cases}x_1~~\Longrightarrow~~Y_{11}~~Y_{12}~~Y_{13}~~\ldots~~Y_{1n_1} \cr x_2~~\Longrightarrow~~Y_{21}~~Y_{22}~~Y_{23}~~\ldots~~Y_{1n_2}\cr x_3~~\Longrightarrow~~Y_{31}~~Y_{32}~~Y_{33}~~\ldots~~Y_{1n_3} \cr \vdots~~~~~~\vdots~~~~~~\vdots~~~~~~\vdots~~~~~~\vdots~~~~~~\ddots~~~~~~\vdots \cr x_m~~\Longrightarrow~~Y_{m1}~~Y_{m2}~~Y_{m3}~~\ldots~~Y_{mn_m} \end{cases}$$

Let’s break the sum of squares of the error into two components.

To understand the breakdown, we take,

$$Y_{ij}-\hat{Y}_i= (Y_{ij}-\bar{Y}_{i.})+(\bar{Y}_{i.}-\hat{Y}_{i}).$$

The first part reflects the variability between observations of the response variable for the same $x_i$, while the second part reflects the deviations from the observation means (in each $x_i$) for the model.

Thus, we associate the first part with pure error (PE) and the second part with the lack of model fit (lof).

$$SQE=\sum_{i=1}^{m}\sum_{j=1}^{n_i} (Y_{ij}-\hat{Y}_{i})^2$$

$$=\sum_{i=1}^{m}\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_{i.}+\bar{Y}_{i.}-\hat{Y}_i)^2$$

$$=\sum_{i=1}^{m}\sum_{j=1}^{n_i}( (Y_{ij}-\bar{Y}_{i.})-(\hat{Y}_i - \bar{Y}_{i.}))^2$$

$$=\sum_{i=1}^{m}\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_{i.})^2-2~\sum_{i=1}^{m}\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_{i.})(\hat{Y}_{i}-\bar{Y}_{i.})+\sum_{i=1}^{m}\sum_{j=1}^{n_i}(\hat{Y}_{i}-\bar{Y}_{i.})^2$$

$$=\sum_{i=1}^{m}\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_{i.})^2+\sum_{i=1}^{m}n_i(\hat{Y}_{i}-\bar{Y}_{i.})^2~,~~{pois}~~2~\sum_{i=1}^{m}\sum_{j=1}^{n_i} (Y_{ij}-\bar{Y}_{i.})(\hat{Y}_{i}-\bar{Y}_{i.})~=0$$

$$=SQ_{PE}+SQ_{LOF}.$$

So,

$$SQ_{PE}=\sum_{i=1}^{m}\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_{i.})^2~~~{ e }~~~SQ_{LOF} =\sum_{i=1}^{m}n_i(\hat{Y}_{i}-\bar{Y}_{i.})^2.$$

The mean square due to Lack of Fit is given by

$$QM_{LOF}=\frac{SQ_{LOF}}{m-2}.$$

Thus the test for lack of fit is given by

$$F_0=\frac{QM_{LOF}}{QM_{PE}}=\frac{\frac{(SQ_{LOF})}{(m-2)}}{\frac{SQ_{PE}}{(n-m)}}~~~~\sim F_{(m - 2; n - m)}$$

We have to

$$E[QM_{LOF}] =\sigma^2 + \frac{\displaystyle\sum_{i=1}^{m}n_i [E(Y_i) - \beta_0 -\beta_1~x_i]^2}{m-2}. \tag{3.5.2}$$

If the linear regression is perfect, we obtain that $E(Y_i)=\beta_0+\beta_1~x_i$ and the second term of equation (3.5.2) is zero. In this case,

$$E[QM_{LOF}]=\sigma^2$$

If the linear model is not suitable, we obtain that $E(Y_i)\neq\beta_0+\beta_1~x_i$. In this case,

$$E[QM_{LOF}]> \sigma^2$$

Be,

$$\begin{cases} H_0:E(Y_i)=\beta_0+\beta_1~x_i \hbox{ modelo linear adequado} \cr H_1: E(Y_i) \neq \beta_0 + \beta_1~x_i \hbox{ modelo linear inadequado} \end{cases}$$

Se $H_0$ is true, we get that $F_0 \sim F_{(m - 2; n - m)}.$

Therefore, we reject $H_0$ if $F_0> F_{(\alpha,m - 2; n - m)}.$

The P-value is given by

$$\text{P-valor}=P[F_{(m - 2; n - m)}> F_0].$$

The ANOVA table is summarized as:

Source SQ GL QM Statistics
Regression $SQR$ 1 $SQR$ $\frac{SQR}{\frac{SQE}{n-2}}$
Waste $SQE$ n-2 $\frac{SQE}{n-2}$
Lack of Adjustment $SQE - SQE(\text{puro})$ m-2 $\dfrac{SQE - SQE(\text{puro})}{m-2}$ $\frac{\dfrac{SQE - SQE(\text{puro})}{m-2}}{\dfrac{SQE(\text{puro})}{n-m}}$
Pure Error $SQE(\text{puro})$ n-m $\dfrac{SQE(\text{puro})}{n-m}$
Total $SQT$ n-1

Table 4.3.22: ANOVA for the regression linearity test.

Example 3.5.1

Let’s apply the Lack of Adjustment Test to the example of “Motivation 1”. In this case of simple regression, we have four levels $(m=4)$ of the explanatory variable temperature, with four replications each.

Solution:

$$S_{xx}=\sum_{i=1}^{n}\sum_{j=0}^{n_i}(x_{ij}-\bar{x_{i.}})^2= 625$$

$$S_{yy}=\sum_{i=1}^{n}\sum_{j=0}^{n_i}(y_{ij}-\bar{y_{i.}})^2= 706,8$$

$$S_{xy}=\sum_{i=1}^{n}\sum_{j=0}^{n_i}(x_{ij}-\bar{x_{i.}})(y_{ij}-\bar{y_{i.}})=-645$$

We initially have $$(y_{ij}-\hat{y}_i)=(y_{ij}-\bar{y}_{i.})-(\bar{y}_{i.}-\hat{y}_{i}).$$

From there we can arrive at the separate sum of squares for the Lack of Fit Test.

$$SQE=\sum_{i=1}^{m}\sum_{j=1}^{n_i}(y_{ij}-\bar{y}_{i.})^2 +\sum_{i=1}^{m}\sum_{j=1}^{n_i}(\hat{y}_{i}-\bar{y}_{i.})^2$$

$$=30,40+10,76=41,16.$$

$$QM_{LOF}=\frac{SQ_{LOF}}{m-2}=\frac{10,76}{2}=5,38.$$

$$QM_{PE}=\frac{SQ_{PE}}{n-m}=\frac{30,4}{16}=1,9.$$

We can then calculate the F statistic based on mean squares, knowing that in this example the values of $m = 4$ and $n = 20.$

$$F_0=\frac{QM_{LOF}}{QM_{PE}}=\frac{5,38}{1,9}= 2,83~~~~\sim ~~~~F_{(2;16)}$$

Se $H_0$ is true, we get that $F_0 \sim F_{(2;16)}.$ Therefore, we reject $H_0$ if $F_0> F_{(2,83;2; 16)}.$

The p-value is given by

$$\text{P-valor}=P[F_{(2; 16)}> F_0]= 0,089.$$

Source SQ GL QM Statistics P-value
Regression 665,64 1 665,64 350,3368 0
Waste 41,16 18 2,2867
Lack of Adjustment 10,76 2 5,38 2,8316 0,0885
Pure Error 30,4 16 1,9
Total 706,8 19

Table 4.3.23: Lack of Fit Test (Motivation 1).

Therefore, we do not reject the hypothesis that the linear model is adequate.

4.3.5.2 Analysis of lack of fit in models in Multiple Linear Regression

In the case of multiple linear regression, our model is given by

$$Y_{ij}=\beta_0+\beta_i~x_{ij}+\varepsilon_{ij} ~~\begin{cases}i=1,2,\ldots,m \cr j=1,2,\ldots,n_i \cr \end{cases} \tag{3.5.3}$$

in which,

  • $Y_{ij}$ : represents the j-th observation for the ith value of the variable;

  • $\beta_0$ : where the hyperplane intersects the y-axis;

  • $\beta_i$ : is the coefficient of the ith regressor variable ($x_i$);

  • $x_{ij}$: the j-th value of the explanatory variable $i$;

  • $\varepsilon_{ij}$: random error associated with the jth observation;

  • $n_i$ represents the number of observations for the ith value of x.

As we have $n_i$ observations for each combination i of explanatory variables, $x_i$, we have $n=\displaystyle\sum_{i=1}^{n}n_i$ observations.

The test procedure involves partitioning the sum of squares of the residuals into two components (in the same way as in the simple linear case),

$$SQ_E = SQ_{PE}+SQ_{LOF}.$$

in which $SQ_{PE}$ is the sum of squares due to Pure Error and $SQ_{LOF}$ is the sum of squares due to Lack of Fit.

To develop this partition $SQ_E$, note that the $(ij)$-th residue is,

$$e_{ij}=Y_{ij}-\hat{Y}_i= (Y_{ij}-\bar{Y}_{i.})+(\bar{Y}_{i.}-\hat{Y}_{i}). \tag{3.5.4}$$

in which $\bar{Y}_i$ is the average of $n_i$ observations in $x_i$.

With both sides squared in equation (3.5.4) and adding through i and j, we have:

$$\sum_{i=1}^m \sum_{j=1}^{n_i} (Y_{ij}-\hat{Y}_i)^2=\sum_{i=1}^m\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_i)^2+\sum_{i=1}^{m}n_i(\bar{Y}_i-\hat{Y})^2. \tag{3.5.5}$$

The left side of equation (3.5.5) is the traditional sum of squares of the residuals. The two components on the right measure pure error and Lack of Fit.

The sum of the squares of pure error,

$$SQ_{PE}=\sum_{i=1}^m\sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_i)^2, \tag{3.5.6}$$

is obtained through the sum of the corrected squares of repeated observations at each level $x_i$ and then we sum for all m levels of x.

As we have $(n_i - 1)$ degrees of freedom for the sum of squares of pure error at each level $x_i$, the total degrees of freedom associated with the sum of squares of pure error is,$\displaystyle\sum_{i=1}^m (n_i -1)=n-m.$

The sum of the squares of the Lack of Fit,

$$\sum_{i=1}^{m}n_i(\bar{Y}_i-\hat{Y})^2. \tag{3.5.7}$$

is a weighted sum of the squared deviations between the mean response $\bar{Y}_i$ at each level and its

corresponding adjusted value.

If the adjusted value $\hat{Y}_i$ is close to the corresponding average responses $\bar{Y}_i$ so there is a strong indication that the linear model is adequate. Se $\hat{Y}_i$ deviates a lot from $\bar{Y}_i$, this in turn is a strong indication that the regression is not linear.

The expected value of $QM_{PE}$ is $\sigma^2$, and the expected value of the $QM_{LOF}$ is given by:

$$E(QM_{LOF})=\sigma^2+\frac{\sum_{i=1}^m n_i \left[ E(Y_i)-\beta_0-\sum_{j=1}^k \beta_j x_{ij} \right]^2}{m-p-1}.$$

in which $p$ is the number of explanatory variables in the regression.

The statistical test for Lack of Fit is,

$$F_0=\frac{\frac{SQ_{LOF}}{(m-p-1)}}{\frac{SQ_{PE}}{(n-m)}}=\frac{QM_{LOF}}{QM_{PE}}.$$

If the linear regression is perfect, we obtain that $E(Y_i)=\beta_0+\beta_1~x_i$ and the second term of the equation is zero. In this case, $$E[QM_{LOF}]=\sigma^2.$$

If the linear model is not suitable, we obtain that $E(Y_i)\neq\beta_0+\beta_1~x_i$. In this case, $$E[QM_{LOF}]> \sigma^2.$$

Be,

$$\begin{cases} H_0:E(Y_i)=\beta_0+\beta_1~x_i \hbox{ modelo linear adequado} \cr H_1: E(Y_i) \neq \beta_0 + \beta_1~x_i \hbox{ modelo linear inadequado} \end{cases}$$

Se $H_0$ is true, we get that $F_0 \sim F_{(m - p-1; n - m)}.$ Therefore, we reject $H_0$ if $F_0 > F_{(\alpha,m - p-1; n - m)}$. The P-value is given by:

$$\text{P-valor}=P[F_{(m - p -1; n - m)}> F_0].$$

The ANOVA Table summarizes as

Source SQ GL QM Statistics
Regression $SQR$ p $QMR$ $\frac{SQR}{s^2}$
Waste $SQE$ n-p-1
Lack of Adjustment $SQE - SQE(puro)$ m-p-1 $\frac{SQE - SQE(puro)}{m-p-1}$ $\frac{SQE - SQE(puro)}{s^2(m-p-1)}$
Pure Error $SQE(puro)$ n-m $\frac{SQE(puro)}{n-m}$
Total $SQT$ n-1

Table 4.3.24: ANOVA for the regression linearity test.

Example 3.5.2

Let’s apply Lack of Adjustment to the problem given in “Motivation 2”. As we need replicas at the levels, we will consider a new set of data as shown in Table 4.3.25.

Note Time Dose Gain Note Time Dose Gain
1 195 4 1004 16 225 4,7 1160
2 195 4 1010 17 225 4,3 1276
3 195 4,6 852 18 225 4,3 1270
4 195 4,6 849 19 225 4,72 1225
5 195 4,3 903 20 225 4,72 1220
6 195 4,3 920 21 230 4,3 1321
7 225 4,2 1272 22 230 4,3 1330
8 225 4,2 1285 23 230 4,5 1340
9 225 4,1 1270 24 230 4,5 1345
10 225 4,1 1280 25 255 4 1636
11 225 4,6 1269 26 255 4 1640
12 225 4,6 1200 27 255 4,6 1506
13 225 4 1260 28 255 4,6 1510
14 225 4 1250 29 255 4,3 1555
15 225 4,7 1146 30 255 4,3 1550

Table 4.3.25: “Motivation 2” data with replicas

Solution:

We initially have

$$ (y_{ij}-\hat{y}_i)=(y_{ij}-\bar{y}_{i.})-(\bar{y}_{i.}-\hat{y}_{i}).$$

From there we can arrive at the separate sum of squares for Lack of Adjustment.

$$SQE=\sum_{i=1}^m\sum_{j=1}^{n_i}(y_{ij}-\bar{y}_{i.})^2 +\sum_{i=1}^m \sum_{j=1}^{n_i}(\hat{y}_{ij}-\bar{y}_{i})^2$$

$$=2942+28587=31529.$$

$$QM_{LOF}=\frac{SQ_{LOF}}{m-p-1}=\frac{28587}{12}= 2382.$$

$$QM_{PE}=\frac{SQ_{PE}}{n-m}=\frac{2942}{15} =196.$$

We can then calculate the F statistic, based on the mean squares, knowing that in this example the values of $m=15$ and $n=30$.

$$F_0=\frac{QM_{LOF}}{QM_{PE}} = \frac{2382}{196}= 12,15.$$

Se $H_0$ is true, we get that $F_0 \sim F_{(12;15)}.$

Therefore, we reject $H_0$ if $F_0> F_{(12; 15)}$.

The p-value is given by

$$\text{P-valor}=P[F_{(12; 15)}> F_0]= 0,000.$$

Below we have the ANOVA Table with the Lack of Fit of the data from the Motivation 2 example, with replications.

Source SQ GL QM Statistics P-value
Regression 1307620 2 653810 559,89 0
Waste 31529 27 1168
Lack of Adjustment 28587 12 2382 12,15 0
Pure Error 2942 15 196
Total 133914 29

Table 4.3.26: ANOVA table with Lack of Adjustment with data from Table 4.3.25

Using the Action software we have the following results:

  • No replicas:
Lack of Fit Test
Input data does not contain replicas.

Table 4.3.27: Lack of Fit Test with Motivation 2 data (without replications)

  • With replicas:
GL Sum of Squares Medium Square Stat. F P-value
Time 1 1264886.4029802 1264886.4029802 6449.1149030262 0
Dose 1 42733.8932878853 42733.8932878853 217.8818488505 2e-10
Waste 27 31529.1703985826 1167.7470517994
Lack of Adjustment 12 28587.1703985826 2382.2641998819 12.1461464984 0.0000124497
Pure Error 15 2942 196.1333333333

Table 4.3.28: Lack of Fit Test with Motivation 2 data with replicates.

4.3.6 Collinearity and Multicollinearity Analysis

When we work with more than one regressor variable, it is very important to check whether these explanatory variables are correlated. This way, if there is no relationship between them, we say they are orthogonal.

In practice, it is very difficult for the input variables to be orthogonal and, fortunately, the lack of orthogonality is not serious. But if the variables are highly correlated, inferences based on the regression model may be erroneous or unreliable.

Therefore, it is necessary to check whether the variables are highly correlated. In the literature, the terms Collinearity (Mulcollinearity) are used to indicate the strong existence of correlation between two (or more) independent variables. However, some authors designate Collinearity the existence of a linear relationship between two explanatory variables (correlation matrix) and Multicollinearity the existence of a linear relationship between an explanatory variable and the others.

If the matrix $X’X$ is singular, that is, some explanatory variables are linear combinations of others, we have Multicollinearity and there are no unique Least Squares Estimators for the parameters. Se $X’X$ is approximately singular, we have Multicollinearity approximate.

4.3.6.1 Collinearity

Some characteristics in the model adjustment may indicate collinearity problems. They are:

  • $\hat{\beta}_i$ with a sign opposite to that expected;

  • Big changes in $\hat{\beta}_i$ when we add or delete variables or observations;

  • $\hat{\beta}_i$ not significant for a $X_i$ theoretically important.

To diagnose collinearity, we have the following option:

  • Check whether the correlation matrix of the explanatory variables presents high correlations. If the correlation of two variables is close to 1, it indicates a problem.

4.3.6.1.1 Correlation Matrix

The correlation matrix presents the correlation of the variables with all others under consideration. Let’s assume we have three variables: $X_1,X_2$ and $X_3.$ The correlation matrix is given by

$$r=\begin{bmatrix}r_{(x_1,x_1)}~~r_{(x_1,x_2)}~~r_{(x_1,x_2)}\cr r_{(x_2,x_1)}~~r_{(x_2,x_2)}~~r_{(x_2,x_3)}\cr r_{(x_3,x_1)}~~r_{(x_3,x_2)}~~r_{(x_3,x_3)} \end{bmatrix},$$

in which

$$r_{x_j,x_k}=\frac{\sum_{i=1}^n(x_{ji}-\bar{x}_j)(x_{ki}-\bar{x}_k)}{(n-1)s_{x_j}s_{x_k}}.$$

$s_{x_j}$ and $s_{x_k}$ are the standard deviations of $X_j$ and $X_k$, respectively.

If the correlation of two variables is greater than 0.9, it is indicative of a strong correlation between them.

Example 3.6.1.1

In the example in “Motivation 2” we will check whether there is a correlation between the variables Time and Ion Dose.

Be $\bar{x_1}$ and $s_{x1}$ the mean and standard deviation of the Time variable, respectively and are $\bar{x}_2$ and $s_{x2}$ the mean and standard deviation of the Ion Dose variable. The correlation is given by

$$r_{x_1,x_2}=\frac{\sum_{i=1}^n(x_{1i}-\bar{x}_1)(x_{2i}-\bar{x}_2)}{(n-1)s_{x_1}s_{x_2}},$$

in which $\bar{x_1}$, $=225,36$, $\bar{x_2}=4,34$, $s_{x_1}=20,42$ and $s_{x_2}=0,26$.

$$r_{x_1,x_2}=\frac{\sum_{i=1}^n(x_{1i}-225,36)(x_{2i}-4,34)}{(14-1)(20,42)(0,26)}.$$

$$r_{x_1,x_2}= -0,00265.$$

The correlation matrix is

$$r=\begin{bmatrix} 1~~~~~-0,002 \cr -0,002~~~~~~~1 \end{bmatrix}.$$

Therefore, the correlation between the Time and Ion Dose variables is low.

Using the Action software we have the following results:

Collinearity

Time Ion dose
Time 1 -0.0026478463
Dose.de.ions -0.0026478463 1

Table 4.3.28: Collinearity matrix of Time and Dose variables

Figura4.3.15

Figure 4.3.15: Collinearity graph

4.3.6.2 Multicollinearity

Multicollinearity is a problem in model adjustment that can impact parameter estimation. We can diagnose Multicollinearity through the VIF (Variance Inflation Factor).

4.3.6.2.1 VIF

The elements of the main diagonal of $(X^\prime X)^{-1}$ they are also useful for detecting multicollinearity. The jth element of the main diagonal $(X^\prime X)^{-1}$, $C_{jj}$ can be written as $$C_{jj}=(1-R^2_j)^{-1},~~~~~~~~j=1,…,p.$$

in which $R_j^2$ is the coefficient of determination of the regression of $X_j$ on the other explanatory variables.

$C_{jj}$ is called the variance inflation factor and another notation used is $VIF_j$. Thus, the $VIF_j$ is given by

$$VIF_j=\frac{1}{1-R^2_j}.$$

We check that $VIF_j$ measures how much the variance of the coefficient $\hat{\beta}_j$ is inflated by its collinearity.

Generally, VIF is indicative of multicollinearity issues if VIF > 10.

Example 3.6.2.1

Still considering the example in “Motivation 2”, let’s calculate the VIF of the Dose and Time variables.

  • Calculation of the VIF of the Time variable:

O $R^2$ of the Time variable considering Ion Dose as an explanatory variable is 0.000007. Thus, the VIF of the Time variable is

$$VIF=\frac{1}{1-0,000007}=1,000007.$$

  • Calculation of the VIF of the Ion Dose variable

O $R^2$ of the Ion Dose variable considering Time as an explanatory variable is 0.000007. Thus, the VIF of the ion dose variable is

$$VIF=\frac{1}{1-0,000007}=1,000007.$$

Note that the VIF values ​​for both variables are the same. This happens because VIF measures the correlation of the variable with all others in the model. As we only have these two variables in the adjusted model, obviously the VIF of both is the same.

As the VIF is less than 10, we do not have the multicollinearity problem in the “Motivation 2” example.

Using the Action software we have the following results:

Time Ion dose
VIF 1 1

Table 4.3.29: Multicollinearity of the Time and Dose variables

↑