CommencerCommencer gratuitement

Variance/Covariance Calculations

In the last exercise you pre-processed the combine data into a matrix A. We now use A to create the variance-covariance matrix of this dataset.

Cet exercice fait partie du cours

Linear Algebra for Data Science in R

Afficher le cours

Instructions

  • Create the matrix \(\frac{A^TA}{n-1}\). Call this matrix B.
  • Show that the [1,1] element of B is the same as the variance of the first column of A.
  • Show that the [1,2] and [2,1] elements of B are the same as the covariance between the first and second columns of A.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Create matrix B from equation in instructions
B <- ___(A)%*%A/(___(A) - 1)

# Compare 1st element of the 1st column of B to the variance of the first column of A
B[1,1]
____(A[, 1])

# Compare 1st element of 2nd column of B to the 1st element of the 2nd row of B to the covariance between the first two columns of A
B[1, 2]
B[2, 1]
___(A[, 1], A[, 2])
Modifier et exécuter le code