We will build three models here. We have a vector of regressand `y`

and two covariates: `x1`

and `x2`

.

- 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)`

. - Visualize the relationships among the variables with:
par(mfrow=c(1,3)) plot(x1,y) plot(x2,y) plot(x1,x2)

- 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

Start Free Trial

No credit card required