4

The following are the datasets

mm <- read.csv("https://stats.idre.ucla.edu/stat/data/mmreg.csv")
colnames(mm) <- c("Control", "Concept", "Motivation", "Read", "Write", "Math", 
"Science", "Sex")
psych <- mm[, 1:3] # dataset A
acad <- mm[, 4:8]  # dataset B

For these datasets psych and acad,I wanted to do the canonical correlation analysis and obtained the canonical correlation coefficients and canonical loadings as follows:

require(CCA) 
cc1 <- cc(psych, acad)

I would like to know if there is a package or function in R to automatically compute the significance of the canonical dimensions/variates.And also something to test the overall model fit for canonical correlation analysis and summarize as follows:

Table

KT12
  • 549
  • 11
  • 24
Paul
  • 1,077
  • 3
  • 14
  • 27

1 Answers1

4

using package CCP in R, we can calculate the statistical significance of the canonical correlation analysis.

library(CCP)
## Define number of observations, number of dependent variables, number of independent variables.
N = dim(psych)[1]
p = dim(psych)[2]
q = dim(acad)[2]

## Calculate canonical correlations ("cancor" is part of the stats-package):

rho <- cancor(psych,acad)$cor

## Calculate p-values using the F-approximations of different test statistics:

p.asym(rho, N, p, q, tstat = "Wilks")
p.asym(rho, N, p, q, tstat = "Hotelling")
p.asym(rho, N, p, q, tstat = "Pillai")
p.asym(rho, N, p, q, tstat = "Roy")

## Plot the F-approximation for Wilks’ Lambda, considering 3, 2, or 1 canonical correlation(s):

res1 <- p.asym(rho, N, p, q)
plt.asym(res1,rhostart=1)
plt.asym(res1,rhostart=2)
plt.asym(res1,rhostart=3)

Going a step further the permutation tests were then calculated as:

p.perm(psych, acad, nboot = 999, rhostart = 1, type = "Wilks")
Paul
  • 1,077
  • 3
  • 14
  • 27
  • Thanks @Paul. This post really helped me a lot. I am doing a CCA analysis. As far as my understating of Wilk's lambda, the closer it is to zero the better it is. Can you please let me know how to interpret Hotelling, Pillai, and Roy? Thanks. – nasia jaffri May 29 '14 at 04:12