# Modeling and Fitting Two-Way Tables Containing Outliers

Authors: David L. Farnsworth
Journal: International Journal of Mathematics and Mathematical Sciences
 (2023)

---

## Abstract

A model is proposed for two-way tables of measurement data containing outliers. The two independent variables are categorical and error-free. Neither missing values nor replication is present. The model consists of the sum of a customary additive part that can be fit using least squares and a part that is composed of outliers. Recommendations are made for methods for identifying cells containing outliers and fitting the model. A graph of the observations is used to determine the outliers’ locations. For all cells containing an outlier, replacement values are determined simultaneously using a classical missing-data tool. The result is called the adjusted table. The inserted values are such that, when a mean-based fitting of the adjusted table is performed, the residuals in those cells are zero. The outlying portion of the observation in each of those cells is the difference of the observation and the replacement value. In this way, outliers are removed from further analyses of the adjusted table. This is particularly helpful because outliers can greatly contaminate and alter computations and conclusions. Subsequently, the causes of the outliers might be determined, and statistical estimation and testing can be implemented on the adjusted table.


---

## Body

## 1. Introduction

The modeling of anm × n table that contains outliers and is otherwise approximately additive is addressed. An outlier is an observation that is substantially different from the other observations ([1], p. 4; [2], p. 1; [3], pp. 3-4). Methods are recommended for the identification of the cells containing outliers, computation of replacement values for those cells, and estimation of the sizes of the outliers beyond the replacement values. They fill the need for a set of systematic and uncomplicated methods.The goal is a least-squares, i.e., mean-based, analysis of the observations. However, when outliers are present, that statistical analysis is unreliable due to cross contamination among the table’s cells. The cells that contain outliers are identified, and the outliers’ sizes are estimated in order to determine whether they might be impactful on the statistical analysis. In the model and fitting procedure, the underlying additive observations are prepared for analyses, and the outlying measurements, being isolated both in the model and the fit, can be concurrently investigated, including for causes.The approach is guided by a desire for simplicity, believing that little is gained from excessive computations and manipulation of the observations and that, indeed, much can be lost with subsequent misleading outcomes. Imposing or guessing a probability model can cause its own problems. If it is incorrect, non-outlying observations might be misidentified as outlying because they do not fit the model or might be missed because they do ([2], pp. 60–62).It is required that the outliers’ identification method always works, that is, outliers are not missed and non-outliers are not identified as outliers. The method should not presuppose a certain fixed number of outliers, as some methods do. A governing principle is that the methods must not break down.The cells that contain outlying values are found by examining a three-dimensional graph of the observations, where it is extremely unlikely that outliers will be masked or non-outliers will be misidentified as outliers. Each outlier is removed from the analysis, and a perfectly fitting value is inserted into its cell. The cell’s replacement value eliminates repercussions by the outlier on further analyses. The outliers themselves can be important in many ways ([2], pp. 399–418; [3], pp. 16-17, 199-200). To the person using the observations, the role of the outlying observations can be either beneficial or harmful. The outliers might indicate a cure for a disease or combinations of the independent variables that produce uniquely favorable outcomes with either high or low values of the dependent variable. On the other hand, outliers may highlight pairs of values of the independent variables that cause harm and should be avoided. The identified outlying values can be errors and might be investigated as such.For measurement datayij, the model is(1)yij=μ+αi+βj+εij+∑p,qδijIi,j=p,q,with 1 ≤ i ≤ m, 1 ≤ j ≤ n, m ≥ 3, and n ≥ 3, where there is one observation per cell. The first four terms are considered a conventional additive, mean-based model. Cells identified as (p, q) contain outliers of size δpq beyond the additive model. The functionI is the indicator function.The graph of the observations serves the purpose of finding the locations of the outliers and checking the appropriateness of the additive model. The independent axes are the row and column numbersi and j. The graphing program allows rotation of the axes, so that the observations can be viewed from any vantage point. If the observations do not appear sufficiently planar, a transformation of the dependent variable should be considered. If the points corresponding to a whole row or column are questionable, that level of the dependent variable should be examined.To simultaneously determine replacement values for all the cells identified as having an outlier, place a variable in each of those cells and find the additive fit for them. The fitted values depend upon the variables in a linear way. Set each fitted value equal to the respective variable. The solution of this system of linear equations is the replacement value for the adjusted table. They give residuals of zero in those cells in mean-based fitting of the adjusted table. The estimates of the sizes of the outlying portions are the differences between the observations and the replacement values. The outlying portions of the cells’ observations are segregated from the adjusted table. For each replaced value, one degree of freedom is lost in subsequent analyses of them × n adjusted table.Example 1.
Consider the artificial data in Table1 [4]. Figure 1 shows that, except for the two outliers in cells (1, 1) and (3, 3), the data appear to be close to planar, thus additive. No transformation is required. Placing y11′ and y33′ in cells (1, 1) and (3, 3), finding the fitted values, and setting the fitted values equal to y11′ and y33′ gives(2)y11′+2+1+24+y11′+2+23–y11′+2+1+2+2+0+2+2+2+1+y33′+012=y11′,and(3)2+1+y33′+04+1+2+y33′3–y11′+2+1+2+2+0+2+2+2+1+y33′+012=y33′,or 6y11′+y33′=17 and y11′+6y33′=7, whose solution gives the replacement values y11′=19/7 and y33′=5/7. Fitting the adjusted table containing these values and using the outlying portions 14–19/7 = 79/7 and 5–5/7 = 30/7 in cells (1, 1) and (3, 3), the fit of the model is(4)yij=6142+1021121–1121+3342–1942–942–542+797Ii,j=1,1+307Ii,j=3,3.Table 1
Tukey’s artificial data for Example1.
1421220222150Figure 1
Observations in Table1 with (x, y, z) = (i, j, yij).


