Learn R Programming

rSDR (version 1.0.3.0)

optimal_alpha_boot: The optimal alpha for rSDR via bootstrap resampling

Description

Perform R bootstrap replications of the cost function in rSDR method and return the corresponding optimal alpha.

Usage

optimal_alpha_boot(alpha.v,X,Y,d,R,maxiter=1000,tol=1e-7)

Value

An object of class "optimal_alpha_boot" is returned. The returned value contains the following components:

opt.alpha

value of alpha that gives minimum f_test.meam.

f_test.mean

The mean of cost function by the alpha sequence - a vector of length length(alpha.v).

f_test.sd

The standard deviation of cost function by the alpha sequence.

f_test

An \(R \times\) length(alpha.v) matrix. The cost value for each fold at a given alpha.

d

The value of d as passed to optimal_alpha_boot.

R

The value of R as passed to optimal_alpha_boot.

Arguments

alpha.v

user-supplied alpha sequence. The default is alpha.v=c(0.3,0.4,0.5,0.6,0.7).

X

an \(n \times p\) numeric matrix, where \(n\) is the number of observations and \(p\) is the number of variable.

Y

an \(n \times k\) numeric response matrix, where \(k (\geq 1)\) is the number of response variables.

d

the number of reduced dimension. The default is d=3.

R

the number of bootstrap replicates.

maxiter

maxiter is the maximum number of iterations allowed for the solver (a non-negative integer). See the Max_Iteration parameter in get.solver.params for details.

tol

tol is used to assess convergence, see the Tolerance parameter in get.solver.params for details.

Examples

Run this code
library(ManifoldOptim)
library(rSDR)
library(future)
library(future.apply)
utils::data("ionosphere", package = "fdm2id")
X<-as.matrix(ionosphere[,c(1:33)])
Y<-ifelse(ionosphere[,34]=='b',0,1)
Y<-matrix(Y,length(Y),1)
set.seed(2435)
# plan(multisession) will launch parallel workers running in the background
# to save running time. To shut down background workers launched this way, call
# plan(sequential)
# use all local cores except one
# future::plan(future::multisession, workers = future::availableCores() - 1)
# use 2 cores for parallel
# \donttest{
future::plan("multisession", workers = 2)
opt_results<-optimal_alpha_boot(alpha.v=c(0.3,0.5,0.7),X=X,Y=Y,d=3,R=5)
opt_results
future::plan(sequential)
# }

Run the code above in your browser using DataLab