Description Usage Arguments Value Author(s) References Examples
Compute the Nonparametric canonical correlations between two data matrices
1 2 3 |
X |
The training data set containing n samples and p features |
Y |
The paired training data set containing n samples and q features |
XV |
The validation data set containing nv samples and p features |
YV |
The paired validation data set containing nv samples and q features |
XT |
The testing data set containing nt samples and p features |
YT |
The paired testing data set containing nt samples and q features |
d |
The dimension of the ouput transformed features |
hx |
The bandwidth parameters for the KDEs of X |
hy |
The bandwidth parameters for the KDEs of Y |
nx |
The number of nearest neighbors for the KDEs of X |
ny |
The number of nearest neighbors for the KDEs of Y |
PreComputedNNs |
The name of the .Rda file containing two n*nx matrices for the nearest neighbor indice and the nearest neighbor Euclidean distances for X, and two n*ny matrices for the nearest neighbor indice and the nearest neighbor Euclidean distances for Y. It is optional, only for debugging purposes. |
... |
X_new The d-dimensional projections of the training data X
Y_new The d-dimensional projections of the training data Y
XV_new The d-dimensional projections of the validation data X
YV_new The d-dimensional projections of the validation data Y
XT_new The d-dimensional projections of the testing data X
YT_new The d-dimensional projections of the testing data Y
The canonical correlation between X_new and Y_new
The canonical correlation between XV_new and YV_new
The canonical correlation between XT_new and YT_new
p value for X_new and V_new
p value XV_new and YV_new
p value XT_new and YT_new
Meiwen Jia, meiwen_jia@psych.mpg.de Ilaria Bonavita, ilaria_bonavita@psych.mpg.de
Michaeli, T., Wang, W., & Livescu, K. (2015). Nonparametric canonical correlation analysis. arXiv preprint arXiv:1511.04839.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | N <- 10000 # Overal number of examples (train+test)
N_paired <- 5000 # Number of training examples
MaxAngle <- 4*pi
MinRadius <-0.3
MaxRadius <- 8
NumNNs_X <- 20
NumNNs_Y <- 20
sx <- 0.5
sy <- 0.5
set.seed(8409)
## Generate data for views 1,2
t <- seq(0, MaxAngle, length.out = N)
r <- seq(MinRadius, MaxRadius, length.out = N) + 2*runif(N)
#### generate X, the noise can be added!
X <- cbind(r*cos(t+0*rnorm(N)*0.05), r*sin(t+0*rnorm(N)*0.05))
X <- X + 0*matrix(rnorm(N*2), ncol = 2)
#### generate Y, the noise can be added!
Y <- cbind(t+0*rnorm(N)*1, 2*rnorm(N))
Y <- Y + 0*cbind(rep(0, N), rnorm(N))
## Training data
PairedIndices <- sample(1:N, N_paired)
## Test (or validation) data
UnpairedIndices <- setdiff(1:N,PairedIndices)
ncca_res <- ncca.rsvd(X[PairedIndices,],Y[PairedIndices,], X[UnpairedIndices,],Y[UnpairedIndices,],
d = 2, hx = 0.75, hy = 0.75, nx = NumNNs_X, ny=NumNNs_Y)
cat("The nonparametric canonical correlation between X and Y is ", ncca_res$cor_XY, "\n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.