## 2. Computing the Replacement Values

This section formally presents the method employed to compute the values for insertion into the adjusted table to replace the values in the cells containing outliers. The method’s advantages are that it is computationally simple even for a large number of outliers and requires no iterations. The values are unique, if no entire row or column is considered to be outlying. The values yield residuals of zero in subsequent mean-based analyses of the adjusted table.Designate the originalm × n table by T. Table T′ is the same as T, except that the cells containing outliers have had their observations replaced by placeholders. The placeholder in cell (h, k) is designated by yhk′. Table T″ is the same as T, except that the cells of T containing outliers are composed of zeros. The fitted value for cell (h, k) in T is(5)fhk=∑j=1nyhjn+∑i=1myikm–∑i=1m∑j=1nyijmn.The fitted values for cell (h, k) in T ′ and T″ are designated as fhk′ and fhk″, respectively.Theorem 1 (one outlier).
IfT has one outlier, which is in cell (h, k), then the replacement value is(6)yhk′=mnm–1n–1fhk″.Proof.
Using (2) and setting the fitted value in T′ equal to yhk′ gives(7)fhk′=yhk′n+yhk′m–yhk′mn+fhk″=yhk′,whose solution is (6).
The outlying portion of the observation in cell (h, k) in Theorem 1 is defined to be yhk–yhk′, which is an estimator of δhk in model (1).Theorem 2 (two outliers).
IfT has two outliers, which are in cells (h, k) and (s, t), then the replacement values are given by the solutions to the following systems of linear equations, whose solutions are unique.Case 1.
(outliers in different rows and columns). Ifs ≠ h and t ≠ k, then(8)m–1n–1yhk′+yst′=mnfhk″,and(9)yhk′+m–1n–1yst′=mnfst″.Case 2.
(outliers in the same row and different columns). Ifs = h and t ≠ k, then(10)m–1n–1yhk′–m–1yht′=mnfhk″,and(11)–m–1yhk′+m–1n–1yht′=mnfht″.Case 3.
(outliers in different rows and the same column). Ifs ≠ h and t = k, then(12)m–1n–1yhk′–n–1ysk′=mnfhk″,and(13)–n–1yhk′+m–1n–1ysk′=mnfsk″.Proof.
For Case1 using (5),(14)fhk′=yhk′n+yhk′m–yhk′+yst′mn+fhk″=yhk′,and(15)fst′=yst′n+yst′m–yhk′+yst′mn+fst″=yst′,which are equivalent to (9). Since the determinant of the coefficients is (m − 1)2(n − 1)2 − 1 > 0, there is just one solution.
For Case2,(16)fhk′=yhk′+yht′n+yhk′m–yhk′+yht′mn+fhk″=yhk′,and(17)fht′=yhk′+yht′n+yhk′m–yhk′+yht′mn+fht″=yht′,which yields (11), where the determinant of the coefficients is non-zero.
The proof of Case3 is similar to the proof of Case 2.
The following theorem can be proven with the method of the proof of Theorem2.Theorem 3 (three outliers).
IfT has three outliers, which are in cells (h, k), (s, t), and u,v, then the replacement values are given by the solutions to the following systems of linear equations.Case 4.
(outliers in different rows and columns). Ifk, s, and u are distinct and k, t, and v are distinct, then(18)m–1n–1yhk′+yst′+yuv′=mnfhk″,yhk′+m–1n–1yst′+yuv′=mnfst″,and(19)yhk′+yst′+m–1n–1yuv′=mnfuv″.Case 5.
(two outliers in one row and the third in a different row and all outliers are in different columns). Ifs = h ≠ u and k, t, and v are distinct, then(20)m–1n–1yhk′–m–1yht′+yuv′=mnfhk″,–m–1yhk′+m–1n–1yht′+yuv′=mnfht″,and(21)yhk′+yht′+m–1n–1yuv′=mnfuv″.Case 6.
(two outliers in one column and the third in a different column and all outliers are in different rows). Ift = k ≠ v and h, s, and u are distinct, then(22)m–1n–1yhk′–n–1ysk′+yuv′=mnfhk″,–n–1yhk′+m–1n–1ysk′+yuv′=mnfsk″,and(23)yhk′+ysk′+m–1n–1yuv′=mnfuv″.Case 7.
(two outliers in one row and the third in the same column as one of the two). Ifs = h ≠ u and v = k ≠ t, then(24)m–1n–1yhk′–m–1yht′–n–1yuk′=mnfhk″,–m–1yhk′+m–1n–1yht′+yuk′=mnfht″,and(25)–n–1yhk′+yht′+m–1n–1yuk′=mnfuk″.Case 8.
(outliers in one row). Ifh = s = u and k, t, and v are distinct, then(26)m–1n–1yhk′–m–1yht′–m–1yhv′=mnfhk″,–m–1yhk′+m–1n–1yht′–m–1yhv′=mnfht″,and(27)–m–1yhk′–m–1yht′+m–1n–1yhv′=mnfhv″.Case 9.
(outliers in one column). Ifk = t = v and h, s, and u are distinct, then(28)m–1n–1yhk′–n–1ysk′–n–1yuk′=mnfhk″,–n–1yhk′+m–1n–1ysk′–n–1yuk′=mnfsk″,and(29)–n–1yhk′–n–1ysk′+m–1n–1yuk′=mnfuk″.
In Cases4–7 of Theorem 3, the determinants of the coefficients of the equations are non-zero for m ≥ 3 and n ≥ 3, so there is a unique solution. In Case 8, the determinant is −(m − 1)3n(n − 3), which is zero solely for n = 3 columns. If the table has only three columns and a particular row has three outliers, the estimates are not uniquely determined. Case 9 is similar with more than three rows being required for uniqueness of the estimates. Cases 8 and 9 illustrate the requirement for a unique solution that no single row or column is comprised of outliers.
A pattern emerges from Theorems1–3.Theorem 4 (any number of outliers).
Forv cells that contain outliers, the replacement values are given by the solutions to the system of linear equations:(30)MUVYV′=mnFU″,which are given in matrix notation, where the subscripts are for all the cells (i, j) that are among the cells (p, q), as displayed in model (1). The vector YV′ is a column of the replacement values yij′, which can be listed in any order, as long as consistency is maintained. The elements of column vector FU″ are the appropriate fij″. The v × v matrix MUV is symmetric. Each element on the main diagonal is (m − 1)(n − 1). The off -diagonal elements are +1, −(m − 1), or −(n − 1). The entry depends upon whether U and V represent cells that are in neither the same row nor the same column, in the same row, or in the same column, respectively. The solution is unique if there is no complete row or column of outliers.If all cells of a row or column are deemed to contain outliers, then the solution is not unique because adding any number to each replacement value is also a solution. At least one non-outlying cell is needed in the row or column in order to anchor the row or column’s run, so that the remaining values are unique. As few as minimum{m, n} outliers are sufficient for non-uniqueness. A row or column of outliers would indicate that the corresponding level of the independent variable should be examined before further analyses are attempted, so this is not a threat to this procedure.The other extreme is that all replacement values are unique if the cells are in anm − 1 by n − 1 block. In that case, the determinant of MUV ≠ 0, and a perfectly fitting, additive adjusted table is obtained. The row outside the block determines the differences for the additivity of the replacement values, and the single data value in each of the other rows determines the scale of its row. Because one degree of freedom is lost in the error term of (1) for each replacement value, determining the block’s (m − 1) (n − 1) replacement values reduces the degrees of freedom to zero. This maximum number of outliers would indicate that the so-called outliers are the typical data. The number of cells that might be considered to contain outliers gives reassurance that the breakdown of this method will not be met in practice. Indeed, this method is very safe.


