Q1

Reproduce the covariance matrix in the upper right part of Table 4.1 from the correlations and standard deviations in the upper left part of the table.

# Install Packages 
library(mvtnorm)

# Enter the covariance/correlation matrix
x <- as.matrix(data.frame(c(1.000, .2721, .6858),
          c(.2721, 1.0000, .4991),
          c(.6858, .4991, 1.0000)))

V <- diag(c(3.0070, 2.8172, 10.8699))
S <- V %*% x %*% V
# Covariance Matrix 
S
##           [,1]      [,2]      [,3]
## [1,]  9.042049  2.305046  22.41591
## [2,]  2.305046  7.936616  15.28378
## [3,] 22.415914 15.283781 118.15473
cor(rmvnorm(100, sigma=S))
##           [,1]      [,2]      [,3]
## [1,] 1.0000000 0.3058924 0.6866995
## [2,] 0.3058924 1.0000000 0.5313669
## [3,] 0.6866995 0.5313669 1.0000000
# Get eigenvalues and eigenvectors
eigen(x)
## eigen() decomposition
## $values
## [1] 1.9906969 0.7441315 0.2651717
## 
## $vectors
##            [,1]       [,2]       [,3]
## [1,] -0.5835121  0.5545839  0.5932540
## [2,] -0.4874832 -0.8234582  0.2903044
## [3,] -0.6495180  0.1198052 -0.7508482

Q2

Given Cov(𝑋,𝑌)=13.00, 𝑠𝑋2=12.00, and 𝑠𝑌2=10.00, show that the corresponding correlation is out of bounds.

sqrt(12*10)
## [1] 10.95445

The covariance is found by Rxy * 10.95445 = 13.00

Solving for correlation: 13 / 10.95445 = 1.186732

Since this correlation is greater than one (1.186732), data shows the corresponding correlation is out of bounds. In addition, since the covariance (cov = 13) is greater that 10.95, the value is out of bounds.

Q3

Find a normalizing transformation for the data in Figure 4.2. Explain why.

The data is positively skewed based on the box and whisker plot. More variables are found in the left side of the data set. A positive skew will add a constant of 1.0 as the lowest value. The transformation will be accomplished compressing the differences between scores in the upper end more than the differences between lower scores.

Q4

##a) List the cases that should be excluded when calculating corresponding covariances using pairwise deletion and listwise deletion.

Listwise Deletion: Exclude C, D, F, G

Pairwise Deletion: Exclude CW, DX, FY, GY, (X n=6, W n=6, Y n = 5)

##b) Calculate the covariance matrix using pairwise deletion. Show that the corresponding correlation matrix has an element that is out of bounds.

pairwise <- cbind(c(42, 34, 22, NA, 24, 16, 30),
          c(13, 12, NA, 8, 7, 10, 10),
          c(8, 10, 12, 14, 16, NA, NA))
pairwise
##      [,1] [,2] [,3]
## [1,]   42   13    8
## [2,]   34   12   10
## [3,]   22   NA   12
## [4,]   NA    8   14
## [5,]   24    7   16
## [6,]   16   10   NA
## [7,]   30   10   NA
pairwise.cor <- cor(pairwise, use = "pairwise.complete.obs")
pairwise.cov <- cov(pairwise, use = "pairwise.complete.obs")
eigen(pairwise.cor)
## eigen() decomposition
## $values
## [1]  2.68743416  0.32436846 -0.01180262
## 
## $vectors
##            [,1]       [,2]      [,3]
## [1,] -0.5404144  0.8153712 0.2076584
## [2,] -0.5817871 -0.5404064 0.6078525
## [3,]  0.6078454  0.2076793 0.7664159
eigen(pairwise.cov)
## eigen() decomposition
## $values
## [1] 98.229327  7.041785 -3.671112
## 
## $vectors
##            [,1]       [,2]       [,3]
## [1,]  0.9333177  0.3493531 0.08288858
## [2,]  0.1941479 -0.6852301 0.70197316
## [3,] -0.3020342  0.6390713 0.70736354
pairwise.cov
##           [,1]      [,2]      [,3]
## [1,]  86.40000  15.90000 -26.33333
## [2,]  15.90000   5.20000 -10.66667
## [3,] -26.33333 -10.66667  10.00000
pairwise.cor
##            [,1]       [,2]       [,3]
## [1,]  1.0000000  0.7005289 -0.8297422
## [2,]  0.7005289  1.0000000 -0.9922779
## [3,] -0.8297422 -0.9922779  1.0000000

According to the eigen values, there is one covariance out of bounds in the third variable.

Find out of bounds Covariance

-26.33333 Value

sqrt(10*86.4)
## [1] 29.39388

The covariance (cov = 26.33333) is not greater that 29.39388, the value is not out of bounds.

-10.66667 Value

sqrt(10*5.2)
## [1] 7.211103

Since the covariance (cov = 10.66667) is greater that 7.211103, the value is out of bounds.

c) Calculate the covariance matrix using listwise deletion. Check if the correlation matrix has an element that is out of bounds

listwise.cor <- cor(pairwise, use = "complete.obs")
listwise.cov <- cov(pairwise, use = "complete.obs")
eigen(listwise.cov)
## eigen() decomposition
## $values
## [1]  1.076844e+02  1.315572e+00 -2.147130e-16
## 
## $vectors
##            [,1]       [,2]       [,3]
## [1,]  0.8674003  0.4880625 0.09701425
## [2,]  0.3008023 -0.6695831 0.67909975
## [3,] -0.3964022  0.5598692 0.72760688
listwise.cov
##           [,1]      [,2]      [,3]
## [1,]  81.33333  27.66667 -36.66667
## [2,]  27.66667  10.33333 -13.33333
## [3,] -36.66667 -13.33333  17.33333
listwise.cor
##            [,1]       [,2]       [,3]
## [1,]  1.0000000  0.9543383 -0.9765536
## [2,]  0.9543383  1.0000000 -0.9962710
## [3,] -0.9765536 -0.9962710  1.0000000

Find out of bounds Covariance

-36.66667 Value

sqrt(81.33333*17.33333)
## [1] 37.547

The covariance (cov = 36.66667) is not greater that 37.547, the value is not out of bounds.

-13.33333 Value

sqrt(17.33333*10.33333)
## [1] 13.38324

Since the covariance (cov = 13.33333) is not greater that 13.38324, the value is not out of bounds.

27.66667 Value

sqrt(10.33333*81.33333)
## [1] 28.99041

Since the covariance (cov = 27.66667) is not greater that 28.99041, the value is not out of bounds.