The method of building a multiple linear regression model remains the same as earlier. If all the variables in data.frame
are to be used, we use the formula y ~ .
. However, if we need specific variables, say x1
and x3
, the formula would be y ~ x1 + x3
.
Build the multiple linear regression model with
gasoline_lm <- lm(y~., data=Gasoline)
. Here, the formulay~.
considers the variabley
as the dependent variable and all the remaining variables in theGasoline
data frame as independent variables.Get the details of the fitted multiple linear regression model with
summary(gasoline_lm)
.The R screen then appears as follows:
As with the simple model, we need to first check whether the overall model is significant by looking at the p-value of the F-statistics, which appears as the last line of the summary output. Here, the value 0.0003 being very close to zero, the overall model is...