StatBCS 7Regression 4 handout without solutions
Multiple linear regression (MLR)
Multiple Linear Regression (MLR) is a statistical method that extends simple linear regression by allowing for multiple independent variables to predict a single dependent variable. This technique is widely applicable, including in cognitive neuroscience, for instance, in Statistical Parameter Mapping (SPM) which is used to analyze neuroimaging data like fMRI 5.
The core concept of MLR can be represented by the following model: Y=α+β1X1+β2X2+⋯+βpXp+ϵ where:
- Y is the dependent variable.
- X1,X2,…,Xp are the p independent variables (predictors).
- α is the intercept, representing the expected value of Y when all independent variables are zero.
- β1,β2,…,βp are the regression coefficients, each indicating the change in Y for a one-unit increase in the corresponding Xj, holding all other predictors constant.
- ϵ is the error term, representing the unexplained variance.
In matrix notation, this model is expressed as: y=Xβ+e where y is a vector of observed dependent variable values, X is the design matrix containing the independent variables (including a column of ones for the intercept), β is a vector of coefficients, and e is a vector of residuals 7 8.
Design matrix in fMRI
In the context of fMRI analysis, the design matrix is crucial. It typically includes regressors representing the experimental paradigm (e.g., task timing, stimulus presentation), nuisance regressors to account for confounding factors (e.g., head motion parameters, physiological noise), and terms for session constants and drifts (e.g., intercept, polynomial drifts). Temporal derivatives of predictors are often included to account for temporal jitter in the experimental design 5 6.
Example: A design matrix might include columns for a main task, a constant (intercept), and the temporal derivative of the main task to capture potential timing variations 6.
Geometric interpretation
Similar to how simple linear regression represents a line in a 2-dimensional space (R2), MLR with two independent variables can be visualized as a plane in a 3-dimensional space (R3). For a model with p predictors, the relationship can be envisioned in p+1 dimensions 7.
Interpretation of coefficients
- Intercept (α): This is the conditional expected value of the dependent variable (Y) when all independent variables (Xj) are zero. α=E(Y∣X=0).
- Partial Regression Coefficients (βj): Each βj represents the change in the expected value of Y when Xj increases by one unit, while all other independent variables (Xj′=j) are held constant. This is also known as the partial effect 9.
Example: If β1=−0.05 for the Prefrontal Cortex Volume (X1) predicting Stroop Interference Score (Y), it means that for every 1 cubic millimeter increase in Prefrontal Cortex Volume, the Stroop Interference Score is expected to decrease by 0.05 milliseconds, assuming all other predictors remain unchanged 9.
Ordinary Least Squares (OLS) solution
The goal of OLS is to find the coefficients (β^) that minimize the sum of squared residuals (SSRes). This is achieved by satisfying two conditions:
- The sum of residuals is zero: ∑i=1nei=0. This ensures the regression hyperplane passes through the mean of all variables. The estimated intercept is then calculated as α^=yˉ−∑j=1pβ^jxˉj.
- The covariance between each independent variable (xj) and the residuals (e) is zero: sxj,e=0 for all j∈{1,…,p}. This can be summarized by the matrix equation XTe=0 10.
The OLS solution for the coefficient vector β^ is given by the formula: β^=(XTX)−1XTy This solution involves the inverse of the (XTX) matrix, which contains information about the means and covariances of the independent variables, and the (XTy) vector, which contains the sum of the dependent variable and its covariances with the independent variables 11.
Test of the regression coefficients
The OLS estimators (β^) are considered Best Linear Unbiased Estimators (BLUE), meaning they have the smallest variance among all linear unbiased estimators 12.
- Expected value: E(β^)=β
- Variance: Var(β^)=σ2(XTX)−1
The variance of a specific coefficient β^j can be expressed as: Var(β^j)=SE(β^j)2=nsxj2(1−Rj2)σ2 where sxj2 is the sample variance of the predictor Xj, and Rj2 is the R-squared value obtained from regressing Xj on all other predictors 12.
Since the true error variance σ2 is usually unknown, it is estimated by the Mean Squared Error (MSRes). This allows for testing individual regression coefficients (β^j) using a t-test, similar to simple linear regression 12.
Derivations for p=2
The OLS solution for a model with two predictors (p=2) can be derived explicitly, leading to expressions for the coefficients in terms of simple and partial correlations. The partial regression coefficients can be rewritten using partial correlations, which "clean" the relationship between the dependent variable and one independent variable by accounting for the contribution of the other variables 13 14.
Multicollinearity and Singularity
Multicollinearity occurs when independent variables in a regression model are highly correlated with each other. Singularity is an extreme case where one or more independent variables are perfectly linearly related to others 15.
Problems caused by multicollinearity
- Inestimable Coefficients: If two predictors are identical (X1=X2), the model effectively becomes a simple linear regression, and it's impossible to distinguish the individual contributions of β1 and β2 to the combined effect 15.
- Singular Matrix: If independent variables are linear combinations of each other, the XTX matrix becomes singular (determinant is zero) and cannot be inverted, meaning no OLS solution exists.
- Inflated Standard Errors: Even if the determinant is not exactly zero but small, the inverse (XTX)−1 can have large values, leading to inflated variances and standard errors for the coefficient estimates.
- Reduced Power: Inflated standard errors lead to deflated t-statistics, potentially resulting in Type II errors (false non-significance), reduced statistical power, and unreliable model predictions 16.
Detecting multicollinearity
Methods for detecting multicollinearity include: a) Scatterplots of pairs of independent variables. b) Calculating the determinant of the XTX matrix (singularity if Det(XTX) = 0). c) Eigenvalue methods (less commonly discussed in introductory contexts). d) Calculating the Variance Inflation Factor (VIF) for each predictor 17.
The variance of the estimators is influenced by several factors: larger noise (σ2) increases SEs, larger sample size (n) and variance of the predictor (sxj2) decrease SEs, and a smaller Rj2 (less prediction of Xj by other predictors) improves the SE. The term 1−Rj21 highlights the negative impact of high Rj2 values 17 18.
Variance Inflation Factor (VIF)
The VIF for the j-th independent variable quantifies how much the variance of the estimated regression coefficient is inflated due to collinearity with other predictors. VIFj=1−Rj21 where Rj2 is the R-squared from regressing Xj on all other predictors 19.
Rules of thumb for VIF:
- VIFj=1: No collinearity.
- 1<VIFj<5: Moderate collinearity.
- VIFj≥5: Strong collinearity.
- VIFj≥10: Serious problem 19.
Remedies for multicollinearity: a) Remove the predictor causing high VIF if it's not theoretically essential. b) Identify and address outliers or influential points. c) Consider standardizing variables or removing the intercept (though standardizing is generally preferred) 19.
ANOVA Table for MLR
The Analysis of Variance (ANOVA) table in MLR partitions the total variation in the dependent variable (Y) into components explained by the regression model and the residual error 20.
| Source of Variation | Degrees of Freedom (df) | Sum of Squares (SS) | Mean Square (MS) | F statistic |
|---|---|---|---|---|
| Regression | p | SSReg=∑(y^i−yˉ)2 | MSReg=SSReg/p | F=MSReg/MSRes |
| Residual Error | n−p−1 | SSRes=∑(yi−y^i)2 | MSRes=SSRes/(n−p−1) | — |
| Total | n−1 | SSTot=∑(yi−yˉ)2 | — | — |
Key points:
- For estimation and testing, it must hold that n>p+1.
- The overall F-test (General Linear F-Test) assesses whether at least one of the regression coefficients is significantly different from zero.
- R2, the coefficient of multiple determination, represents the proportion of variance in the dependent variable explained by the model. A partial R2 indicates the proportion of variance explained by a subset of predictors. The square root of R2 (R2) is the coefficient of multiple correlation, which is the correlation between Y and Y^ (ryy^) 20.
General Linear F-Test
The General Linear F-Test is used to test hypotheses about subsets of regression coefficients. It involves comparing a "Full" (unrestricted) model with a "Reduced" (restricted) model.
- Estimate OLS coefficients and SSRes for both models:
- Full model (F): Includes all predictors of interest. SSRes,F.
- Reduced model (R): A subset of the predictors from the full model. SSRes,R.
- Calculate the sequential (extra) sum of squares: SSRes,R−SSRes,F. This represents the reduction in unexplained variance (or increase in explained variance) gained by adding the predictors from the full model that are not in the reduced model.
- The F-statistic is computed as: F=SSRes,F/dfF(SSRes,R−SSRes,F)/(dfR−dfF) This test determines if the additional predictors in the full model significantly improve the model fit compared to the reduced model 21.
The sequential sum of squares can also be used to calculate the Partial R2: Ry,B∣A2=SSRes,ASSRes,A−SSRes,A∪B=SSRes,ASSRes,B∣A This value represents the proportion of variance explained by adding a set of predictors B to a model already containing predictors A 22.
Advanced: alternative approaches to OLS
While Ordinary Least Squares (OLS) is the standard method, Weighted Least Squares (WLS) and Generalized Least Squares (GLS) are used when assumptions about the error term's variance-covariance matrix are violated 23.
- OLS assumptions: Assumes the error variance-covariance matrix (ΘOLS) is σ2I, meaning errors are independent and have constant variance.
- WLS assumptions: Assumes the error variance-covariance matrix (ΘWLS) is a diagonal matrix with potentially different variances for each observation (σi2).
- GLS assumptions: Assumes a general error variance-covariance matrix (ΘGLS) where errors can be correlated and have unequal variances.
The OLS solution is a special case of the WLS/GLS solution where W=Θ−1 is the inverse of the error variance-covariance matrix. For OLS, W=σ21I, which simplifies the solution to the standard formula 23.
Limitations of MLR and extensions
MLR has several limitations that lead to more advanced models:
- Single Dependent Variable: MLR can only handle one dependent variable at a time. Multivariate Regression extends this to multiple correlated dependent variables.
- Direct Effects Only: MLR models direct effects from IVs to the DV. Path Analysis can model simultaneous regressions and direct/indirect effects between multiple IVs and DVs.
- Fixed Effects: MLR models only fixed effects. Mixed-Effects Models incorporate both fixed and random effects, essential for hierarchical or longitudinal data.
- Continuous Dependent Variable: MLR assumes a continuous DV. Generalized Linear Models (GLMs) can handle categorical or other types of DVs.
- Observed Variables: MLR uses observed variables. Latent Variable Models (e.g., Factor Analysis, Structural Equation Models) allow for unobserved (latent) IVs and DVs 25.
Multivariate Regression
Multivariate Regression extends MLR to scenarios with multiple dependent variables (d) and multiple independent variables (p). The model can be written for each dependent variable 26: Yk=αk+βk1X1+βk2X2+⋯+βkpXp+ϵk for k=1,…,d.
In matrix notation, the system of regressions becomes: Y=XB+E where Y is a n×d matrix of dependent variables, X is the n×(p+1) design matrix (including the intercept column), B is a (p+1)×d matrix of regression coefficients, and E is a n×d matrix of residuals 27.
Estimation in Multivariate Regression
The least squares estimator for the coefficient matrix B is found by minimizing the sum of squared residuals across all dependent variables. This leads to: B^=(XTX)−1XTY This formula is analogous to the MLR solution, effectively stacking multiple MLR problems 29.
Related Models
- Multivariate ANOVA (MANOVA): Occurs when all predictors are categorical.
- Multivariate ANCOVA (MANCOVA): Occurs when predictors include both categorical and continuous variables.
- Repeated Measures Analysis: Multivariate approaches can analyze correlated errors in repeated measures data, although "univariate" approaches are often more common 29.
Why multivariate regression is less common
- Complexity: Univariate approaches are generally simpler to implement and interpret.
- Test Statistics: Multivariate analyses involve multiple complex test statistics (e.g., Wilk's Lambda, Pillai's Trace) which can be difficult to interpret, especially when they disagree 30.
- Curse of Dimensionality: With many dependent variables, the number of parameters to estimate grows rapidly. In high-dimensional data (e.g., thousands of voxels in fMRI), the residual variance-covariance matrix can become singular if the number of dependent variables exceeds the number of observations minus the number of predictors. This necessitates regularization techniques or alternative approaches like Multivoxel Pattern Analysis (MVPA) 31.
Path Analysis
Path Analysis is used when independent and dependent variables can directly affect each other, forming a system of regressions. It distinguishes between:
- Exogenous variables: Variables that are not explained by other variables in the model (only influenced by external factors or error).
- Endogenous variables: Variables that are explained by other variables within the model (can be both dependent and independent) 32.
The model is represented using path diagrams. A classic path analysis deals with observed variables; path diagrams with latent variables are termed Structural Equation Models (SEM) 33.
Mediation
A key concept in path analysis is mediation, where one variable (Z) explains the relationship between an independent variable (X) and a dependent variable (Y) by acting as an intermediate 32.
- Direct path: X→Y, with effect γ21.
- Indirect path: X→Z→Y, with effect β21γ11.
- Total effect: The sum of the direct and indirect effects (γ21+β21γ11) 33.
Confounder, mediator, moderator, and collider
These terms describe different roles a third variable (Z) can play in relation to an independent variable (X) and a dependent variable (Y) 34:
- Moderator: Changes the strength or direction of the X→Y path.
- Mediator: Explains the X→Y relationship through an indirect path (X→Z→Y).
- Confounder: Affects both X and Y, potentially creating a spurious association. Confounders must be controlled for in the analysis.
- Collider: Is caused by both X and Y. Colliders should not be controlled for, as doing so can induce spurious associations (selection bias).
Fixed versus random effects
In many statistical models, particularly those analyzing data with hierarchical structures (e.g., students within schools, patients over time), it's important to distinguish between fixed and random effects 35.
- Fixed effects: Coefficients are treated as specific, constant values representing the direct effect of a predictor. In fMRI, individual regression coefficients for a task might be treated as fixed effects for that specific subject.
- Random effects: Coefficients are considered realizations from a random variable, representing variability across different groups or individuals. This approach assumes an infinite population of such effects 37.
Mixed-Effects Models
Mixed-effects models combine both fixed and random effects. They are particularly useful for:
- Accounting for hierarchical structure: Recognizing that observations within groups are not independent.
- Estimating variance components: Estimating variability both between groups (e.g., between-subjects variance, σB2) and within groups (e.g., within-subject variance, σW2) 37.
A common application is in longitudinal studies, where individuals are followed over time. A model might include:
- A fixed intercept and slope representing the average effects across all individuals.
- Random intercepts and slopes for each individual, capturing their unique deviations from the average 38 39.
The model structure can be: Y=(α+u0)+(β1+u1)X+ϵ where α and β1 are fixed effects, u0 and u1 are random effects (e.g., normally distributed with mean 0 and variances σu02, σu12), and ϵ is the residual error 39.
Note: Mixed-effects models offer a compromise between "no pooling" (fitting separate models for each group, like ANCOVA) and "complete pooling" (fitting a single model for all data). They provide "semi-pooling," allowing for borrowing strength across groups while still accounting for individual differences 44.
Comparison with ANOVA and Moderation
| Approach | Equation | dfX | dfZ | dfXZ | dfRes | Variances |
|---|---|---|---|---|---|---|
| ANOVA Within | Y=α+β1X+β2Z+ϵ | T−1 | n−1 | 0 | (T−1)(n−1) | σ2 |
| Moderation (X categorical) | Y=α+β1X+β2Z+β3XZ+ϵ | T−1 | n−1 | (T−1)(n−1) | 0 | σ2 |
| Moderation (X continuous) | Y=α+β1X+β2Z+β3XZ+ϵ | 1 | n−1 | n−1 | (T−2)n | σ2 |
| Mixed-Effect model | Y=α+u0+(β1+u1)X+ϵ | 1 | 0 | 0 | Debated | σ2,σu02,σu12 |
Within-subject ANOVA and simple moderation models treat all effects as fixed. Mixed-effects models significantly reduce the number of parameters by treating some effects as random, leading to more efficient estimation, though the degrees of freedom for testing can be complex 41.
Intraclass Correlation Coefficient (ICC)
The ICC quantifies the proportion of total variance attributable to between-group differences. For a model with random intercepts: ρ0=σu02+σ2σu02 where σu02 is the variance of the random intercepts (between-group variance) and σ2 is the within-group variance 42.
Important: The ICC ρ0 is an "unconditional" ICC. In models with random slopes, a "conditional" ICC which depends on X might be more appropriate but is more complex to calculate 42.
Generalized Linear Model (GLM)
Generalized Linear Models (GLMs) extend linear regression to accommodate dependent variables that are not normally distributed and are not necessarily continuous 45.
The need for GLM
When the dependent variable (Y) is categorical (e.g., binary: Yes/No), a standard linear regression model is inappropriate because:
- The predicted values (probabilities) can fall outside the range 0 1.
- The assumption of normally distributed errors with constant variance is violated 45 46.
GLMs address this by:
- Specifying a distribution for Y: The distribution of Y belongs to the exponential family (e.g., Bernoulli, Poisson, Gamma).
- Defining a linear predictor: η=α+β1X1+⋯+βpXp.
- Using a link function (g): A monotonic and differentiable function that connects the expected value of Y (μ=E(Y∣X)) to the linear predictor: μ=g−1(η) 47.
Simple Logistic Regression
A common GLM is logistic regression, used when the dependent variable is binary (Bernoulli distributed).
- Probability: P(Y=1∣X)=p(X). The expected value is μ=E(Y∣X)=p(X).
- Link function: For the Bernoulli distribution, the logit function is typically used: logit(p)=ln(1−pp) This function, also known as the log-odds, transforms the probability (bounded between 0 and 1) into a variable that ranges from −∞ to +∞ 47.
The model equation becomes: logit(p(X))=ln(1−p(X)p(X))=α+βX This linear relationship between the log-odds and the predictor allows for estimation using methods like Maximum Likelihood Estimation (MLE) 48.
Representations of Logistic Regression
The relationship can be expressed in three equivalent ways 48:
- Logit/Log-odds: ln(1−P(Y=1∣X)P(Y=1∣X))=α+βX
- Odds: 1−P(Y=1∣X)P(Y=1∣X)=eα+βX
- Probability: P(Y=1∣X)=1+eα+βXeα+βX (This is the logistic function, hence "logistic regression").
Parameter interpretation
- Intercept (α): Represents the log-odds of Y=1 when X=0. eα is the odds of Y=1 when X=0.
- Coefficient (β): Represents the change in the log-odds for a one-unit increase in X. eβ is the odds-ratio, indicating how much the odds of Y=1 are multiplied for each unit increase in X 50.
Example: If β=0.5, then eβ≈1.65. This means for every one-unit increase in the test score (X), the odds of a positive diagnosis (Y=1) are multiplied by approximately 1.65 50.
Hat Matrix Formulation
The Hat Matrix (H), also known as the projection or influence matrix, plays a crucial role in understanding the relationship between observed and predicted values in linear regression 52.
In matrix form, the simple linear regression model is y=Xβ+e, where β^=(XTX)−1XTy is the OLS solution. The predicted values (y^) are then: y^=Xβ^=X(XTX)−1XTy=Hy The matrix H=X(XTX)−1XT is the hat matrix 52.
Properties of the Hat Matrix
The Hat matrix H and the related Residual Maker Matrix (I−H) have important properties 54: a) Symmetric: HT=H and (I−H)T=I−H. b) Idempotent: H2=H and (I−H)2=I−H.
The residuals (e) can be computed as e=y−y^=(I−H)y 54.
Leverage values
The diagonal elements of the hat matrix, hii, are called leverage values. They measure how much the i-th observation's independent variable value (xi) deviates from the mean of the independent variables. Higher leverage values indicate that an observation has a greater potential to influence the regression line 53.
For simple linear regression, the leverage value for the i-th observation is: hii=n1+∑j=1n(xj−xˉ)2(xi−xˉ)2 53.
The variance of a single residual ei is given by: Var(ei)=σ2(1−hii) This shows that residuals associated with high leverage points have smaller variances 54.
The sum of squared residuals can be expressed using the hat matrix: SSRes=eTe=yT(I−H)T(I−H)y=yT(I−H)y 54.
© 2026 Maeve. All rights reserved. This content is protected by copyright.