StatBCS 6Regression 3 handout without solutions

Table of contents

  1. Statistics for Brain and Cognitive Sciences
  2. Polynomial terms
  3. Partial correlation
  4. 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.

MethodImplied Message
LinearBasic regression performed
QuadraticCurved relationship intentionally modeled
LogarithmicTapering-off effect observed
ExponentialUncontrolled growth indicated
LOESSSophisticated, non-foundational approach
LogisticConnecting two lines with mathematical rigor
Confidence intervalAcknowledging scientific difficulty and effort
PiecewiseTheory-driven data selection
Connecting linesExcel's smooth lines feature used
Ad-hoc filterData cleanup based on an idea
House of cardsModel fits smoothly but is unstable upon extension

This chart displays various curve-fitting methods with corresponding scatter plots and fitted lines, illustrating different approaches to data analysis.

📝 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+ϵY = \alpha + \beta X + \epsilon, and MLR uses Y=β0+β1X1+β2X2+⋯+βpXp+ϵY = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \dots + \beta_p X_p + \epsilon, polynomial regression specifically incorporates continuous variables with degrees greater than one 5.

Variable NatureRegression Type
Continuous, degree oneMultiple Linear Regression (MLR)
Continuous, degree greater than onePolynomial Regression
Categorical and continuousANCOVA
Representing interactionsModeration
All categoricalMulti-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.

This scatter plot visualizes the relationship between prefrontal dopamine/D1DR levels and working memory performance, showing an inverted U-shaped curve for dopamine and a downward trend for D1DR.

📝 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.

This chart illustrates the Uncanny Valley phenomenon, plotting likability against human-likeness, showing a dip in likability for near-human but not perfectly human entities.

📝 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.

Illustrations of polynomial functions of increasing degrees from 0 to 5.

