Multiple Regression
Multiple regression, also known as multiple linear regression, is a statistical technique used to model the relationship between a dependent variable and two or more independent variables. In multiple regression, we need to understand how changes in multiple predictors are associated with changes in the dependent variable.
y=β0 +β1 x1 +β2 x2 + … +βn xn + ε
Where:
- y is the dependent variable.
- x1, x2,…, xn are the independent variables (predictors).
- β0 is the intercept (the value of y when all predictors are zero).
- β1, β2,…, βn are the coefficients representing the effect of each predictor on y.
- ε is the error term, representing the difference between the observed and predicted values of y.
Multiple regression is to estimate the values of the coefficients β1, β2,…, βn that minimize the sum of squared differences between the observed and predicted values of y. Once the model is fitted, we can use it to make predictions about the dependent variable based on new values of the independent variables.
Transition to multiple linear regression when you have more than one independent variable.
- Use the lm() function similarly, but include multiple predictors in the formula.
# Sample data
x1 <- c(1, 2, 3, 4, 5)
x2 <- c(2, 3, 4, 5, 6)
y <- c(2, 4, 5, 4, 6)
# Fit multiple linear regression model
model <- lm(y ~ x1 + x2)
# Summary of the model
summary(model)
Output:
Call:
lm(formula = y ~ x1 + x2)
Residuals:
1 2 3 4 5
-0.6 0.6 0.8 -1.0 0.2
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.8000 0.9381 1.919 0.1508
x1 0.8000 0.2828 2.828 0.0663 .
x2 NA NA NA NA
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.8944 on 3 degrees of freedom
Multiple R-squared: 0.7273, Adjusted R-squared: 0.6364
F-statistic: 8 on 1 and 3 DF, p-value: 0.06628
Here, output represents the results of a multiple linear regression model fitted to data with two independent variables (x1 and x2) and one dependent variable (y).
How to proceed from Simple to Multiple and Polynomial Regression in R
Regression analysis allows us to understand how one or more independent variables relate to a dependent variable. Simple linear regression, which explores the relationship between two variables. Multiple linear regression extends this to include several predictors simultaneously. Finally, polynomial regression introduces flexibility by accommodating non-linear relationships in the R Programming Language.
Contact Us