Last chance! 50% off unlimited learning
Sale ends in
Produces SPSS- and SAS-like output for canonical correlation analysis. Portions of the code were adapted from James Steiger (www.statpower.net).
CANCOR(data, set1, set2, plot, plotCV, plotcoefs, verbose)
A dataframe where the rows are cases & the columns are the variables.
The names of the continuous variables for the first set,
e.g., set1 = c('varA', 'varB', 'varC').
The names of the continuous variables for the second set,
e.g., set2 = c('varD', 'varE', 'varF').
Should a plot of the coefficients be produced? The options are: TRUE (default) or FALSE.
The canonical variate number for the plot, e.g., plotCV = 1.
The coefficient for the plots. The options are 'structure' (default) or 'standardized'.
Should detailed results be displayed in the console? The options are: TRUE (default) or FALSE.
If verbose = TRUE, the displayed output includes Pearson correlations, multivariate significance tests, canonical function correlations and bivariate significance tests, raw canonical coefficients, structure coefficients, standardized coefficients, and a bar plot of the structure or standardized coefficients.
The returned output is a list with elements
canonical correlations and their significance tests
raw canonical coefficients for Set 1
raw canonical coefficients for Set 2
structure coefficients for Set 1 variables with the Set 1 variates
structure coefficients for Set 2 variables with the Set 1 variates
structure coefficients for Set 1 variables with the Set 2 variates
structure coefficients for Set 2 variables with the Set 2 variates
standardized coefficients for Set 1 variables
standardized coefficients for Set 2 variables
Wilk's multivariate significance test
Pillai-Bartlett multivariate significance test
Hotelling-Lawley multivariate significance test
Roy's Largest Root multivariate significance test
Bartlett's V multivariate significance test
Rao's' multivariate significance test
Pearson correlations for Set 1
Pearson correlations for Set 2
Pearson correlations between Set 1 & Set 2
Manly, B. F. J., & Alberto, J. A. (2017). Multivariate statistical methods: A primer (4th Edition). Chapman & Hall/CRC, Boca Raton, FL. Sherry, A., & Henson, R. K. (2005). Conducting and interpreting canonical correlation analysis in personality research: A user-friendly primer. Journal of Personality Assessment, 84, 37-48. Steiger, J. (2019). Canonical correlation analysis. www.statpower.net/Content/312/Lecture%20Slides/CanonicalCorrelation.pdf Tabachnik, B. G., & Fidell, L. S. (2013). Using multivariate statistics (6th. ed.). New York, NY: Pearson.
# NOT RUN {
# data that simulate those from De Leo & Wulfert (2013)
CANCOR(data = na.omit(data_CCA_De_Leo),
set1 = c('Tobacco_Use','Alcohol_Use','Illicit_Drug_Use','Gambling_Behavior',
'Unprotected_Sex','CIAS_Total'),
set2 = c('Impulsivity','Social_Interaction_Anxiety','Depression',
'Social_Support','Intolerance_of_Deviance','Family_Morals',
'Family_Conflict','Grade_Point_Average'),
plot = TRUE, plotCV = 1, plotcoefs='structure',
verbose = TRUE)
# }
# NOT RUN {
# data from Tabachnik & Fidell (2013, p. 589)
CANCOR(data = data_CCA_Tabachnik,
set1 = c('TS','TC'),
set2 = c('BS','BC'),
plot = TRUE, plotCV = 1, plotcoefs='structure',
verbose = TRUE)
# UCLA dataset
UCLA_CCA_data <- read.csv("https://stats.idre.ucla.edu/stat/data/mmreg.csv")
colnames(UCLA_CCA_data) <- c("LocusControl", "SelfConcept", "Motivation",
"read", "write", "math", "science", "female")
summary(UCLA_CCA_data)
CANCOR(data = UCLA_CCA_data,
set1 = c("LocusControl","SelfConcept","Motivation"),
set2 = c("read","write","math","science","female"),
plot = TRUE, plotCV = 1, plotcoefs='standardized',
verbose = TRUE)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab