O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – building a multiple linear regression model

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.

  1. Build the multiple linear regression model with gasoline_lm <- lm(y~., data=Gasoline). Here, the formula y~. considers the variable y as the dependent variable and all the remaining variables in the Gasoline data frame as independent variables.
  2. Get the details of the fitted multiple linear regression model with summary(gasoline_lm).

    The R screen then appears as follows:

    Figure 7: Building the multiple linear regression model

As with the simple ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required