A <- matrix(c(2, -4, 5, 3, -1, -3), nrow = 2) A
## [,1] [,2] [,3] ## [1,] 2 5 -1 ## [2,] -4 3 -3
nrow
or ncol
.byrow = FALSE
, so it will spool the numbers down the columns first.as.matrix()
.B <- matrix(c(2, 1, 0, 0, 1, 4), nrow = 3) # A * B C <- A %*% B
*
operator will do element-wise multiplication.%*%
for matrix multiplication (inner product).Transpose: t()
C
## [,1] [,2] ## [1,] 9 1 ## [2,] -5 -9
t(C)
## [,1] [,2] ## [1,] 9 -5 ## [2,] 1 -9
Inverse: solve()
solve(C)
## [,1] [,2] ## [1,] 0.11842 0.01316 ## [2,] -0.06579 -0.11842
C %*% solve(C)
## [,1] [,2] ## [1,] 1.00e+00 0 ## [2,] -1.11e-16 1
Two components due next week:
In good shape: - great diversity in topics. - leads on data.
Needs work: - what is the observational unit (i.e. the rows of the data frame)? - what is the response? - build a MLR.
Time series: time series data is data that was collected over time, such as the price of a particular stock.
Logistic regression: used when you have a binary response (e.g. predicting whether an internet user will click on your ad).