Article ID: 829215  View products that this article applies to. On This PageSUMMARYThis article describes numeric improvements in each of the
three Analysis ToolPak ANOVA tools. This article also illustrates inaccurate results in Microsoft Excel
2002 and in earlier versions of Excel in extreme situations. MORE INFORMATIONMany functions require the calculation of the sum of squared
deviations about a mean. To do this accurately, Microsoft Office Excel 2003 and later versions of Excel use a twopass
procedure that finds the mean on the first pass, and then calculates squared
deviations about the mean on the second pass. In precise arithmetic, the same result occurs in earlier versions of Excel that use the "calculator formula." This formula is so named because it was in widespread use when statisticians used calculators instead of computers. With the calculator formula, earlier versions of Excel sum the squares of the observations, and then subtract from this total the following quantity:
In finite precision arithmetic, the calculator formula is subject to roundoff errors in extreme cases. Excel 2002 and earlier versions of Excel use the calculator formula for most functions that require a sum of squared deviations about a mean (such as VAR, STDEV, SLOPE, and PEARSON). However, these versions of Excel also use the more numerically robust twopass procedure for the CORREL, COVAR, and DEVSQ functions. Experts in statistical computing recommend that you do not use the calculator formula. The calculator formula is presented as "how not to do it" in texts about statistical computing. Unfortunately, all three of the Analysis ToolPak (ATP) ANOVA tools make widespread use of the calculator formula or an equivalent singlepass approach in Excel 2002 and in earlier versions of Excel. Excel 2003 and later versions of Excel use the twopass procedure for all three ATP ANOVA models. This article discusses the following computational improvements in ATP's three ANOVA models:
Because Excel has always used the twopass procedure with DEVSQ, this article makes frequent use of it to describe the improved procedures. These revised procedures either effectively call DEVSQ or use code whose functionality is exactly the same as DEVSQ's functionality. For each ANOVA tool, ATP output contains a Summary table with values of Count, Sum, Average, and Variance, and an ANOVA table that has various sums of squares and values of SS, df, MS, F and Pvalue. Results in the summary table are calculated by calling Excel functions COUNT, SUM, AVERAGE, and VAR. Of these four functions, only VAR is subject to roundoff errors. Excel 2002 and earlier versions of Excel implement VAR by using the calculator formula. The following article about VAR describes the improvements that occurred in Excel 2003 and in later versions of Excel. This article also lets you experiment with numeric data to see when roundoff errors are likely to occur in earlier versions of Excel. For more information about VAR, click the following article number to view the article in the Microsoft Knowledge Base: 826112
(https://support.microsoft.com/kb/826112/
)
Excel statistical functions: VAR
As this article discusses the three ANOVA models, it focuses on the ANOVA output tables. In each case, the Summary tables are wellbehaved in Excel 2003 and in later versions of Excel. In Excel 2002 and in earlier versions of Excel, problems occur in the Variance column when data have extreme values. However, this article includes the Summary tables in the model sections because these tables are useful for comparison when you review the modified examples in the Appendix. Model 1: Single FactorA simple example with data is as follows.Collapse this table
Again, for model 2 and model 3, sums of squares are calculated and a quantity is subtracted from the sum of squares as in the calculator formula. Unfortunately, basic statistics texts frequently suggest approaches for ANOVA such as the one that is shown earlier in this article. Excel 2003 and later versions of Excel use a different approach to calculate the various entries in the SS column of the ANOVA table. For illustration, this article assumes that the numeric data in the earlier example appear in cells A2:C7 with missing data in cells B6 and B7.
Model 2: TwoFactor with ReplicationA simple example with data is as follows.Collapse this table
Here is the computational procedure for Excel 2003 and for later versions of Excel. This procedure uses DEVSQ to calculate the various entries in the SS column of the ANOVA table. For illustration, this example assumes that the numeric data appear in cells B2:D7.
Model 3: TwoFactor without ReplicationA simple example with data is as follows.Collapse this table
Excel 2003 and later versions of Excel use the following computational procedure. The procedure uses DEVSQ to calculate the values in the SS column of the ANOVA table. For illustration, this example assumes that the range of cells shown in the earlier example is cells A1:D10. Therefore, the numeric data appear in cells B2:D10.
Results in Excel 2002 and in earlier versions of ExcelIn extreme cases where there are many significant digits in the data but also a small variance, the calculator formula leads to inaccurate results. The Appendix that appears later in this article gives examples of roundoff problems in such extreme situations.Results in Excel 2003 and in later versions of ExcelExcel 2003 and later versions of Excel use a procedure that makes two passes through the data. On the first pass, Excel 2003 and later versions of Excel calculate the sum and count of the data values. From these, Excel can calculate the sample mean (average).On the second pass, Excel calculates the squared difference between each data point and the sample mean, and then sums these squared differences. As a result, the results in Excel 2003 and in later versions of Excel are more stable numerically. ConclusionsA twopass approach improves the numeric performance in all three ATP ANOVA tools in Excel 2003 and in later versions of Excel as compared to earlier versions of Excel. The results that you obtain by using Excel 2003 and later versions of Excel are never less accurate than the results that you obtain by using earlier versions of Excel.In most practical cases, however, there is no difference between these results. This is because data do not typically exhibit the kind of unusual behavior that the following Appendix illustrates. Numeric instability is most likely to occur in earlier versions of Excel when data contains a high number of significant digits with relatively little variation between data values. If you use an earlier version of Excel, and if you want to see whether Excel 2003 or a later version of Excel gives you different ANOVA results, compare the results that you obtain when you use the ANOVA tools in your earlier version of Excel with the results that you obtain when you use the procedures that use DEVSQ. Note The procedures that use DEVSQ were described earlier in this article for the ANOVA table that is associated with each of the tools. To verify that Variances are correct in the Summary table for each range, use DEVSQ(range)/(COUNT(range) – 1). Appendix: Numeric examples of the performance of Excel 2002 and earlier versions of ExcelFor each basic example from models 1, 2, and 3, this article previously presented the ATP tool's output. This included the Summary and ANOVA tables. Data was modified in each example to create a "stressed" example. This is done by adding 10^8 to each data value. Adding a constant such as 10^8 to each data value does not affect Variance in the Summary table (but will affect Average and Sum in obvious ways). It should also not affect any entry in the ANOVA table.If you compare Variances in the Summary tables and SS in the ANOVA tables, you will notice that all of these are incorrectly calculated in all three of the following stressed models except for one entry in model 3 that is pointed to with "<". In all the stressed cases, the ANOVA results that you obtain by using Excel 2003 and later versions of Excel agree with the earlier results in the basic cases (as they should). ANOVA 1 stressed model with large data valuesCollapse this table
ANOVA 2 stressed model with large data valuesCollapse this table
ANOVA 3 stressed model with large data valuesCollapse this table
PropertiesArticle ID: 829215  Last Review: January 10, 2007  Revision: 2.2
Give Feedback 
