cancorr: Canonical correlation analysis

View source: R/cancorr.R

cancorrR Documentation

Canonical correlation analysis

Description

This function conducts canonical correlation analysis using the OpenMx package. Missing data are handled with the full information maximum likelihood method when raw data are available. It provides standard errors for the estimates.

Usage

cancorr(
  X_vars,
  Y_vars,
  data = NULL,
  Cov = NULL,
  numObs = NULL,
  model = c("CORR-W", "CORR-L", "COV-W", "COV-L"),
  extraTries = 50,
  ...
)

Arguments

X_vars

A vector of characters of the X variables.

Y_vars

A vector of characters of the Y variables.

data

A data frame containing raw data. If NULL, Cov and numObs must be provided.

Cov

A covariance or correlation matrix. Required when data is NULL.

numObs

A sample size. Required when data is NULL.

model

Four models defined in Gu, Yung, and Cheung (2019). CORR and COV refer to analyses of correlation structures and covariance structures, respectively.

extraTries

This function calls OpenMx::mxTryHard() to obtain parameter estimates and their standard errors. extraTries is the number of extra runs. If extraTries=0, OpenMx::mxRun() is called.

...

Additional arguments passed to either OpenMx::mxTryHard() or OpenMx::mxRun().

Value

A list with class CanCorr. It stores the model in OpenMx objects. The fitted object is stored in mx.fit.

Note

cancorr expects the number of variables in Y_vars to be equal to or greater than that in X_vars. If there are fewer in Y_vars, you may swap between X_vars and Y_vars.

Author(s)

Mike W.-L. Cheung mikewlcheung@nus.edu.sg

References

Gu, F., Yung, Y.-F., & Cheung, M. W.-L. (2019). Four covariance structure models for canonical correlation analysis: A COSAN modeling approach. Multivariate Behavioral Research, 54(2), 192-223. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00273171.2018.1512847")}

See Also

Thorndike00, sas_ex1

Examples


## Canonical Correlation Analysis
cancorr(X_vars=c("Weight", "Waist", "Pulse"),
        Y_vars=c("Chins", "Situps", "Jumps"),
        data=sas_ex1)


mulSEM documentation built on Feb. 17, 2026, 1:07 a.m.