# Methods and formulas for Two-way ANOVA

Select the method or formula of your choice.

The calculations for the mean square for the factors, interaction, and error follow:

### Notation

TermDescription
MSMean Square
SSSum of Squares
DFDegrees of Freedom

The sum of squared distances. SS Total is the total variation in the data. SS (A) and SS (B) are the amount of variation of the estimated factor level mean around the overall mean. These statistics are also known as the sum of squares for factor A or factor B. SS Error is the amount of variation of the observations from their fitted values. The calculations follow:

• SS (A) = nb Σi (y̅i.. − y̅ ...) 2
• SS (B) = na S j (y̅.j. − y̅ ... ) 2
• SS (AB) = SS Total − SS Error − SS (A) − SS(B)
• SS Error = S iΣjΣk (yijk − y̅ij. ) 2
• SS Total = ΣiΣjΣk (yijk − y̅...) 2
TermDescription
anumber of levels in factor A
bnumber of levels in factor B
n total number of trials
yi..mean of the i th factor level of factor A
y...overall mean of all observations
y.j.mean of the j th factor level of factor B
yij.mean of observations at the i th level of factor A and the j th level of factor B

## Degrees of freedom (DF)

For a model with factors A and B, the degrees of freedom associated with each sum of squares follow:
• DF (A) = a − 1
• DF (B) = b − 1
• DF (AB) = (a − 1)(b − 1)
• With no interaction in the model, DF Error = (n − 1) − (a − 1) − (b − 1)
• With the interaction in the model, DF Error = (n − 1) − (a − 1) − (b − 1) − (a − 1)(b − 1)
• Total = n − 1

### Notation

TermDescription
anumber of levels in factor A
bnumber of levels in factor B
ntotal number of observations

## Fitted mean

The fitted means are least squares estimates. For a factor level, the least squares mean is the sum of the constant coefficient and the coefficient for the factor level.

For a combination of factor levels in an interaction term, the least squares mean is the same as the fitted value.

The equation that defines the vector of estimated coefficients is as follows:

In the case of balanced data, the fitted means are equivalent to means in the data. For a factor level, the fitted mean is as follows:

For a combination of levels in an interaction term, the fitted mean is the same as the fitted value.

### Notation

TermDescription
constant coefficient
coefficient for the ith level of a factor
coefficient for the jth level of the second factor
Xdesign matrix
X'transpose of the design matrix
(X'X)−1inverse of the X'X matrix
Yvector of response values
yijith value at the jth level of the factor
nisample size for the jth level of the factor
yijkith value at the jth level of the first factor and the kth level of the second factor
njksample size for the jth level of the first factor and the kth level of the second factor

## Fit

The fitted values are least squares estimates.

The equation that defines the vector of estimated coefficients is as follows:

In the case of balanced data, the fitted values are equivalent to means in the data. If the model has no interaction term, the fitted value is as follows:

If the model has an interaction term, the fitted value is the cell mean, or the mean of observations at the ith level of factor A and the j th level of factor B.

### Notation

TermDescription
Xdesign matrix
X'transpose of the design matrix
(X'X)−1inverse of the X'X matrix
Yvector of response values
mean of the observations at the ith level of factor A
mean of the observations at the jth level of factor B
mean of all of the observations
mean of the observations at the ith level of factor A and the jth level of factor B

## F-value

The F statistic depends on the term in the test. For factor A, the F-statistic is as follows:

For factor B, the F-statistic is as follows:

For the interaction between factor A and factor B, the F-statistic is as follows:

When the lack-of-fit test appears, the F-statistic is as follows:

The numerator and denominator degrees of freedom correspond to the degrees of freedom for the mean square.

TermDescription
MSMean Square

## Pooled standard deviation

The pooled standard deviation is equivalent to S, which is displayed in the output. The formula follows:

TermDescription
MSMean Square

## P-value – Analysis of variance table

The degrees of freedom for the F statistic that you use to calculate the p-value depend on the term that is in the test.

When you test a term, the denominator degrees of freedom are always the degrees of freedom for error. The degrees of freedom for error depend on whether the interaction term is in the model or not.
• With no interaction in the model, DF Error = (n − 1) − (a − 1) − (b − 1)
• With the interaction in the model, DF Error = (n − 1) − (a − 1) − (b − 1) − (a − 1)( b − 1)
When you test a term, the numerator degrees of freedom depend on the term.
• For F(A), the degrees of freedom for the numerator are a − 1
• For F(B), the degrees of freedom for the numerator are b − 1
• For F(AB), the degrees of freedom for the numerator are (a − 1)(b − 1)
For the lack-of-fit test, the degrees of freedom follow:
• Denominator DF = nc
• Numerator DF = cp

1 − P(Ffj)

### Notation

TermDescription
anumber of levels in factor A
bnumber of levels in factor B
ntotal number of observations
cnumber of unique combinations of factor levels
pnumber of terms in the model
P(Ffj)cumulative distribution function for the F distribution
fjf statistic for the test

## Residuals (Resid)

### Notation

TermDescription
yijkkth response value for the ith level of factor A and the jth level of factor B
kth fitted value for the ith level of factor A and the jth level of factor B
mean of the fitted values for the ith level of factor A and the jth level of factor B

## R-sq

R2 is also known as the coefficient of determination.

### Notation

TermDescription
yi i th observed response value
mean response
i th fitted response

Accounts for the number of predictors in your model and is useful for comparing models with different numbers of predictors.

### Notation

TermDescription
yi i th observed response value
i th fitted response
mean response
n number of observations
p number of model parameters

## R-sq (pred)

While the calculations for R2(pred) can produce negative values, Minitab displays zero for these cases.

### Notation

TermDescription
yi i th observed response value
mean response
n number of observations
ei i th residual
hi i th diagonal element of X(X'X)–1X'
X design matrix

## S

### Notation

TermDescription
MSEmean square error

## SE Mean

### Formula

The vector x0 defines the factor levels for a fitted mean in the same terms as the design matrix. The vector has 1 for the constant coefficient, the combination of 1, 0, and -1 that defines the factor levels for the term, and 0 for any factor levels that are not in the term. For the highest-level interaction in the model, all of the elements in the vector define factor levels and the standard error of the mean equals the standard error of the fitted value.

### Notation

TermDescription
s2mean square error
Xdesign matrix
X'transpose of the design matrix
(X'X)−1inverse of the X'X matrix
x0vector that defines the factor levels for the fitted mean
x'0transpose of the vector that defines the factor levels for the fitted mean

## Standardized residual (Std Resid)

Standardized residuals are also called "internally Studentized residuals."

### Notation

TermDescription
ei i th residual
hi i th diagonal element of X(X'X)–1X'
s2 mean square error
Xdesign matrix
X'transpose of the design matrix
By using this site you agree to the use of cookies for analytics and personalized content.  Read our policy