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

No credit card required

# Time for action – averaging k simple linear regression models

We will build three models here. We have a vector of regressand `y` and two covariates: `x1` and `x2`.

1. Enter the dependent variable and the independent variables with `y <- c(1, 5,3,8,5,3,10,7)`, `x1 = c(2,4,5,6,8,10,11,13)`, and `x2 <- c(1,2, 2,4,4,4,6,6)`.
2. Visualize the relationships among the variables with:
```par(mfrow=c(1,3))
plot(x1,y)
plot(x2,y)
plot(x1,x2)```
3. Build the individual simple linear regression model and our first multiple regression model with:
```summary(lm(y~x1))
summary(lm(y~x2))
summary(lm(y~x1+x2)) # Our first multiple regression model``` Figure 6: Averaging k simple linear regression models ...

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

No credit card required