StatBCS 6Regression 3 handout without solutions
Table of contents
- Statistics for Brain and Cognitive Sciences
- Polynomial terms
- Partial correlation
- SLR plus one dichotomous IV
1. Statistics for Brain and Cognitive Sciences
1.1 Extending the SLR
This section outlines the extension of the Simple Linear Regression (SLR) model, providing a foundational understanding for advanced statistical analyses in brain and cognitive sciences. The subsequent discussion delves into various curve-fitting methods and their implications for data interpretation 2.
1.2 Curve-fitting methods and their messages
Different curve-fitting methods convey distinct messages about the underlying data relationships and the researcher's analytical approach. The choice of method reflects assumptions about the data's structure and the intended interpretation of the model 3.
| Method | Implied Message |
|---|---|
| Linear | Basic regression performed |
| Quadratic | Curved relationship intentionally modeled |
| Logarithmic | Tapering-off effect observed |
| Exponential | Uncontrolled growth indicated |
| LOESS | Sophisticated, non-foundational approach |
| Logistic | Connecting two lines with mathematical rigor |
| Confidence interval | Acknowledging scientific difficulty and effort |
| Piecewise | Theory-driven data selection |
| Connecting lines | Excel's smooth lines feature used |
| Ad-hoc filter | Data cleanup based on an idea |
| House of cards | Model fits smoothly but is unstable upon extension |

📝 When a researcher uses a linear regression model, the implied message is that a basic regression has been performed, suggesting a straightforward, direct relationship between variables. Conversely, selecting an exponential fit communicates that the data exhibits an accelerating growth pattern, potentially indicating an uncontrolled increase in the measured phenomenon 3.
2. Polynomial terms
Polynomial terms extend the capabilities of linear regression models, such as Simple Linear Regression (SLR) and Multiple Linear Regression (MLR), to capture non-linear relationships between variables. While SLR and ANOVA typically follow the form Y=α+βX+ϵ, and MLR uses Y=β0+β1X1+β2X2+⋯+βpXp+ϵ, polynomial regression specifically incorporates continuous variables with degrees greater than one 5.
| Variable Nature | Regression Type |
|---|---|
| Continuous, degree one | Multiple Linear Regression (MLR) |
| Continuous, degree greater than one | Polynomial Regression |
| Categorical and continuous | ANCOVA |
| Representing interactions | Moderation |
| All categorical | Multi-way ANOVA |
2.1 Polynomial terms - quadratic
Quadratic polynomial terms are used to model relationships that exhibit a curvilinear, often U-shaped or inverted U-shaped, pattern. This approach is particularly useful when the effect of an independent variable on a dependent variable is not monotonic 6.
- Biological applications: Certain brain regions, such as the ventral temporal cortex (VTC), show a quadratic relationship in the mean square successive difference (MSSD) of the BOLD signal across the lifespan, with high MSSD in middle age and lower MSSD in younger and older age 6.
- Cognitive function: Prefrontal dopamine and D1DR signaling are proposed to have an 'inverted U-shaped' dynamic, where optimal levels are associated with peak cognitive function 7.

📝 The relationship between prefrontal dopamine levels and working memory performance often follows an inverted U-shaped curve, indicating that both too little and too much dopamine can impair performance, with an optimal range for peak function 7.
2.2 Polynomial terms - cubic
Cubic polynomial terms allow for more complex, S-shaped or W-shaped relationships, capturing inflections in the data that quadratic models cannot. This is particularly relevant in fields where phenomena exhibit multiple turning points 8.
- Human-robot interaction: The "Uncanny Valley" phenomenon, where imperfect human-likeness in robots can provoke dislike, is hypothesized to follow a cubic polynomial relationship with human-likeness 8.

📝 In the Uncanny Valley, as robots become more human-like, likability increases, then sharply drops when they are "almost human" but not quite, before rising again when they achieve near-perfect human resemblance, illustrating a cubic relationship 8.
2.3 Polynomial terms - higher degrees
Polynomials of higher degrees (e.g., quartic, quintic) can model even more intricate non-linear patterns, capturing multiple peaks and troughs in a dataset. These are often employed when simpler polynomial forms do not adequately fit the observed data 9.
- Signal processing: A polynomial drift model can be utilized to account for signal fluctuations in BOLD time series data, which may arise from hardware instabilities or physiological factors 9.

