MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Linear Algebra for Data Science in R

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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])
Edit dan Jalankan Kode