## Exercise 1: Change the author to your name, knit, commit, and push

mpg wt
21.0 2.62
21.0 2.88
22.8 2.32
21.4 3.22
18.7 3.44
18.1 3.46
14.3 3.57

You can create a vector in R using the c() function. You can then assign this vector to an object in R using the <-

For example, I can input the data from the table above into an object y like below.

y <- c(21, 21, 22.8, 21.4, 18.7, 18.1, 14.3)

You can create a design matrix in R using the matrix() function.

X <- matrix(c(1, 1, 1, 1, 1, 1, 1,
2.62, 2.88, 2.32, 3.22, 3.44, 3.46, 3.57),
ncol = 2)

You can transpose a matrix using the t() function, get the inverse of a matrix using solve(), and multiple matrices using %*%

For example, $(X^TX)^{-1}$ is calculated by:

solve(t(X)%*%X)
##           [,1]       [,2]
## [1,]  7.072878 -2.2552371
## [2,] -2.255237  0.7339219

## Exercise 3: Check your answers by running the lm() function below (change teh chunk option to eval = TRUE).

lm(y ~ X[, 2])