📝 A quintic function (degree 5) can model highly complex signal drifts in fMRI data, capturing subtle, multi-inflectional changes over time that a linear or quadratic model would miss 9.
2.4 Quadratic term in SLR extension
Adding a quadratic term to a Simple Linear Regression (SLR) model transforms it into a polynomial regression of degree two: Y=α+β1X+β2X2+ϵ. In this formulation, X and X2 can be treated as distinct predictors, effectively making it a form of Multiple Linear Regression 10.
- Design matrix: The inclusion of X2 modifies the design matrix X in the matrix form of the regression equation, y=Xβ+e. The design matrix now includes a column for the original predictor X and another for X2 10.

📝 If we are modeling the effect of age on a cognitive score, and we suspect an inverted U-shaped relationship, we would include both
AgeandAge^2as predictors in the model. The coefficient forAge^2(β2) would indicate the curvature of this relationship 10.
2.5 Quadratic term calculations
The Ordinary Least Squares (OLS) solution for a quadratic regression model provides formulas for estimating the intercept (α^) and the slope coefficients (β^1, β^2). These coefficients are often referred to as partial regression coefficients because they represent the relationship between a predictor and the dependent variable while controlling for other predictors in the model 11.
- Intercept formula: The estimated intercept α^ is calculated as yˉ−β^1xˉ−β^2x2ˉ.
- Slope coefficients: The formulas for β^1 and β^2 involve terms related to the variances and covariances of X, X2, and Y, and are proportional to partial correlations 11.

📝 The formula for β^1 is given by sx2sx22−sxx22sxysx22−sx2ysxx2, which is proportional to the partial correlation rxy⋅x2, indicating the unique contribution of X to Y after accounting for X2 11.
3. Partial correlation
Partial correlation quantifies the linear relationship between two variables, X and Y, while statistically controlling for the influence of a third variable, Z. This method helps to discern direct relationships by removing the variance explained by the confounding variable 12.
3.1 Formula for partial correlation
The partial correlation coefficient, rxy⋅z, is calculated using the individual Pearson correlation coefficients between X, Y, and Z. This formula adjusts the observed correlation between X and Y by accounting for their respective correlations with Z 12.
rxy⋅z=1−rxz21−ryz2rxy−rxzryz

The interpretation of partial correlation can be understood through two extreme cases:
- Z is not a confounding variable: If Z is independent of both X and Y (i.e., rxz=0 and ryz=0), the partial correlation rxy⋅z simplifies to the original correlation rxy. This indicates that Z has no mediating or confounding effect on the relationship between X and Y.
- Z is a confounding variable: If the correlation between X and Y is entirely due to their shared relationship with Z (i.e., rxy=ryzrxz), then the partial correlation rxy⋅z becomes zero. This signifies a spurious correlation, where the apparent relationship between X and Y vanishes once Z is controlled for 12.
3.2 Spurious correlation
A spurious correlation occurs when two variables appear to be directly related, but their association is actually caused by a third, unobserved, or uncontrolled variable. Controlling for this confounding variable reveals that the direct relationship between the initial two variables is negligible or nonexistent 13.
📝 A classic example of spurious correlation is the observed positive relationship between ice cream sales and shark attacks. Both tend to increase during summer months. The confounding variable here is temperature or season; warmer weather leads to both more ice cream consumption and more swimming, thus increasing the likelihood of shark encounters. When temperature is controlled, the correlation between ice cream sales and shark attacks disappears.
3.3 Understanding the calculation of partial correlation
The calculation of partial correlation can be conceptualized through a residualization process using linear regression. This method isolates the unique variance of X and Y that is not explained by Z, and then correlates these independent components 14.
The process involves the following steps:
- Assume centered variables: For simplicity, variables X, Y, and Z are assumed to be centered, meaning their means are subtracted, which eliminates the need for an intercept in the regression models.
- Regress Z on X: A linear regression is performed with X as the dependent variable and Z as the independent variable (X=βxzZ+exz). The residuals, exz, represent the variation in X that is uncorrelated with Z.
- Regress Z on Y: Similarly, a linear regression is performed with Y as the dependent variable and Z as the independent variable (Y=βyzZ+eyz). The residuals, eyz, represent the variation in Y that is uncorrelated with Z.
- Correlate residuals: The partial correlation rxy⋅z is then obtained by calculating the Pearson correlation coefficient between these two sets of residuals, exz and eyz 14.