## 3. Example

Example 2.
Consider the data in Table2. A graph shows that there are high outliers in cells (1, 2) and (1, 3) and a low outlier in cell (3, 4). This is an instance of Case 5 of Theorem 3 with (h, k) = (1, 2), (h, t) = (1, 3), and u,v = (3, 4). Table T″ is given in Table 3.
The equations for the replacement values are(31)8y12′–2y13′+y34′=24,–2y12′+8y13′+y34′=34,and(32)y12′+y13′+8y34′=117,whose solution is y12′=2,y13′=3, and y34′=14 The corresponding outlying portions in those cells are 10 − 2 = 8, 12 − 3 = 9, and 4 − 14 = −10.Table 2
Artificial dataT for Example 2.
1101245678910111213415Table 3
T″ corresponding to T in Table 2.
10045678910111213015


## 4. Concluding Comments

The cells designated as (p, q) in (1) are few in number and contain values that might be called outliers, interactions, errors, blunders, or contaminations or described as renegade, rogue, spurious, deviant, unrepresentative, stray, discordant, incongruous, or wild. The designation outlier is used in order to avoid words that might appear to prejudice the search for the cause of an unusual value. The model clarifies the manner in which outliers are set aside for examination.The graphical method for identifying outliers does not involve any manipulation of the observations, and thus no assumptions or artifacts of calculations enter the procedure. In particular, it does not involve residuals, which are widely used but fraught with pitfalls ([1], pp. 281–328). An aim is to alter the observations as little as possible by using a very light touch.A graph of the observations may be the safest method for determining the locations of outliers. Mean-based methods using z-scores can be flawed because outliers tend to increase standard deviations so that z-scores are reduced [5, 6]. Mean-based procedures have the feature that outliers contaminate multiple cells and lose their impact on their own cells ([1], pp. 284–285, 301–318; [7], pp. 184–185; [8]). An outlier biases the statistics that are being used to detect it and introduces dependence among the residuals. For a very simple example, take the artificial observations in Table 4, which have residuals of zero for an additive fit. Adding 9 to the entry in cell (1, 3) and performing a mean-based additive fit produce the residuals in Table 5. The spurious value in cell (1, 3) has produced non-zero residuals in every cell. Although the largest residual is in cell (1, 3), if some noise was present, the outlier could avoid detection and raise the variance for a subsequent estimation or testing procedure.Table 4
Artificial observations to show the impact of an outlier.
123456789Table 5
Residuals for an additive fit to Table4 with 9 added to the cell (1, 3).
−2−2411−211−2Graphing allows the observations to speak for themselves with no contamination or distortions and, importantly, with no assumption about the number of outliers. Decisions about the existence of a possible outlier do not have to be made through the lens of statistical calculations. Many graphing programs are freeware and work on many different platforms. They allow the user to rotate the axes and thus to examine the data cloud from any viewpoint, so that observations away from the data cloud can be seen and identified. One program is GeoGebra [9] (available at https://www.geogebra.org), which is used for Figure 1.Some other options for identifying outliers are median based because the median is known for its resistance to outliers. Two options that are often suggested are to fit the table using median polish ([7], pp. 184–185) or to determine whether observation is outside the inner fences, as in a boxplot [10]. However, both options have weaknesses. Median polish has the significant disadvantage that it can fail when there are outliers in all but one of the entries of a row or a column [8]. So, for a 3 × 3 table with outliers in cells (1, 1) and (1, 2), median polish might indicate that there is an outlier in cell (1, 3). Other unsatisfactory features of median polish are that different results might be obtained depending upon whether rows or columns are polished first and whether the mid-median or the low median is used. The procedure can fail to terminate and may even cycle.The inner fences areQ1 − 1.5 IQR and Q3 + 1.5 IQR, where Q1 and Q3 are the first and third quartiles and IQR is the interquartile range Q3 − Q1. Although this tool can be effective for univariate data ([2], pp. 45-46; [3], pp. 13-14), it ignores the row-column structure of the observations. It fails for tables that are nearly additive and tilted. For example, if the entries increase greatly to the right, and the outlier occurs at the cell in the first column whose underlying values are small, then the outlier might be about the size of the values in the right-hand columns and be undetected in the undifferentiated batch of observations. It would be discovered in a graph, as it would be far from the data cloud.There exist many diverse strategies for identifying outlying observations, which involve extra assumptions, sums of squares or other distance measures or even altering the definition of outlying to being on the boundary of a data cloud, all of which we have sought to circumvent. They include looking for reduction in variance [11], nearest neighbor techniques [12], and finding edges and corners in the data cloud [13]. Another technique is to search for low-density areas in the cloud of data [14], which can use few assumptions but can be computationally intensive. Some of these methods are difficult to implement when the independent variables’ values are not ordered, which is the case addressed here.The process used for finding the replacement values in the adjusted table reflects the operations based on means, which are envisioned for the adjusted table; consequently, no new concepts are added to the analysis. The calculations are extremely simple; in particular, no iterations are involved.The replacement values are numerically the same as Yates’ values used in cells where there are missing values ([15]; [16], pp. 33–34). For just one missing value, which is in cell (h, k),(33)yhk′=m∑j=1nyhj″+n∑i=1myik″–∑i=1m∑j=1nyij″m–1n–1,has been suggested to be inserted into the cell with the missing value ([16], p. 34; [17]; [18], p. 9). Expressions (6) and (33) are equivalent. Adding and subtracting yhk in each of the three summations in (33) yields(34)yhk′=mnfhk+1–m–nyhkm–1n–1,which is a weighted average that does not depend upon the value of yhk. (34) uses quantities that contain yhk and thereby makes unnecessary the introduction of T′ and T″.There may be arguments in favor of other replacement values. Leaving a hole is not recommended ([8], [16], pp. 4, 32–33). A candidate for a replacement value for a single outlier in cell (h, k) is a weighted average of values in the cell’s row and column. Using a cell’s nearest neighbors requires care because neither the rows nor the columns are ordered. The only neighbors to a cell are the cells in its row and column, and all those values are equally close.When there are multiple outliers, replacement values for the cells are determined simultaneously, so that the cells’ residuals would be zero in a mean-based fit of the table with the replacement values. In this way, each cell’s value does not contaminate the replacement values for the other cells. A sequential accommodation of outliers that might eliminate them one at a time has that shortcoming.The scope of this paper is limited to categorical or qualitative independent variables and quantitative dependent variables. Independent variables with more structure, such as an ordering, might be taken advantage of by using the fact that it creates a proximity measure. If the dependent variables are counts with a sufficient range, they might be treated as if they were continuous, instead of discrete. The field of outlier detection and analysis for categorical dependent variables is large and very active ([2], pp. 249–272; [3], pp. 69–93). Its techniques depend upon the features of the particular variables, in order to define nearness or similarities and to identify the appropriate discrete probability distributions.The suggested methodology is practical. Users are armed with knowing the locations of the irregular observations and possessing estimates of the sizes of these unusual values. They can decide if they are meaningfully large in magnitude and whether or not to search for causes. Since the recommended technique is very accessible, straightforward, and easy to implement, this is a suitable topic to introduce into elementary statistics courses.



---

*Source: 6352058-2023-02-11.xml*