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.
Este exercício faz parte do curso
Linear Algebra for Data Science in R
Instruções do exercício
- Create the matrix \(\frac{A^TA}{n-1}\). Call this matrix
B. - Show that the
[1,1]element ofBis the same as the variance of the first column ofA. - Show that the
[1,2]and[2,1]elements ofBare the same as the covariance between the first and second columns ofA.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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])