Package 'acca'

Title: A Canonical Correlation Analysis with Inferential Guaranties
Description: It performs Canonical Correlation Analysis and provides inferential guaranties on the correlation components. The p-values are computed following the resampling method developed in Winkler, A. M., Renaud, O., Smith, S. M., & Nichols, T. E. (2020). Permutation inference for canonical correlation analysis. NeuroImage, <doi:10.1016/j.neuroimage.2020.117065>. Furthermore, it provides plotting tools to visualize the results.
Authors: Livio Finos
Maintainer: livio finos <[email protected]>
License: GPL (>= 2)
Version: 0.2
Built: 2024-11-28 06:39:45 UTC
Source: CRAN

Help Index


A Canonical Correlation Analysis with Inferential Guaranties

Description

It performs Canonical Correlation Analysis and provides inferential guaranties on the correlation components. The p-values are computed following the resampling method developed in Winkler, A. M., Renaud, O., Smith, S. M., & Nichols, T. E. (2020). Permutation inference for canonical correlation analysis. NeuroImage, <doi:10.1016/j.neuroimage.2020.117065>. Furthermore, it provides plotting tools to visualize the results.

Author(s)

Livio Finos

Examples

set.seed(1)
X=matrix(rnorm(500),100,5)
Y=matrix(rnorm(700),100,7)
Z=matrix(rnorm(200),100,2)
mod=cc(X,Y,Z)
mod

ccbiplot(mod)

mod=cc_inference(mod, B = 100, numb_cc = 3)
mod

Methods for acca objects

Description

Methods for acca objects. The following are methods to extract and manipulate relevant information from a acca object.

Usage

## S3 method for class 'acca'
print(x, ...)

## S3 method for class 'acca'
summary(object, ...)

Arguments

x

an acca object

...

additional arguments to be passed

object

an acca


cc

Description

Very similar cancor() of package stats, but 1) it allows for X and Y to be rank deficient, 2) it allows for categorical variables and 3) it allows for covariates, 4) more (see below).

Usage

cc(X, Y, Zx = NULL, Zy = Zx, numb_cc = NULL, fill.na = FALSE)

Arguments

X

See x in cancor for a proper documentation.

Y

See y in cancor for a proper documentation.

Zx

(=NULL by default) covariates (i.e. nuisance) of X. If different from NULL, the X are residualized by Zx before entering cc(). IMPORTANT: if Zx is not NULL, include the intercept (if appropriate!)

Zy

(=Zx by default) covariates of Y. Same use of Zx.

numb_cc

number of (pairs of) canonical correlations to be extracted

fill.na

replace NA in X and Y with column mean before enter cc().

Value

It returns an acca object. This object contains the same list as returned by cc, while it also contains prop_expl_var which is a list reporting the proportion of explained (total) variance of X and Y by each component (i.e. mode).

L=matrix(rnorm(10),10,1) X=matrix(rnorm(50),10,5) Y=matrix(rnorm(70),10,7) Z=matrix(rnorm(20),10,2)

X[,1]=X[,1]+2*L Y[,1]=Y[,1]+2*L mod=cc(X,Y,Z) mod

ccbiplot(mod)


cc_inference

Description

For each pairs of components, it computes p-values to test the null hypothesis of no correlation between components. The p-values are computed following the resampling method developed in Winkler, A. M., Renaud, O., Smith, S. M., & Nichols, T. E. (2020). Permutation inference for canonical correlation analysis. NeuroImage, 220, 117065. https://doi.org/10.1016/j.neuroimage.2020.117065.

Usage

cc_inference(
  mod,
  B = 100,
  alpha_max = 0.5,
  numb_cc = NULL,
  resamp_type = "sign-flip",
  light = FALSE
)

Arguments

mod

an acca object.

B

(100 by default) number of random sampling

alpha_max

stop if p-value > alpha_max (alpha_max=0.5 by default).

numb_cc

stop after computing p-values for the first numb_cc are computed(numb_cc=NULL - the default - means compute all).

resamp_type

"sign-flip" (by default) or "permutation"

light

If TRUE the orthogonalization of the residuals of the projection on Z is not performed. For large sample size the two methods tend to overlap.

Value

It returns an acca object (see cc) with p-values for each pair of the numb_cc components.

Examples

set.seed(1)
X=matrix(rnorm(500),100,5)
Y=matrix(rnorm(700),100,7)
Z=matrix(rnorm(200),100,2)
mod=cc(X,Y,Z)
mod

ccbiplot(mod)

mod=cc_inference(mod, B = 100, numb_cc = 3)
mod

ccbiplot

Description

The function adapts the ggbiplot::ggbiplot() function to an acca-object.

Usage

ccbiplot(
  pcobj,
  choices = 1:2,
  scale = 1,
  pc.biplot = TRUE,
  obs.scale = 1 - scale,
  var.scale = scale,
  groups = NULL,
  shapes = NULL,
  ellipse = FALSE,
  ellipse.prob = 0.68,
  labels = NULL,
  labels.size = 3,
  alpha = 1,
  var.axes = TRUE,
  circle = FALSE,
  circle.prob = 0.69,
  varname.size = 3,
  varname.adjust = 1.5,
  varname.abbrev = FALSE,
  arrows.color = NULL,
  ...
)

Arguments

pcobj

an object returned by acca:cc()

choices

which PCs to plot

scale

covariance biplot (scale = 1), form biplot (scale = 0). When scale = 1, the inner product between the variables approximates the covariance and the distance between the points approximates the Mahalanobis distance.

pc.biplot

for compatibility with biplot.princomp()

obs.scale

scale factor to apply to observations

var.scale

scale factor to apply to variables

groups

optional factor variable indicating the groups that the observations belong to. If provided the points will be colored according to groups

shapes

which shapes to use when plotting observations

ellipse

draw a normal data ellipse for each group?

ellipse.prob

size of the ellipse in Normal probability

labels

optional vector of labels for the observations

labels.size

size of the text used for the labels

alpha

alpha transparency value for the points (0 = transparent, 1 = opaque)

var.axes

draw arrows for the variables?

circle

draw a correlation circle?

circle.prob

size of the circle in qchisq(circle.prob, df = 2)

varname.size

size of the text for variable names

varname.adjust

adjustment factor the placement of the variable names, >= 1 means farther from the arrow

varname.abbrev

whether or not to abbreviate the variable names

arrows.color

color of the arrows

...

not used yet

Value

It returns a ggplot object.