3.4 Exercise 1: Proving the partial correlation result
Exercise 1 asks to prove that the correlation between the residuals exz and eyz is equivalent to the partial correlation formula rxy⋅z. This exercise tests the understanding of how residualization in regression relates to the algebraic definition of partial correlation 14.
3.5 Centering a quadratic relation
Centering variables is a technique used to improve the interpretability of regression coefficients, particularly in models involving quadratic terms. It involves subtracting the mean of a variable from each observation 16.
- Interpretation of β2: In a quadratic model Y=α′+β1′(X−Xˉ)+β2(X−Xˉ)2+ϵ, a positive β2 indicates a convex curve (cup-shaped), while a negative β2 indicates a concave curve (hill-shaped).
- Interpretation of β1: The coefficient β1 represents the rate of change of Y when X=0. If X=0 is outside the range of the observed data, this interpretation can be problematic. Centering X addresses this by making the intercept α′ represent the expected value of Y at the mean of X.
- Centering benefits: Centering X reduces the correlation between the linear term (X−Xˉ) and the quadratic term (X−Xˉ)2, which can mitigate multicollinearity issues in the model.
- Parameter rescaling: When X is centered, the original parameters α and β1 are rescaled to α′ and β1′ as follows:
- α′=α+β1Xˉ+β2Xˉ2
- β1′=β1+2β2Xˉ 16.
3.6 ANCOVA and moderation
Analysis of Covariance (ANCOVA) and moderation are statistical techniques used to analyze relationships between variables, often involving a covariate or an interaction term. ANCOVA is used when the trends of lines are parallel, indicating that the covariate shifts the intercept but not the slope of the relationship.
Moderation, or interaction, occurs when the trends are not parallel, meaning the effect of one variable on another depends on the level of a third variable 17.
📝 Research by Mellick et al. found that lower right IFG/insula activation is associated with higher impulsivity (Barratt Impulsiveness Scale), maximum number of alcohol drinks consumed on a single occasion, and scores on the Obsessive-Compulsive Drinking Scale. This suggests a relationship between brain activity and various measures of impulsivity and drinking behavior 17 .
4. SLR plus one dichotomous IV
4.1 Extending Simple Linear Regression with a Dichotomous Variable
Simple Linear Regression (SLR) can be extended by incorporating a dichotomous independent variable (IV), denoted as D, using dummy coding. This approach forms the smallest possible ANCOVA model, expressed as Y=α+β1X+β2D+ϵ.
In this model, X represents a continuous covariate, D is the dichotomous variable, and Y is the dependent variable. The model can also be viewed as a Multiple Linear Regression (MLR) where X1=X and X2=D 18.
The inclusion of D primarily affects the intercept of the SLR for the two groups defined by D.
| Variable Level | Regression Equation | Expected Value (at X=0) | Parameter Meaning |
|---|---|---|---|
| D = 0 | Y=α+β1X+ϵ | μ0,0=α | α=μ0,0 |
| D = 1 | Y=(α+β2)+β1X+ϵ | μ0,1=α+β2 | β2=μ0,1−μ0,0 |
- Coefficient interpretation: α represents the average expected value of Y when X=0 for the reference group (D=0), while β2 quantifies the difference in the intercept between the treatment group (D=1) and the reference group (D=0) when X=0.
- Main effects: These coefficients represent main effects, indicating the average effect across all levels of the other variable, assuming the effect holds for all X values.
- Parallel lines: The model implies that the regression lines for the two groups are parallel, as the slope β1 remains constant, and the intercept for D=1 is simply shifted by β2 from the intercept for D=0 20.
- Centering: If X=0 is not a meaningful reference point, centering the covariate X around its mean Xˉ can be performed, leading to a rescaled intercept α′=α+β1Xˉ in the model Y=α′+β1(X−Xˉ)+β2D+ϵ 19.
4.2 Simpson’s paradox
Simpson's paradox illustrates a phenomenon where a trend observed in aggregated data disappears or reverses when the data is disaggregated into subgroups. This can lead to incorrect conclusions if the grouping variable is not considered in the analysis 21.

