Problem

Recall the globalLandTempHist.txt dataset that consisted of the global land temperature of Earth over the past 300 years. Also recall that a covariance matrix is a symmetric positive-definite square matrix of the form,

\[\Sigma = \begin{pmatrix} \sigma_{11} & \sigma_{12} \\ \sigma_{21} & \sigma_{22} \end{pmatrix}\]

where each element is computed via the following equation,

\[\sigma_{ij} = \sum_1^{n} ~ (x_i-\overline{x})(y_j-\overline{y})\]

where $n$ represents the number of data points and $x_i$ and $x_j$ are individual data points. Also, recall that the corresponding correlation matrix to this covariance matrix of data is defined as the following,

\[\text{Cor} = \begin{pmatrix} \rho_{11} = 1 & \rho_{12} = \frac{\sigma_{12}}{\sqrt(\sigma_{11}\sigma_{22})} \\ \rho_{21} = \frac{\sigma_{21}}{\sqrt(\sigma_{11}\sigma_{22})} & \rho_{22} = 1 \end{pmatrix}\]

Use the covariance matrix definition and the above equations to compute the correlation matrix of the two year and the temperature anomaly attributes in the data referenced above. To do so, first write a generic function genCorMat(Data) that takes an input matrix (table), then calls another function genCovMat(data) that computes the covariance matrix of data, then uses this covariance matrix to calculate the corresponding elements of the correlation matrix.

Comments