getMomentsAndMomentCI {bootSVD}R Documentation

Calculate bootstrap moments and moment-based confidence intervals for the PCs.

Description

Let KK be the number of PCs of interest, let BB be the number of bootstrap samples, and let pp be the number of measurements per subject, also known as the dimension of the sample. In general, we use kk to refer to the principal component (PC) index, where k=1,2,...Kk=1,2,...K, and use bb to refer to the bootstrap index, where b=1,2,...Bb=1,2,...B.

Usage

getMomentsAndMomentCI(AsByK, V, K = length(AsByK), verbose = FALSE)

Arguments

AsByK

a list of the bootstrap PC matrices. This list should be indexed by kk, with the kthk^{th} element of the lsit containing a bb by pp matrix of results for the kthk^{th} PC, across bootstrap samples.

V

a (pp by nn) matrix containing the coordinate vectors for the matrices within the AsByK list, where nn is sample size and pp is sample dimension. Generally for bootstrap PCA, AsByK should contain the PCs for the bootstrap scores, and V should be the matrix of PCs from the original sample. The argument V may also be a ff object.

K

the number of leading PCs for which moments and confidence intervals should be obtained.

verbose

setting to TRUE will cause the function to print its progress in calculating the bootstrap variance for each PC.

Value

a list containing

EVs

a list containing element-wise bootstrap means for each of the K fitted PCs, indexed by k.

varVs

a list containing element-wise bootstrap variances for each of the K fitted PCs, indexed by k.

sdVs

a list containing element-wise bootstrap standard errors for each of the K fitted PCs, indexed by k.

momentCI

a list of (pp by 22) matrices, indexed by k, where momentCI[[k]][j,] is the pointwise moment-based CI for the jthj^{th} element of the kthk^{th} PC.

Examples


#use small n, small B, for a quick illustration
set.seed(0)
Y<-simEEG(n=100, centered=TRUE, wide=TRUE) 
svdY<-fastSVD(Y)
V<-svdY$v #right singular vectors of the wide matrix Y
DUt<- tcrossprod(diag(svdY$d),svdY$u)
bInds<-genBootIndeces(B=50,n=dim(DUt)[2])
bootSVD_LD_output<-bootSVD_LD(DUt=DUt,bInds=bInds,K=3,verbose=interactive())

AsByB<-bootSVD_LD_output$As
AsByK<-reindexMatricesByK(AsByB)
moments<-getMomentsAndMomentCI(AsByK,V,verbose=interactive())
plot(V[,1],type='l',ylim=c(-.1,.1),main='Original PC1, with CI in blue')
matlines(moments$momentCI[[1]],col='blue',lty=1)

#Can also use this function to get moments for low dimensional
#vectors A^b[,k], by setting V to the identity matrix.
moments_A<- getMomentsAndMomentCI(As=AsByK,V=diag(ncol(AsByK[[1]])))

[Package bootSVD version 1.1 Index]