EGN3443 Module 12 - Multiple Regression Analysis
Multiple regression is a statistical technique that uses multiple independent variables to predict a single dependent variable. It extends simple linear regression by allowing more than one predictor variable in the model.
Predicts a continuous outcome variable
Uses two or more independent (predictor) variables
Allows for more complex and nuanced predictions
Helps understand the relationship between multiple factors and an outcome
Y = β₀ + β₁X₁ + β₂X₂ + ... + βₖXₖ + ε
Where:
Y = Dependent variable
X₁, X₂, ..., Xₖ = Independent variables
β₀ = Intercept
β₁, β₂, ..., βₖ = Regression coefficients
ε = Error term
Predicting house prices based on:
Square footage (X₁)
Number of bedrooms (X₂)
Neighborhood crime rate (X₃)
Ordinary Least Squares (OLS): Most common method
Minimizes the sum of squared residuals
Provides unbiased estimates of regression coefficients
Each coefficient (βᵢ) represents the change in the dependent variable for one unit change in the independent variable, holding other variables constant
# Hypothetical house price prediction model
# Y = Price
# X1 = Square footage
# X2 = Number of bedrooms
# Estimated coefficients
β₀ (Intercept) = 50,000
β₁ (Square footage) = 200
β₂ (Number of bedrooms) = 15,000
# Prediction equation
Price = 50,000 + 200(Square Footage) + 15,000(Number of Bedrooms)
# Example calculation
Price = 50,000 + 200(2000) + 15,000(3)
= 50,000 + 400,000 + 45,000
= $495,000
t-tests for individual coefficients
Assess statistical significance of each predictor
Forward Selection
Start with no variables
Add most significant predictors sequentially
Backward Elimination
Start with all variables
Remove least significant predictors
Stepwise Regression
Combination of forward and backward methods
Adds and removes variables based on statistical significance
R-squared (R²)
Adjusted R-squared
Akaike Information Criterion (AIC)
Bayesian Information Criterion (BIC)
from sklearn.feature_selection import f_regression
from sklearn.linear_model import LinearRegression
# Perform feature selection
F_scores, p_values = f_regression(X, y)
# Select top predictors based on F-scores
Multicollinearity occurs when independent variables are highly correlated with each other.
Variance Inflation Factor (VIF)
Measures how much the variance of an estimated regression coefficient increases
from statsmodels.stats.outliers_influence import variance_inflation_factor
# Calculate VIF for each predictor
vif_data = pd.DataFrame()
vif_data["Variable"] = X.columns
vif_data["VIF"] = [variance_inflation_factor(X.values, i) for i in range(X.shape[1])]
VIF > 5-10 indicates significant multicollinearity
Potential solutions:
Remove correlated predictors
Use regularization techniques
Collect more data
Polynomial regression fits a nonlinear relationship between variables using polynomial equations.
Y = β₀ + β₁X + β₂X² + β₃X³ + ... + ε
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
# Create polynomial features
poly = PolynomialFeatures(degree=2)
X_poly = poly.fit_transform(X)
# Fit regression model
model = LinearRegression()
model.fit(X_poly, y)
Modeling curved relationships
Capturing non-linear patterns in data
Risk of overfitting
Careful selection of polynomial degree
Textbooks:
"Applied Multiple Regression/Correlation Analysis for the Behavioral Sciences" by Jacob Cohen
"Regression Analysis by Example" by Samprit Chatterjee
Online Courses:
Coursera: Statistical Inference and Regression Models
edX: Regression Analysis