4.3 ANCOVA table for a dichotomous IV
The ANCOVA table provides a framework for evaluating the contributions of the covariate X and the dichotomous variable D to the total variance in Y. For a dichotomous variable D with kD levels (where kD=2 for a single dichotomous variable), the table is structured to assess the sequential effects 22.
| Source of Variation | df | SS | MS | F |
|---|---|---|---|---|
| Covariate X | 1 | SSX | MSX=1SSX | F=MSResMSX |
| Effect of D | kD−1 | SSD | MSD=kD−1SSD | F=MSResMSD |
| Residual error | n−kD−1 | SSRes | MSRes=n−kD−1SSRes | — |
| Total | n−1 | SSTot | — | — |
| Effect of X \times D | (kD−1)∗1 | SSX×D | MSX×D=kD−1SSX×D | F=MSResMSX×D |
- Adjusted effect: The effect of the covariate X is estimated prior to the effect of D to determine the adjusted effect of D, which accounts for the influence of X.
- Multiple regression perspective: From an MLR standpoint, there are p=1+(kD−1)=kD predictors. Consequently, the degrees of freedom for regression (dfReg) are kD, and for residual error (dfRes) are n−p−1=n−kD−1 22.
4.4 OLS solution for SLR with a dichotomous IV
The Ordinary Least Squares (OLS) solution for estimating coefficients in an SLR model with one dichotomous IV is more complex than for a simple SLR. The estimated coefficients are given by specific formulas 23.
| Coefficient | Formula |
|---|---|
| α^ | yˉ0−β^1xˉ0 |
| β^2 | (yˉ1−β^1xˉ1)−α^ |
| β^1 | sx,02+sx,12sxy,0+sxy,1=rxy⋅Dsxsy1−rxD21−ryD2 |
- Correlation types: rxy is the Pearson correlation, while rxD and ryD are point-biserial correlations due to D being dichotomous.
- Intercept estimation: The intercepts α and α+β2 are estimated similarly to a standard SLR.
- Pooled variances: β1 utilizes pooled covariances and variances. In unbalanced designs, this pooling requires a weighted average.
- Partial regression coefficient: β1 is a partial regression coefficient, directly proportional to the partial correlation rxy⋅D between X and Y, controlling for D 23.

