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 |
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.
Livio Finos
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
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.
The following are methods to extract and manipulate relevant information from
a acca
object.
## S3 method for class 'acca' print(x, ...) ## S3 method for class 'acca' summary(object, ...)
## S3 method for class 'acca' print(x, ...) ## S3 method for class 'acca' summary(object, ...)
x |
an |
... |
additional arguments to be passed |
object |
an |
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).
cc(X, Y, Zx = NULL, Zy = Zx, numb_cc = NULL, fill.na = FALSE)
cc(X, Y, Zx = NULL, Zy = Zx, numb_cc = NULL, fill.na = FALSE)
X |
See |
Y |
See |
Zx |
( |
Zy |
( |
numb_cc |
number of (pairs of) canonical correlations to be extracted |
fill.na |
replace |
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)
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.
cc_inference( mod, B = 100, alpha_max = 0.5, numb_cc = NULL, resamp_type = "sign-flip", light = FALSE )
cc_inference( mod, B = 100, alpha_max = 0.5, numb_cc = NULL, resamp_type = "sign-flip", light = FALSE )
mod |
an |
B |
( |
alpha_max |
stop if p-value > alpha_max ( |
numb_cc |
stop after computing p-values for the first |
resamp_type |
|
light |
If |
It returns an acca
object (see cc
) with p-values for each pair of the numb_cc
components.
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
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
The function adapts the ggbiplot::ggbiplot()
function to an acca
-object.
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, ... )
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, ... )
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 |
It returns a ggplot
object.