Learn R Programming

DFA.CANCOR (version 0.2.2)

CANCOR: Canonical correlation analysis

Description

Produces SPSS- and SAS-like output for canonical correlation analysis. Portions of the code were adapted from James Steiger (www.statpower.net).

Usage

CANCOR(data, set1, set2, plot, plotCV, plotcoefs, verbose)

Arguments

data

A dataframe where the rows are cases & the columns are the variables.

set1

The names of the continuous variables for the first set, e.g., set1 = c('varA', 'varB', 'varC').

set2

The names of the continuous variables for the second set, e.g., set2 = c('varD', 'varE', 'varF').

plot

Should a plot of the coefficients be produced? The options are: TRUE (default) or FALSE.

plotCV

The canonical variate number for the plot, e.g., plotCV = 1.

plotcoefs

The coefficient for the plots. The options are 'structure' (default) or 'standardized'.

verbose

Should detailed results be displayed in the console? The options are: TRUE (default) or FALSE.

Value

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

cancorrels

canonical correlations and their significance tests

CoefRawSet1

raw canonical coefficients for Set 1

CoefRawSet2

raw canonical coefficients for Set 2

CoefStruct11

structure coefficients for Set 1 variables with the Set 1 variates

CoefStruct21

structure coefficients for Set 2 variables with the Set 1 variates

CoefStruct12

structure coefficients for Set 1 variables with the Set 2 variates

CoefStruct22

structure coefficients for Set 2 variables with the Set 2 variates

CoefStandSet1

standardized coefficients for Set 1 variables

CoefStandSet2

standardized coefficients for Set 2 variables

mv_Wilk

Wilk's multivariate significance test

mv_Pillai

Pillai-Bartlett multivariate significance test

mv_Hotelling

Hotelling-Lawley multivariate significance test

mv_Roy

Roy's Largest Root multivariate significance test

mv_BartlettV

Bartlett's V multivariate significance test

mv_Rao

Rao's' multivariate significance test

CorrelSet1

Pearson correlations for Set 1

CorrelSet2

Pearson correlations for Set 2

CorrelSet1n2

Pearson correlations between Set 1 & Set 2

References

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.

Examples

Run this code
# 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