4.5 Interaction as moderation
Interaction, also known as moderation, occurs when the effect of one independent variable on the dependent variable changes depending on the level of another independent variable. In the context of SLR with a dichotomous IV, an interaction model takes the form Y=α+β1X+β2D+β3XD+ϵ.
- Interaction effect: β3 represents the interaction effect, indicating that D modifies the effect of X on Y. This means D acts as a moderator.
- Theoretical interpretation: The determination of which variable moderates which is often guided by theoretical considerations.
- Moderator types: Moderators can be either categorical or continuous variables.
- Centering effects: If centering is applied to X, the parameters in the interaction model will rescale. The model becomes Y=α′+β1(X−Xˉ)+β2′D+β3(X−Xˉ)D+ϵ, where α′=α+β1Xˉ and β2′=β2+β3Xˉ 24.
- Matrix representation: For a balanced design, the model can be expressed in matrix form as y=Xβ+e. y1y2⋮yn−1yn=11⋮11x1x2⋮xn−1xn00⋮1100⋮xn−1xnαβ1β2β3+e1e2⋮en−1en 25.
4.6 Continuous and dichotomous IVs with interaction
When an interaction term is included, the dichotomous variable D can change both the intercept and the slope of the SLR. This effectively results in two distinct SLR equations for the two groups defined by D 26.
| Variable Level | Regression Equation | Expected Value (at X=0) | Parameter Meaning (Intercept) | Parameter Meaning (Slope) |
|---|---|---|---|---|
| D = 0 | Y=α+β1X+ϵ | μ0,0=α | α=μ0,0 | β1=Var(X)0Cov(X,Y)0 |
| D = 1 | Y=(α+β2)+(β1+β3)X+ϵ | μ0,1=α+β2 | α+β2=μ0,1 | β1+β3=Var(X)1Cov(X,Y)1 |
- Coefficient shifts: β2 and β3 represent the shifts in the intercept (α) and slope (β1), respectively, between the two groups.
- Separate SLRs: The model essentially fits two separate SLR lines, each with its own intercept and slope, for the D=0 and D=1 groups27.
- Estimated coefficients: The estimated coefficients are derived from the group-specific means, covariances, and variances 26.
| Coefficient | Formula |
|---|---|
| α^ | yˉ0−β^1xˉ0 |
| β^1 | sx,02sxy,0 |
| β^2 | (yˉ1−β^1xˉ1)−α^ |
| β^3 | sx,12sxy,1−β^1 |

📝 For the group where D=0, the regression equation is Y=α+β1X+ϵ, with an expected value at X=0 of μ0,0=α. For the group where D=1, the equation is Y=(α+β2)+(β1+β3)X+ϵ, with an expected value at X=0 of μ0,1=α+β2 26.
4.7 ANCOVA table with interaction effect
When an interaction term (X×D) is included in the model, the ANCOVA table expands to account for this additional source of variation. This table is used to assess the significance of the covariate, the dichotomous variable, and their interaction 28.
See the table in section 4.3.
- Adjusted effects: The covariate X is estimated first to adjust the effects of D and the interaction term.
- Multiple regression perspective: In an MLR context, there are p=1+(kD−1)+(kD−1)∗1=2kD−1 predictors. Thus, dfReg=2kD−1 and dfRes=n−p−1=n−2kD 28.
4.8 Model selection strategies
Selecting the most appropriate model from a set of candidate models is a critical step in statistical analysis. Various models, ranging from a simple mean model to complex moderation models, can be considered 29.
| Model Type | Equation |
|---|---|
| Mean model | Y=α+ϵ |
| One-way ANOVA | Y=α+βD+ϵ |
| Simple Linear Regression | Y=α+βX+ϵ |
| Quadratic Regression | Y=α+β1X+β2X2+ϵ |
| One-way ANCOVA | Y=α+β1X+β2D+ϵ |
| Moderation | Y=α+β1X+β2D+β3XD+ϵ |
- Evaluation criteria: Several approaches can be used to determine if adding terms improves a model:
- Coefficient of determination (R2): An increase in R2 is indicative but not solely sufficient.
- p-values: Associated with t-tests, p-values provide evidence for the significance of individual coefficients.
- F-test: Analysis of variance offers an F-test for comparing nested models.
- Fit indexes: Information criteria such as Akaike Information Criterion (AIC) and Bayesian Information Criterion (BIC) decrease with better model fit 29.
4.9 Stepwise procedures for model selection
For models with natural hierarchical nesting, stepwise procedures can be employed to systematically add or remove predictors.
- Backward Elimination:
- Starts with all predictors in the model.
- Removes predictors one at a time if their p-value is higher than a predefined "p-to-remove" threshold (αcrit).
- The model is refitted after each removal.
- The process stops when all remaining p-values are below αcrit.
- Forward Selection:
- Begins with no predictors in the model.
- Adds predictors one at a time, selecting the one with the lowest p-value below αcrit.
- The process repeats until no more predictors can be added that meet the significance criterion.
- Stepwise Regression: Combines elements of both backward elimination and forward selection.
- Complementary tools: These procedures can be enhanced by comparing F-tests and fit indexes like AIC and BIC 30.
4.10 Limitations of model selection approaches
Despite their utility, stepwise model selection procedures and fit indexes have significant limitations that must be considered.
- Suboptimal models: Adding terms one at a time may lead to missing an optimal model configuration.
- Overstated significance: Removing non-significant predictors can artificially inflate the significance of the remaining variables.
- Predictive relevance: Variables deemed non-significant statistically might still hold predictive value and should not be discarded solely based on p-values.
- Multiple testing problem: Each step in algorithmic procedures involves a decision, leading to a multiple testing problem that can increase Type I error rates.
- Theoretical disconnect: Model selection should always be guided by theoretical considerations, not solely by algorithmic outcomes.
- Model size: Stepwise selection often yields models that are smaller than ideal for robust prediction.
- Order dependence: F-tests for comparing variance proportions only test pairs of models, and ANOVA results can be sensitive to the order in which terms are tested.
- Relative fit: AIC and BIC are relative fit indexes, meaning they are useful for comparing models but do not provide an absolute measure of model validity 31.
4.11 Two-way ANOVA34
A two-way ANOVA is a statistical model used when there are two categorical independent variables (factors) and one continuous dependent variable. The model includes main effects for each factor and an interaction effect between them.
- Model equation: For two categorical variables A and B, the two-way ANOVA model is Y=α+β1A+β2B+β3AB+ϵ, where AB represents the interaction term.
- Dummy coding: If A and B are dummy variables, there are four possible cases, each with a specific regression equation and expected value 33.
| Variable Level | Regression Equation | Expected Value | Parameter Meaning |
|---|---|---|---|
| A = 0, B = 0 | Y=α+ϵ | μ0,0=α | α=μ0,0 |
| A = 1, B = 0 | Y=α+β1+ϵ | μ1,0=α+β1 | β1=μ1,0−μ0,0 |
| A = 0, B = 1 | Y=α+β2+ϵ | μ0,1=α+β2 | β2=μ0,1−μ0,0 |
| A = 1, B = 1 | Y=α+β1+β2+β3+ϵ | μ1,1=α+β1+β2+β3 | β3=μ0,0+μ1,1−μ1,0−μ0,1 |
- Parameter interpretation:
- α=μ0,0 is the mean in the reference cell (A=0, B=0).
- β1=μ1,0−μ0,0 is the simple effect of A at B=0.
- β2=μ0,1−μ0,0 is the simple effect of B at A=0.
- β3=(μ1,1−μ0,1)−(μ1,0−μ0,0) represents a difference of differences, quantifying the interaction effect 34.
- Simple vs. main effects: β1 and β2 are simple effects, representing differences between levels of one factor at a specific level of the other factor, rather than main effects (average effects across all levels of the other factor) 33.

