Session Ready
Exercise

Definition of matrices

This chapter will help to understand how the correlation matrix and regression coefficients are constructed. To this purpose, you will first refresh and practice some basic matrix concepts. By going through the exercises, you will acquaint yourself with the implementation of the theoretical concepts in R and become familiar with the step-by-step construction of the correlation matrix and regression coefficients.

A matrix is a rectangular table that contains known or unknown numbers. The size, or order, of the table is given by the number of rows and columns it contains. For example, matrix m consists of 4 rows and 2 columns, which means that the order of matrix m is 4x2. $$\begin{aligned} m = \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \\ 7 & 8 \end{bmatrix} \end{aligned}$$

A trick that is often used in matrix algebra is taking the transpose of a matrix. The transpose of a matrix is constructed by rewriting its rows as columns. As a result, the order will change as the matrix will be reversed. For example, taking the transpose of matrix m results in a 2x4 matrix $$\begin{aligned} m^t = \begin{bmatrix} 1 & 3 & 5 & 7 \\ 2 & 4 & 6 & 8 \end{bmatrix} \end{aligned}$$

Start by creating and defining matrices r and s to be used in the next exercises. Use the R terminal to perform these actions.

Instructions
100 XP
  • Construct matrices r and s with each 3 rows and 8 columns that contain respectively numbers 1 up to 24 and numbers 21 up to 44.
  • Take the transpose of matrix r and name the transposed matrix t. What is the order of the transposed matrix?