📝 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+ϵY = \alpha + \beta_1 X + \beta_2 X^2 + \epsilon. In this formulation, XX and X2X^2 can be treated as distinct predictors, effectively making it a form of Multiple Linear Regression 10.

  • Design matrix: The inclusion of X2X^2 modifies the design matrix X\mathbf{X} in the matrix form of the regression equation, y=Xβ+e\mathbf{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{e}. The design matrix now includes a column for the original predictor XX and another for X2X^2 10.

Diagram illustrating the relationship between X, X squared, Y, and epsilon in a quadratic regression model.

📝 If we are modeling the effect of age on a cognitive score, and we suspect an inverted U-shaped relationship, we would include both Age and Age^2 as predictors in the model. The coefficient for Age^2 (β2\beta_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 (α^\hat{\alpha}) and the slope coefficients (β^1\hat{\beta}_1, β^2\hat{\beta}_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 α^\hat{\alpha} is calculated as yˉ−β^1xˉ−β^2x2ˉ\bar{y} - \hat{\beta}_1 \bar{x} - \hat{\beta}_2 \bar{x^2}.
  • Slope coefficients: The formulas for β^1\hat{\beta}_1 and β^2\hat{\beta}_2 involve terms related to the variances and covariances of XX, X2X^2, and YY, and are proportional to partial correlations 11.

Formulas for calculating the intercept and slope coefficients in a quadratic regression model.

📝 The formula for β^1\hat{\beta}_1 is given by sxysx22−sx2ysxx2sx2sx22−sxx22\frac{s_{xy}s^2_{x^2} - s_{x^2y}s_{xx^2}}{s^2_x s^2_{x^2} - s^2_{xx^2}}, which is proportional to the partial correlation rxy⋅x2r_{xy \cdot x^2}, indicating the unique contribution of XX to YY after accounting for X2X^2 11.

3. Partial correlation

Partial correlation quantifies the linear relationship between two variables, XX and YY, while statistically controlling for the influence of a third variable, ZZ. 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⋅zr_{xy \cdot z}, is calculated using the individual Pearson correlation coefficients between XX, YY, and ZZ. This formula adjusts the observed correlation between XX and YY by accounting for their respective correlations with ZZ 12.

rxy⋅z=rxy−rxzryz1−rxz21−ryz2r_{xy \cdot z} = \frac{r_{xy} - r_{xz}r_{yz}}{\sqrt{1 - r^2_{xz}}\sqrt{1 - r^2_{yz}}} Formula for partial correlation between X and Y, controlling for Z.

The interpretation of partial correlation can be understood through two extreme cases:

  • Z is not a confounding variable: If ZZ is independent of both XX and YY (i.e., rxz=0r_{xz} = 0 and ryz=0r_{yz} = 0), the partial correlation rxy⋅zr_{xy \cdot z} simplifies to the original correlation rxyr_{xy}. This indicates that ZZ has no mediating or confounding effect on the relationship between XX and YY.
  • Z is a confounding variable: If the correlation between XX and YY is entirely due to their shared relationship with ZZ (i.e., rxy=ryzrxzr_{xy} = r_{yz}r_{xz}), then the partial correlation rxy⋅zr_{xy \cdot z} becomes zero. This signifies a spurious correlation, where the apparent relationship between XX and YY vanishes once ZZ 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. This line chart shows a spurious correlation between ice cream sales and shark attacks, with both metrics peaking in the summer months.

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 XX and YY that is not explained by ZZ, and then correlates these independent components 14.

The process involves the following steps:

  • Assume centered variables: For simplicity, variables XX, YY, and ZZ 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 XX as the dependent variable and ZZ as the independent variable (X=βxzZ+exzX = \beta_{xz}Z + e_{xz}). The residuals, exze_{xz}, represent the variation in XX that is uncorrelated with ZZ.
  • Regress Z on Y: Similarly, a linear regression is performed with YY as the dependent variable and ZZ as the independent variable (Y=βyzZ+eyzY = \beta_{yz}Z + e_{yz}). The residuals, eyze_{yz}, represent the variation in YY that is uncorrelated with ZZ.
  • Correlate residuals: The partial correlation rxy⋅zr_{xy \cdot z} is then obtained by calculating the Pearson correlation coefficient between these two sets of residuals, exze_{xz} and eyze_{yz} 14. This diagram illustrates the process of calculating partial correlation between variables X and Y while controlling for variable Z.

3.4 Exercise 1: Proving the partial correlation result

Exercise 1 asks to prove that the correlation between the residuals exze_{xz} and eyze_{yz} is equivalent to the partial correlation formula rxy⋅zr_{xy \cdot 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\beta_2: In a quadratic model Y=α′+β1′(X−Xˉ)+β2(X−Xˉ)2+ϵY = \alpha' + \beta'_1(X - \bar{X}) + \beta_2(X - \bar{X})^2 + \epsilon, a positive β2\beta_2 indicates a convex curve (cup-shaped), while a negative β2\beta_2 indicates a concave curve (hill-shaped).
  • Interpretation of β1\beta_1: The coefficient β1\beta_1 represents the rate of change of YY when X=0X=0. If X=0X=0 is outside the range of the observed data, this interpretation can be problematic. Centering XX addresses this by making the intercept α′\alpha' represent the expected value of YY at the mean of XX.
  • Centering benefits: Centering XX reduces the correlation between the linear term (X−Xˉ)(X - \bar{X}) and the quadratic term (X−Xˉ)2(X - \bar{X})^2, which can mitigate multicollinearity issues in the model.
  • Parameter rescaling: When XX is centered, the original parameters α\alpha and β1\beta_1 are rescaled to α′\alpha' and β1′\beta'_1 as follows:
  • α′=α+β1Xˉ+β2Xˉ2\alpha' = \alpha + \beta_1\bar{X} + \beta_2\bar{X}^2
  • β1′=β1+2β2Xˉ\beta'_1 = \beta_1 + 2\beta_2\bar{X} 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 . Three scatter plots showing the relationship between right IFG/insular signal change and different measures of impulsivity and drinking behavior.

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 DD, using dummy coding. This approach forms the smallest possible ANCOVA model, expressed as Y=α+β1X+β2D+ϵY = \alpha + \beta_1X + \beta_2D + \epsilon.

In this model, XX represents a continuous covariate, DD is the dichotomous variable, and YY is the dependent variable. The model can also be viewed as a Multiple Linear Regression (MLR) where X1=XX_1 = X and X2=DX_2 = D 18.

The inclusion of DD primarily affects the intercept of the SLR for the two groups defined by DD.

Variable LevelRegression EquationExpected Value (at X=0)Parameter Meaning
D = 0Y=α+β1X+ϵY = \alpha + \beta_1X + \epsilonμ0,0=α\mu_{0,0} = \alphaα=μ0,0\alpha = \mu_{0,0}
D = 1Y=(α+β2)+β1X+ϵY = (\alpha + \beta_2) + \beta_1X + \epsilonμ0,1=α+β2\mu_{0,1} = \alpha + \beta_2β2=μ0,1−μ0,0\beta_2 = \mu_{0,1} - \mu_{0,0}
  • Coefficient interpretation: α\alpha represents the average expected value of YY when X=0X=0 for the reference group (D=0D=0), while β2\beta_2 quantifies the difference in the intercept between the treatment group (D=1D=1) and the reference group (D=0D=0) when X=0X=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 XX values.
  • Parallel lines: The model implies that the regression lines for the two groups are parallel, as the slope β1\beta_1 remains constant, and the intercept for D=1D=1 is simply shifted by β2\beta_2 from the intercept for D=0D=0 20.
  • Centering: If X=0X=0 is not a meaningful reference point, centering the covariate XX around its mean Xˉ\bar{X} can be performed, leading to a rescaled intercept α′=α+β1Xˉ\alpha' = \alpha + \beta_1\bar{X} in the model Y=α′+β1(X−Xˉ)+β2D+ϵY = \alpha' + \beta_1(X - \bar{X}) + \beta_2D + \epsilon 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. Two scatter plots illustrating Simpson's paradox, showing how regression lines can change direction when data is aggregated versus when it is separated into groups.

4.3 ANCOVA table for a dichotomous IV

The ANCOVA table provides a framework for evaluating the contributions of the covariate XX and the dichotomous variable DD to the total variance in YY. For a dichotomous variable DD with kDk_D levels (where kD=2k_D=2 for a single dichotomous variable), the table is structured to assess the sequential effects 22.

Source of VariationdfSSMSF
Covariate X1SSXSS_XMSX=SSX1MS_X = \frac{SS_X}{1}F=MSXMSResF = \frac{MS_X}{MS_{Res}}
Effect of DkD−1k_D - 1SSDSS_DMSD=SSDkD−1MS_D = \frac{SS_D}{k_D-1}F=MSDMSResF = \frac{MS_D}{MS_{Res}}
Residual errorn−kD−1n - k_D - 1SSResSS_{Res}MSRes=SSResn−kD−1MS_{Res} = \frac{SS_{Res}}{n-k_D-1}—
Totaln−1n - 1SSTotSS_{Tot}——
Effect of X \times D(kD−1)∗1(k_D - 1) \ast 1SSX×DSS_{X \times D}MSX×D=SSX×DkD−1MS_{X \times D} = \frac{SS_{X \times D}}{k_D-1}F=MSX×DMSResF = \frac{MS_{X \times D}}{MS_{Res}}
  • Adjusted effect: The effect of the covariate XX is estimated prior to the effect of DD to determine the adjusted effect of DD, which accounts for the influence of XX.
  • Multiple regression perspective: From an MLR standpoint, there are p=1+(kD−1)=kDp = 1 + (k_D - 1) = k_D predictors. Consequently, the degrees of freedom for regression (dfRegdf_{Reg}) are kDk_D, and for residual error (dfResdf_{Res}) are n−p−1=n−kD−1n - p - 1 = n - k_D - 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.

CoefficientFormula
α^\hat{\alpha}yˉ0−β^1xˉ0\bar{y}_0 - \hat{\beta}_1\bar{x}_0
β^2\hat{\beta}_2(yˉ1−β^1xˉ1)−α^(\bar{y}_1 - \hat{\beta}_1\bar{x}_1) - \hat{\alpha}
β^1\hat{\beta}_1sxy,0+sxy,1sx,02+sx,12=rxy⋅Dsysx1−ryD21−rxD2\frac{s_{xy,0} + s_{xy,1}}{s^2_{x,0} + s^2_{x,1}} = r_{xy \cdot D} \frac{s_y}{s_x} \sqrt{\frac{1-r^2_{yD}}{1-r^2_{xD}}}
  • Correlation types: rxyr_{xy} is the Pearson correlation, while rxDr_{xD} and ryDr_{yD} are point-biserial correlations due to DD being dichotomous.
  • Intercept estimation: The intercepts α\alpha and α+β2\alpha + \beta_2 are estimated similarly to a standard SLR.
  • Pooled variances: β1\beta_1 utilizes pooled covariances and variances. In unbalanced designs, this pooling requires a weighted average.
  • Partial regression coefficient: β1\beta_1 is a partial regression coefficient, directly proportional to the partial correlation rxy⋅Dr_{xy \cdot D} between XX and YY, controlling for DD 23. Formulas for estimating coefficients in SLR with one dichotomous IV.

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+ϵY = \alpha + \beta_1X + \beta_2D + \beta_3XD + \epsilon.

  • Interaction effect: β3\beta_3 represents the interaction effect, indicating that DD modifies the effect of XX on YY. This means DD 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 XX, the parameters in the interaction model will rescale. The model becomes Y=α′+β1(X−Xˉ)+β2′D+β3(X−Xˉ)D+ϵY = \alpha' + \beta_1(X - \bar{X}) + \beta'_2D + \beta_3(X - \bar{X})D + \epsilon, where α′=α+β1Xˉ\alpha' = \alpha + \beta_1\bar{X} and β2′=β2+β3Xˉ\beta'_2 = \beta_2 + \beta_3\bar{X} 24.
  • Matrix representation: For a balanced design, the model can be expressed in matrix form as y=Xβ+e\mathbf{y} = \mathbf{X}\boldsymbol{\beta} + \mathbf{e}. [y1y2⋮yn−1yn]=[1x1001x200⋮⋮⋮⋮1xn−11xn−11xn1xn][αβ1β2β3]+[e1e2⋮en−1en]\begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_{n-1} \\ y_n \end{bmatrix} = \begin{bmatrix} 1 & x_1 & 0 & 0 \\ 1 & x_2 & 0 & 0 \\ \vdots & \vdots & \vdots & \vdots \\ 1 & x_{n-1} & 1 & x_{n-1} \\ 1 & x_n & 1 & x_n \end{bmatrix} \begin{bmatrix} \alpha \\ \beta_1 \\ \beta_2 \\ \beta_3 \end{bmatrix} + \begin{bmatrix} e_1 \\ e_2 \\ \vdots \\ e_{n-1} \\ e_n \end{bmatrix} 25.

4.6 Continuous and dichotomous IVs with interaction

When an interaction term is included, the dichotomous variable DD 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 DD 26.

Variable LevelRegression EquationExpected Value (at X=0)Parameter Meaning (Intercept)Parameter Meaning (Slope)
D = 0Y=α+β1X+ϵY = \alpha + \beta_1X + \epsilonμ0,0=α\mu_{0,0} = \alphaα=μ0,0\alpha = \mu_{0,0}β1=Cov(X,Y)0Var(X)0\beta_1 = \frac{Cov(X,Y)_0}{Var(X)_0}
D = 1Y=(α+β2)+(β1+β3)X+ϵY = (\alpha + \beta_2) + (\beta_1 + \beta_3)X + \epsilonμ0,1=α+β2\mu_{0,1} = \alpha + \beta_2α+β2=μ0,1\alpha + \beta_2 = \mu_{0,1}β1+β3=Cov(X,Y)1Var(X)1\beta_1 + \beta_3 = \frac{Cov(X,Y)_1}{Var(X)_1}
  • Coefficient shifts: β2\beta_2 and β3\beta_3 represent the shifts in the intercept (α\alpha) and slope (β1\beta_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=0D=0 and D=1D=1 groups27.
  • Estimated coefficients: The estimated coefficients are derived from the group-specific means, covariances, and variances 26.
CoefficientFormula
α^\hat{\alpha}yˉ0−β^1xˉ0\bar{y}_0 - \hat{\beta}_1\bar{x}_0
β^1\hat{\beta}_1sxy,0sx,02\frac{s_{xy,0}}{s^2_{x,0}}
β^2\hat{\beta}_2(yˉ1−β^1xˉ1)−α^(\bar{y}_1 - \hat{\beta}_1\bar{x}_1) - \hat{\alpha}
β^3\hat{\beta}_3sxy,1sx,12−β^1\frac{s_{xy,1}}{s^2_{x,1}} - \hat{\beta}_1

This scatter plot displays two regression lines with different intercepts and slopes, representing two distinct groups.

📝 For the group where D=0D=0, the regression equation is Y=α+β1X+ϵY = \alpha + \beta_1X + \epsilon, with an expected value at X=0X=0 of μ0,0=α\mu_{0,0} = \alpha. For the group where D=1D=1, the equation is Y=(α+β2)+(β1+β3)X+ϵY = (\alpha + \beta_2) + (\beta_1 + \beta_3)X + \epsilon, with an expected value at X=0X=0 of μ0,1=α+β2\mu_{0,1} = \alpha + \beta_2 26.

4.7 ANCOVA table with interaction effect

When an interaction term (X×DX \times 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 XX is estimated first to adjust the effects of DD and the interaction term.
  • Multiple regression perspective: In an MLR context, there are p=1+(kD−1)+(kD−1)∗1=2kD−1p = 1 + (k_D - 1) + (k_D - 1) \ast 1 = 2k_D - 1 predictors. Thus, dfReg=2kD−1df_{Reg} = 2k_D - 1 and dfRes=n−p−1=n−2kDdf_{Res} = n - p - 1 = n - 2k_D 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 TypeEquation
Mean modelY=α+ϵY = \alpha + \epsilon
One-way ANOVAY=α+βD+ϵY = \alpha + \beta D + \epsilon
Simple Linear RegressionY=α+βX+ϵY = \alpha + \beta X + \epsilon
Quadratic RegressionY=α+β1X+β2X2+ϵY = \alpha + \beta_1 X + \beta_2 X^2 + \epsilon
One-way ANCOVAY=α+β1X+β2D+ϵY = \alpha + \beta_1 X + \beta_2 D + \epsilon
ModerationY=α+β1X+β2D+β3XD+ϵY = \alpha + \beta_1 X + \beta_2 D + \beta_3 XD + \epsilon
  • Evaluation criteria: Several approaches can be used to determine if adding terms improves a model:
  • Coefficient of determination (R2R^2): An increase in R2R^2 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\alpha_{crit}).
  • The model is refitted after each removal.
  • The process stops when all remaining p-values are below αcrit\alpha_{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\alpha_{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 AA and BB, the two-way ANOVA model is Y=α+β1A+β2B+β3AB+ϵY = \alpha + \beta_1A + \beta_2B + \beta_3AB + \epsilon, where ABAB represents the interaction term.
  • Dummy coding: If AA and BB are dummy variables, there are four possible cases, each with a specific regression equation and expected value 33.
Variable LevelRegression EquationExpected ValueParameter Meaning
A = 0, B = 0Y=α+ϵY = \alpha + \epsilonμ0,0=α\mu_{0,0} = \alphaα=μ0,0\alpha = \mu_{0,0}
A = 1, B = 0Y=α+β1+ϵY = \alpha + \beta_1 + \epsilonμ1,0=α+β1\mu_{1,0} = \alpha + \beta_1β1=μ1,0−μ0,0\beta_1 = \mu_{1,0} - \mu_{0,0}
A = 0, B = 1Y=α+β2+ϵY = \alpha + \beta_2 + \epsilonμ0,1=α+β2\mu_{0,1} = \alpha + \beta_2β2=μ0,1−μ0,0\beta_2 = \mu_{0,1} - \mu_{0,0}
A = 1, B = 1Y=α+β1+β2+β3+ϵY = \alpha + \beta_1 + \beta_2 + \beta_3 + \epsilonμ1,1=α+β1+β2+β3\mu_{1,1} = \alpha + \beta_1 + \beta_2 + \beta_3β3=μ0,0+μ1,1−μ1,0−μ0,1\beta_3 = \mu_{0,0} + \mu_{1,1} - \mu_{1,0} - \mu_{0,1}
  • Parameter interpretation:
  • α=μ0,0\alpha = \mu_{0,0} is the mean in the reference cell (A=0, B=0).
  • β1=μ1,0−μ0,0\beta_1 = \mu_{1,0} - \mu_{0,0} is the simple effect of A at B=0.
  • β2=μ0,1−μ0,0\beta_2 = \mu_{0,1} - \mu_{0,0} is the simple effect of B at A=0.
  • β3=(μ1,1−μ0,1)−(μ1,0−μ0,0)\beta_3 = (\mu_{1,1} - \mu_{0,1}) - (\mu_{1,0} - \mu_{0,0}) represents a difference of differences, quantifying the interaction effect 34.
  • Simple vs. main effects: β1\beta_1 and β2\beta_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. This line graph illustrates the interaction effects in a two-way ANOVA, showing how the dependent variable changes with Factor A at different levels of Factor B.

📝 If A=0 and B=0, the expected value is μ0,0=α\mu_{0,0} = \alpha. If A=1 and B=0, the expected value is μ1,0=α+β1\mu_{1,0} = \alpha + \beta_1, meaning β1=μ1,0−μ0,0\beta_1 = \mu_{1,0} - \mu_{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 kAk_A and kBk_B levels respectively, provides a comprehensive breakdown of variance sources, including main effects and interaction effects 36.

Source of VariationdfSSMSF
Effect of AkA−1k_A - 1SSASS_AMSA=SSAkA−1MS_A = \frac{SS_A}{k_A-1}F=MSAMSResF = \frac{MS_A}{MS_{Res}}
Effect of BkB−1k_B - 1SSBSS_BMSB=SSBkB−1MS_B = \frac{SS_B}{k_B-1}F=MSBMSResF = \frac{MS_B}{MS_{Res}}
Effect of A \times B(kA−1)∗(kB−1)(k_A - 1) \ast (k_B - 1)SSA×BSS_{A \times B}MSA×B=SSA×B(kA−1)(kB−1)MS_{A \times B} = \frac{SS_{A \times B}}{(k_A-1)(k_B-1)}F=MSA×BMSResF = \frac{MS_{A \times B}}{MS_{Res}}
Residual errorn−kAkBn - k_A k_BSSResSS_{Res}MSRes=SSResn−kAkBMS_{Res} = \frac{SS_{Res}}{n-k_A k_B}—
Totaln−1n - 1SSTotSS_{Tot}——
  • Multiple regression perspective: From an MLR viewpoint, there are p=(kA−1)+(kB−1)+(kA−1)∗(kB−1)=kAkB−1p = (k_A - 1) + (k_B - 1) + (k_A - 1) \ast (k_B - 1) = k_A k_B - 1 predictors. Consequently, dfReg=kAkB−1df_{Reg} = k_A k_B - 1 and dfRes=n−p−1=n−kAkBdf_{Res} = n - p - 1 = n - k_A k_B 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\beta_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+ϵY = \alpha + \beta_1A + \beta_2B + \epsilon.

  • 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\mu_{1,1} + \mu_{0,0} = \mu_{0,1} + \mu_{1,0} 37. {"header": ["Variable Level", "Regression Equation", "Expected Value", "Parameter Meaning", "rows": [["A = 0, B = 0", "Y=α+ϵY = \alpha + \epsilon", "μ0,0=α\mu_{0,0} = \alpha", "α=μ0,0\alpha = \mu_{0,0}", ["A = 1, B = 0", "Y=α+β1+ϵY = \alpha + \beta_1 + \epsilon", "μ1,0=α+β1\mu_{1,0} = \alpha + \beta_1", "β1=μ1,0−μ0,0\beta_1 = \mu_{1,0} - \mu_{0,0}", ["A = 0, B = 1", "Y=α+β2+ϵY = \alpha + \beta_2 + \epsilon", "μ0,1=α+β2\mu_{0,1} = \alpha + \beta_2", "β2=μ0,1−μ0,0\beta_2 = \mu_{0,1} - \mu_{0,0}", ["A = 1, B = 1", "Y=α+β1+β2+ϵY = \alpha + \beta_1 + \beta_2 + \epsilon", "$\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. This line graph illustrates the main effects of a two-way ANOVA, showing the dependent variable Y across levels of Factor A for two levels of Factor B.

  • Coefficient interpretation:
  • α=μ0,0\alpha = \mu_{0,0}: Represents the mean in the reference cell.
  • β1=μ1,0−μ0,0=μ1,1−μ0,1\beta_1 = \mu_{1,0} - \mu_{0,0} = \mu_{1,1} - \mu_{0,1}: Denotes the distance from A=0 to A=1, independent of B.
  • β2=μ0,1−μ0,0=μ1,1−μ1,0\beta_2 = \mu_{0,1} - \mu_{0,0} = \mu_{1,1} - \mu_{1,0}: Denotes the distance from B=0 to B=1, independent of A 38.
  • OLS solutions for dummy coding:
  • α=μA=0+μB=0−μ\alpha = \mu_{A=0} + \mu_{B=0} - \mu: Represents a difference of means.
  • β1=μA=1−μA=0\beta_1 = \mu_{A=1} - \mu_{A=0}: Represents the main effect of A.
  • β2=μB=1−μB=0\beta_2 = \mu_{B=1} - \mu_{B=0}: Represents the main effect of B 40. This line graph displays the main effects of Factor A on the dependent variable Y, with different lines representing levels of Factor B.

📝 If μ0,0\mu_{0,0} is the mean in the reference cell, then β1=μ1,0−μ0,0\beta_1 = \mu_{1,0} - \mu_{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 kAk_A and kBk_B levels, respectively, provides a structured summary of the variance decomposition. From a multiple regression perspective, the number of predictors pp is (kA−1)+(kB−1)=kA+kB−2(k_A - 1) + (k_B - 1) = k_A + k_B - 2 41.

See the table in section 4.13.

  • Degrees of freedom:
  • dfReg=p=kA+kB−2df_{Reg} = p = k_A + k_B - 2.
  • dfRes=n−p−1=n−(kA+kB−1)df_{Res} = n - p - 1 = n - (k_A + k_B - 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,BSS_{Reg} = SS_A + SS_{B|A} + SS_{A \times B|A,B} might differ from SSReg=SSB+SSA∣B+SSA×B∣A,BSS_{Reg} = SS_B + SS_{A|B} + SS_{A \times B|A,B}.
  • Summation of effects: Individual effects (SSEffectSS_{Effect}) sum to the regression effect (SSRegSS_{Reg}).
  • 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∣BSS_{A|B} and SSB∣ASS_{B|A} while initially ignoring the interaction effect A×BA \times B, followed by estimating SSA×B∣A,BSS_{A \times 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 (SSEffectSS_{Effect}) might not sum to SSRegSS_{Reg}.
  • Application: Best utilized in the absence of significant interactions, as it allows for more robust testing of main effects 44. This diagram illustrates the calculation of sums of squares for ANOVA Type II, showing how different terms are estimated.

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×BSS_{A|B,A \times B}, SSB∣A,A×BSS_{B|A,A \times B}, and SSA×B∣A,BSS_{A \times 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. This diagram shows the structure of an ANOVA Type III test, outlining its characteristics and conditions.

4.22 Eta squared η2\eta^2 is a smaller R2R^2

Effect size measures quantify the proportion of variance explained by an effect. These include Eta squared (η2\eta^2), Partial Eta squared (ηP2\eta^2_P), and Generalized Eta squared, which accounts for non-manipulable predictors.

  • Formulas for effect size:
  • Eta squared: η2=SSEffectSSTot\eta^2 = \frac{SS_{Effect}}{SS_{Tot}}
  • Partial Eta squared: ηP2=SSEffectSSEffect+SSRes\eta^2_P = \frac{SS_{Effect}}{SS_{Effect} + SS_{Res}} 46.
ANOVA TypeInterceptEffect of AEffect of BEffect of A × BSum to SSReg
Type INOSSASS_ASSB∣ASS_{B\vert A}SSA×B∣A,BSS_{A \times B\vert A,B}YES
Type IINOSSA∣BSS_{A\vert B}SSB∣ASS_{B\vert A}SSA×B∣A,BSS_{A \times B\vert A,B}Might not
Type IIIYESSSA∣B,A×BSS_{A\vert B,A \times B}SSB∣A,A×BSS_{B\vert A,A \times B}SSA×B∣A,BSS_{A \times B\vert A,B}Might not
  • Overall variance explained: η2=SSRegSSTot=R2\eta^2 = \frac{SS_{Reg}}{SS_{Tot}} = R^2 46. This table summarizes different ANOVA calculations and their corresponding effect sizes.

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−SubjectsSS_{Tot} = SS_{Between-Subjects} + SS_{Within-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)SS_{Between-Subjects} = SS_{Between} + SS_{Error(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)SS_{Within-Subjects} = SS_{Within} + SS_{Interaction} + SS_{Error(Within)} 47.
  • Mixed-design ANOVA table: For a design with factor A (between, kAk_A groups) and factor B (within, kBk_B levels), with nn participants per group, the total number of observations is N=nkAkBN = nk_Ak_B 48.
SourcedfSSMSF
Factor AkA−1k_A - 1SSASS_AMSA=SSAkA−1MS_A = \frac{SS_A}{k_A-1}F=MSAMSS(A)F = \frac{MS_A}{MS_{S(A)}}
Error BetweenkA(n−1)k_A(n - 1)SSS(A)SS_{S(A)}MSS(A)=SSS(A)kA(n−1)MS_{S(A)} = \frac{SS_{S(A)}}{k_A(n-1)}—
Total betweenkAn−1k_An - 1SSTotBtwSS_{TotBtw}——
Factor BkB−1k_B - 1SSBSS_BMSB=SSBkB−1MS_B = \frac{SS_B}{k_B-1}F=MSBMSB×S(A)F = \frac{MS_B}{MS_{B \times S(A)}}
Interaction A × B(kA−1)(kB−1)(k_A - 1)(k_B - 1)SSA×BSS_{A \times B}MSA×B=SSA×B(kA−1)(kB−1)MS_{A \times B} = \frac{SS_{A \times B}}{(k_A-1)(k_B-1)}F=MSA×BMSB×S(A)F = \frac{MS_{A \times B}}{MS_{B \times S(A)}}
Error WithinkA(n−1)(kB−1)k_A(n - 1)(k_B - 1)SSB×S(A)SS_{B \times S(A)}MSB×S(A)=SSB×S(A)kA(n−1)(kB−1)MS_{B \times S(A)} = \frac{SS_{B \times S(A)}}{k_A(n-1)(k_B-1)}—
Total WithinnkA(kB−1)nk_A(k_B - 1)SSTotWithSS_{TotWith}Not computed—
Grand TotalN−1=nkAkB−1N - 1 = nk_Ak_B - 1SSTotSS_{Tot}——

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also