Learn R Programming

flars (version 1.0)

fccaXX: Canonical correlation analysis between two groups of mixed functional and scalar variables

Description

This function carries out the canonical correlation analysis between two groups of mixed functional and scalar variables. Three different representing methods can be used for the functional coefficients. The tuning parameters should be specified in the arguments control1 and control2 for the two groups xL1 and xL2, respectively.

Usage

fccaXX(xL1,xL2,centre=TRUE,method=c('basis','gq','raw'),control1=list(), control2=list(),tol=1e-7)

Arguments

xL1
The mixed scalar and functional variables. For any number and any type of variables, xL1 should be a list. Each item of the list should correspond to one variable.
xL2
Same as xL1.
centre
Logic argument. Default is TRUE, which means the variables do need to be centred.
method
The representative methods for the functional coefficients. The method could be one of the 'basis', 'gq' and 'raw' for basis function expression, Gaussian quadrature and representative data points, respectively.
control1
List of elements that controls the details of the functional coefficients for xL1. See details for more information. See the argument control in function fccaGen for details.
control2
Similar to control1.
tol
The threshold to decide whether the correlation is to small to be non-zero.

Value

corr
All the non-zero canonical correlation.
coef1
The corresponding coefficients (weights) for the xL1.
coef2
The corresponding coefficients (weights) for the xL2.

Details

This function uses Moore-Penrose generalized inverse in the calculation to avoid sigular problem.

Examples

Run this code
# library(flars)
# library(fda)
## Generate some data sets.
# dataL1=data_generation(seed = 1,uncorr = FALSE,nVar = 8,nsamples = 120,
#       var_type = 'm',cor_type = 1)
# dataL1=dataL1$x

# dataL2=data_generation(seed = 2,uncorr = FALSE,nVar = 8,nsamples = 120,
#       var_type = 'm',cor_type = 1)
# dataL2=dataL2$x

## cross validation
# outCV=fccaXXcv(xL1 = dataL1[1:2], xL2 = dataL2[1:2], method = 'basis'
#      ,alpha = 10^seq(-6,0,len=5))

# cvCor=outCV$cor  
# calculate the correlation
# out=fccaXX(dataL1, dataL2, method = 'basis',control1 = list(pen1=
#      outCV$alpha[which.max(cvCor)]),control2 = list(pen1=
#      outCV$alpha[which.max(cvCor)]))

Run the code above in your browser using DataLab