Description Usage Arguments Details Value Author(s) References See Also Examples
This function fits the solution path of canonical variate regression, with tuning parameters selected by cross validation. The tuning parameters include the rank, the η and the λ.
1 2 3 4 |
Y |
A univariate response variable. |
Xlist |
A list of two covariate matrices as in |
rankseq |
A sequence of candidate ranks. The default is a single value 2. |
neta |
Number of η values. The default is 10. |
etaseq |
A sequence of length |
nlam |
Number of λ values. The default is 50. |
Lamseq |
A matrix of λ values. The column number is the number of sets in |
family |
Type of response as in |
Wini |
A list of initial loading W's. The default is from the SparseCCA solution. See |
penalty |
Type of penalty on loading matrices W's as in |
nfold |
Number of folds in cross validation. The default is 10. |
foldid |
Specifying training and testing sets in cross validation; random generated if not supplied. It remains the same across different rank and η. |
opts |
A list of options for controlling the algorithm. The default of |
type.measure |
Type of measurement used in cross validation. |
In this function, the rank, η and λ are tuned by cross validation. CVR then is refitted with
all data using the selected tuning parameters. The plot
function shows the tuning of λ,
with selected rank and η.
An object with S3 class "CVR" containing the following components
cverror |
A matrix containing the CV errors. The number of rows is the length
of |
etahat |
Selected η. |
rankhat |
Selected rank. |
Lamhat |
Selected λ's. |
Alphapath |
An array containing the fitted paths of the intercept term α. |
Betapath |
An array containing the fitted paths of the regression coefficient β. |
W1path, W2path |
Arrays containing the fitted paths of W1 and W2. |
foldid |
|
cvout |
Cross validation results using selected η and rank. |
solution |
A list including the solutions of α, β, W1 and W2, by refitting all the data using selected tuning parameters. |
Chongliang Luo, Kun Chen.
Chongliang Luo, Jin Liu, Dipak D. Dey and Kun Chen (2016) Canonical variate regression. Biostatistics, doi: 10.1093/biostatistics/kxw001.
cvrsolver
, SparseCCA
, SimulateCVR
.
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | ############## Gaussian response ######################
set.seed(42)
mydata <- SimulateCVR(family = "g", n = 100, rank = 4, p1 = 50, p2 = 70,
pnz = 10, beta = c(2, 1, 0, 0))
X1 <- mydata$X1;
X2 <- mydata$X2
Xlist <- list(X1 = X1, X2 = X2);
Y <- mydata$y
## fix rank = 4, tune eta and lambda
##out_cvr <- CVR(Y, Xlist, rankseq = 4, neta = 5, nlam = 25,
## family = "g", nfold = 5)
## out_cvr$solution$W[[1]];
## out_cvr$solution$W[[2]];
### uncomment to see plots
## plot.CVR(out_cvr)
##
## Distance of subspaces
##U <- mydata$U
##Pj <- function(U) U %*% solve(t(U) %*% U, t(U))
##sum((Pj(U) - (Pj(X1 %*% out_cvr$sol$W[[1]]) + Pj(X2 %*% out_cvr$sol$W[[2]]))/2)^2)
## Precision/Recall rate
## the first 10 rows of the true W1 and W2 are set to be nonzero
##W12 <- rbind(out_cvr$sol$W[[1]], out_cvr$sol$W[[1]])
##W12norm <- apply(W12, 1, function(a)sqrt(sum(a^2)))
##prec <- sum(W12norm[c(1:10, 51:60)] != 0)/sum(W12norm != 0); prec
##rec <- sum(W12norm[c(1:10, 51:60)] != 0)/20; rec
## sequential SparseCCA, compare the Distance of subspaces and Prec/Rec
##W12s <- SparseCCA(X1, X2, 4)
## Distance larger than CVR's
##sum((Pj(U) - (Pj(X1 %*% W12s$W1) + Pj(X2 %*% W12s$W2))/2)^2)
##W12snorm <- apply(rbind(W12s$W1, W12s$W2), 1, function(a)sqrt(sum(a^2)))
## compare Prec/Rec
##sum(W12snorm[c(1:10, 51:60)] != 0)/sum(W12snorm != 0);
##sum(W12snorm[c(1:10, 51:60)] != 0)/20;
############## binary response ########################
set.seed(12)
mydata <- SimulateCVR(family = "binomial", n = 300, rank = 4, p1 = 50,
p2 = 70, pnz = 10, beta = c(2, 1, 0, 0))
X1 <- mydata$X1; X2 <- mydata$X2
Xlist <- list(X1 = X1, X2 = X2);
Y <- mydata$y
## out_cvr <- CVR(Y, Xlist, 4, neta = 5, nlam=25, family = "b", nfold = 5)
## out_cvr$sol$W[[1]];
## out_cvr$sol$W[[2]];
## plot.CVR(out_cvr)
############## Poisson response ######################
set.seed(34)
mydata <- SimulateCVR(family = "p", n = 100, rank = 4, p1 = 50,
p2 = 70, pnz = 10, beta = c(0.2, 0.1, 0, 0))
X1 <- mydata$X1; X2 <- mydata$X2
Xlist <- list(X1 = X1, X2 = X2);
Y <- mydata$y
## etaseq <- 10^seq(-3, log10(0.95), len = 10)
## out_cvr <- CVR(Y, Xlist, 4, neta = 5, nlam = 25, family = "p", nfold = 5)
## out_cvr$sol$W[[1]];
## out_cvr$sol$W[[2]];
## plot.CVR(out_cvr)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.