📝 If A=0 and B=0, the expected value is μ0,0=α. If A=1 and B=0, the expected value is μ1,0=α+β1, meaning β1=μ1,0−μ0,0 is the simple effect of A at B=0 33.
4.12 Exercise 2: Deviation coding in two-way ANOVA
This exercise requires calculating the solution and interpreting the coefficients using a design matrix for deviation coding in a two-way ANOVA. This tests the understanding of how different coding schemes (e.g., dummy vs. deviation) affect the interpretation of coefficients in ANOVA models 35.
4.13 Two-way ANOVA table for general case
The general ANOVA table for a two-way design with factors A and B, having kA and kB levels respectively, provides a comprehensive breakdown of variance sources, including main effects and interaction effects 36.
| Source of Variation | df | SS | MS | F |
|---|---|---|---|---|
| Effect of A | kA−1 | SSA | MSA=kA−1SSA | F=MSResMSA |
| Effect of B | kB−1 | SSB | MSB=kB−1SSB | F=MSResMSB |
| Effect of A \times B | (kA−1)∗(kB−1) | SSA×B | MSA×B=(kA−1)(kB−1)SSA×B | F=MSResMSA×B |
| Residual error | n−kAkB | SSRes | MSRes=n−kAkBSSRes | — |
| Total | n−1 | SSTot | — | — |
- Multiple regression perspective: From an MLR viewpoint, there are p=(kA−1)+(kB−1)+(kA−1)∗(kB−1)=kAkB−1 predictors. Consequently, dfReg=kAkB−1 and dfRes=n−p−1=n−kAkB 36.
4.14 Additive two-way ANOVA
An additive two-way ANOVA model is a simplified version of the interaction model where the interaction term (β3) is removed, implying that the effects of factors A and B are independent and do not modify each other. The model is expressed as Y=α+β1A+β2B+ϵ.
- Dummy coding: With dummy coding, the expected values for the four cases demonstrate a strong parallelism constraint, where μ1,1+μ0,0=μ0,1+μ1,0 37. {"header": ["Variable Level", "Regression Equation", "Expected Value", "Parameter Meaning", "rows": [["A = 0, B = 0", "Y=α+ϵ", "μ0,0=α", "α=μ0,0", ["A = 1, B = 0", "Y=α+β1+ϵ", "μ1,0=α+β1", "β1=μ1,0−μ0,0", ["A = 0, B = 1", "Y=α+β2+ϵ", "μ0,1=α+β2", "β2=μ0,1−μ0,0", ["A = 1, B = 1", "Y=α+β1+β2+ϵ", "$\mu_{1,1} =
4.15 Two-way ANOVA: Main effects only
In a two-way ANOVA with only main effects, the assumption of strong parallelism implies that the effect of one factor is consistent across all levels of the other factor. This allows for a straightforward interpretation of coefficients as main effects.

- Coefficient interpretation:
- α=μ0,0: Represents the mean in the reference cell.
- β1=μ1,0−μ0,0=μ1,1−μ0,1: Denotes the distance from A=0 to A=1, independent of B.
- β2=μ0,1−μ0,0=μ1,1−μ1,0: Denotes the distance from B=0 to B=1, independent of A 38.
- OLS solutions for dummy coding:
- α=μA=0+μB=0−μ: Represents a difference of means.
- β1=μA=1−μA=0: Represents the main effect of A.
- β2=μB=1−μB=0: Represents the main effect of B 40.

📝 If μ0,0 is the mean in the reference cell, then β1=μ1,0−μ0,0 represents the distance from A=0 to A=1, independent of B 38.
4.16 Exercise 3
This exercise requires calculating the table and OLS solution for coefficients using deviation coding and demonstrating that these solutions consistently coincide 40.
4.17 ANOVA table
The ANOVA table for a general case with factors A and B having kA and kB levels, respectively, provides a structured summary of the variance decomposition. From a multiple regression perspective, the number of predictors p is (kA−1)+(kB−1)=kA+kB−2 41.
See the table in section 4.13.
- Degrees of freedom:
- dfReg=p=kA+kB−2.
- dfRes=n−p−1=n−(kA+kB−1) 41.
4.18 ANOVA types
Different coding schemes and unbalanced or complex factorial designs can significantly influence the construction of sums of squares (SS) and, consequently, the F-tests. The order of variables can also affect SS construction if multiple independent variables share covariation with the dependent variable.
Orthogonal designs and coding schemes are designed to remove such covariation. To address these complexities, three distinct types of sums of squares have been developed 42.
📝 If multiple independent variables share covariation with the dependent variable, the order of variables can affect the construction of the sums of squares (SSs) 42.
4.19 ANOVA type I
Type I ANOVA, also known as the 'sequential way', employs sequential model comparisons that adhere to the principle of marginality, where higher-order terms are entered only after all corresponding lower-order terms.
- Characteristics:
- Sequential model comparisons: Conforms to the principle of marginality.
- Order dependence: Results depend on the order of model terms, meaning SSReg=SSA+SSB∣A+SSA×B∣A,B might differ from SSReg=SSB+SSA∣B+SSA×B∣A,B.
- Summation of effects: Individual effects (SSEffect) sum to the regression effect (SSReg).
- Coding scheme: No single best or suggested coding scheme.
- Application: Type I ANOVA is the default in R and is optimal for sequential testing, such as with polynomial terms or covariance variables 43.
4.20 ANOVA type II
Type II ANOVA, referred to as the 'hierarchical way', tests model comparisons that conform to the principle of marginality, similar to Type I, but controls for terms at the same order. This involves estimating SSA∣B and SSB∣A while initially ignoring the interaction effect A×B, followed by estimating SSA×B∣A,B.
- Characteristics:
- Marginality principle: Adheres to the principle of marginality, controlling for terms at the same order.
- Order independence: Does not depend on the order of model terms.
- Summation of effects: Individual effects (SSEffect) might not sum to SSReg.
- Application: Best utilized in the absence of significant interactions, as it allows for more robust testing of main effects 44.

4.21 ANOVA type III
Type III ANOVA, known as the 'partial way', tests model comparisons that can violate the principle of marginality when evaluating main effects. This means higher-order terms are considered alongside lower-order terms, estimating SSA∣B,A×B, SSB∣A,A×B, and SSA×B∣A,B.
- Characteristics:
- Marginality violation: Tests main effects by considering higher-order terms alongside lower-order terms.
- Regression model mimicry: Mimics the output of the regression model and includes a test for an intercept term.
- Coding scheme: Hypotheses should only be tested using zero-sum or orthogonal coding (e.g., Deviation coding, Helmert).
- Application: Most suitable in the presence of significant interactions, noting that the highest-order term will coincide across all ANOVA types 45.

4.22 Eta squared η2 is a smaller R2
Effect size measures quantify the proportion of variance explained by an effect. These include Eta squared (η2), Partial Eta squared (ηP2), and Generalized Eta squared, which accounts for non-manipulable predictors.
- Formulas for effect size:
- Eta squared: η2=SSTotSSEffect
- Partial Eta squared: ηP2=SSEffect+SSResSSEffect 46.
| ANOVA Type | Intercept | Effect of A | Effect of B | Effect of A × B | Sum to SSReg |
|---|---|---|---|---|---|
| Type I | NO | SSA | SSB∣A | SSA×B∣A,B | YES |
| Type II | NO | SSA∣B | SSB∣A | SSA×B∣A,B | Might not |
| Type III | YES | SSA∣B,A×B | SSB∣A,A×B | SSA×B∣A,B | Might not |
- Overall variance explained: η2=SSTotSSReg=R2 46.

4.23 ANOVA Mixed-Design
A mixed-design ANOVA, also known as a split-plot ANOVA, is employed when both between-subjects and within-subjects effects are present in a model. The total sum of squares is partitioned into these two components.
- Partitioning of total sum of squares: SSTot=SSBetween−Subjects+SSWithin−Subjects.
- Between-subjects component: Accounts for the main effect of the between-subjects factor and individual differences among participants within the same between-subjects condition.
- SSBetween−Subjects=SSBetween+SSError(Between).
- Within-subjects component: Accounts for the main effect of the within-subjects factor, its interaction with the between-subjects factor, and unexplained variability specific to the within-subjects factor and its interaction with subjects.
- SSWithin−Subjects=SSWithin+SSInteraction+SSError(Within) 47.
- Mixed-design ANOVA table: For a design with factor A (between, kA groups) and factor B (within, kB levels), with n participants per group, the total number of observations is N=nkAkB 48.
| Source | df | SS | MS | F |
|---|---|---|---|---|
| Factor A | kA−1 | SSA | MSA=kA−1SSA | F=MSS(A)MSA |
| Error Between | kA(n−1) | SSS(A) | MSS(A)=kA(n−1)SSS(A) | — |
| Total between | kAn−1 | SSTotBtw | — | — |
| Factor B | kB−1 | SSB | MSB=kB−1SSB | F=MSB×S(A)MSB |
| Interaction A × B | (kA−1)(kB−1) | SSA×B | MSA×B=(kA−1)(kB−1)SSA×B | F=MSB×S(A)MSA×B |
| Error Within | kA(n−1)(kB−1) | SSB×S(A) | MSB×S(A)=kA(n−1)(kB−1)SSB×S(A) | — |
| Total Within | nkA(kB−1) | SSTotWith | Not computed | — |
| Grand Total | N−1=nkAkB−1 | SSTot | — | — |
© 2026 Maeve. All rights reserved. This content is protected by copyright.

