Title: | Estimating and Testing the Number of Interesting Components in Linear Dimension Reduction |
---|---|
Description: | For different linear dimension reduction methods like principal components analysis (PCA), independent components analysis (ICA) and supervised linear dimension reduction tests and estimates for the number of interesting components (ICs) are provided. |
Authors: | Klaus Nordhausen [aut, cre] , Hannu Oja [aut] , David E. Tyler [aut], Joni Virta [aut] |
Maintainer: | Klaus Nordhausen <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.3-5 |
Built: | 2024-11-20 06:55:51 UTC |
Source: | CRAN |
Function to extract components from an object. If the object is of class ictest or ladle the user can choose if all components are extracted or only those which were interesting under the null hypothesis.
components(x, ...) ## S3 method for class 'ictest' components(x, which = "all", ...) ## S3 method for class 'ladle' components(x, which = "all", ...)
components(x, ...) ## S3 method for class 'ictest' components(x, which = "all", ...) ## S3 method for class 'ladle' components(x, which = "all", ...)
x |
an object which has a components method, like for example an ictest object. |
which |
for an object of class ictest. If |
... |
arguments passed on to other methods. |
a matrix with the components.
Klaus Nordhausen
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) head(components(TestCov)) head(components(TestCov, which = "k"))
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) head(components(TestCov)) head(components(TestCov, which = "k"))
Sliced Inverse Regression (SIR) can be seen as special case of Supervised ICS (SICS) and this function gives the supervised scatter matrix for SIR
covSIR(X, y, h = 10, ...)
covSIR(X, y, h = 10, ...)
X |
a numeric data matrix. |
y |
a numeric response vector. |
h |
the number of slices. |
... |
arguments passed on to |
This supervised scatter matrix is usually used as the second scatter matrix in SICS to obtain a SIR type supervised linear dimension reduction.
For that purpose covSIR
first divides the response y
into h
slices using the corresponding quantiles as cut points.
Then for each slice the mean vector of X
is computed and the resulting supervised scatter matrix consist of the covariance matrix of these mean vectors.
The function might have problems if the sample size is too small.
a supervised scatter matrix
Klaus Nordhausen
Liski, E., Nordhausen, K. and Oja, H. (2014), Supervised invariant coordinate selection, Statistics: A Journal of Theoretical and Applied Statistics, 48, 711–731. <doi:10.1080/02331888.2013.800067>.
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
X <- matrix(rnorm(1000), ncol = 5) eps <- rnorm(200, sd = 0.1) y <- 2 + 0.5 * X[, 1] + 2 * X[, 3] + eps covSIR(X, y)
X <- matrix(rnorm(1000), ncol = 5) eps <- rnorm(200, sd = 0.1) y <- 2 + 0.5 * X[, 1] + 2 * X[, 3] + eps covSIR(X, y)
In non-gaussian component analysis (NGCA) and independent components analysis (ICA) gaussian components are considered as uninteresting.
The function tests, based on FOBI, if there are p-k
gaussian components where p
is the dimension of the data.
The function offers three different test versions.
FOBIasymp(X, k, type = "S3", model = "NGCA", method = "satterthwaite")
FOBIasymp(X, k, type = "S3", model = "NGCA", method = "satterthwaite")
X |
numeric data matrix. |
k |
the number of non-gaussian components under the null. |
type |
which of the three tests to perform. Options are |
model |
What is the underlying assumption of the non-gaussian parts. Options are general |
method |
if |
The function jointly diagonalizes the regular covariance and the matrix of fourth moments. Note however that in this case the matrix of fourth moments
is not made consistent under the normal model by dividing it by , as for example done by the function
cov4
where denotes the dimension
of the data. Therefore
the eigenvalues of this generalized eigenvector-eigenvalue problem which correspond to normally distributed components should be
p+2
.
Given eigenvalues the function thus orders the components in decending order according to the values of
.
Under the null it is then assumed that the first k
interesting components are mutually independent and non-normal and the last p-k
are gaussian.
Three possible tests are then available to test this null hypothesis for a sample of size n:
type="S1"
: The test statistic T is the variance of the last p-k eigenvalues around p+2:
the limiting distribution of which under the null is the sum of two weighted chisquare distributions with weights:
and
.
and degrees of freedom:
and
.
type="S2"
: Another possible version for the test statistic is a scaled sum of the variance of the eigenvalues around the mean plus the variance around
the expected value under normality (p+2). Denote as the variance of the last p-k eigenvalues and
as the variance of these eigenvalues around
.
Then the test statistic is:
This test statistic has a limiting chisquare distribution with degrees of freedom.
type="S3"
: The third possible test statistic just checks the equality of the last p-k eigenvalues using only the first part of the test statistic of type="S2"
.
The test statistic is then:
and has a limiting chisquare distribution with degrees of freedom.
The constants and
depend on the underlying model assumptions as specified in argument
model
and are estimated from the data.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the degrees of freedom of the test or the degrees of freedoms and the corresponding weights of the test in case the test has as its limiting distribution a weighted sum of chisquare distributions. |
method |
character string denoting which test was performed. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number or non-gaussian components used in the testing problem. |
W |
the transformation matrix to the independent components. Also known as unmixing matrix. |
S |
data matrix with the centered independent components. |
D |
the underlying FOBI eigenvalues. |
MU |
the location of the data which was substracted before calculating the independent components. |
sigma1 |
the asymptotic constant sigma1 needed for the asymptotic test(s). |
sigma2 |
the asymptotic constant sigma2 needed for the asymptotic test(s). |
type |
the value of |
model |
the value of |
Klaus Nordhausen
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
Nordhausen, K., Oja, H., Tyler, D.E. and Virta, J. (2017), Asymptotic and Bootstrap Tests for the Dimension of the Non-Gaussian Subspace, Signal Processing Letters, 24, 887–891. <doi:10.1109/LSP.2017.2696880 >.
n <- 1500 S <- cbind(runif(n), rchisq(n, 2), rexp(n), rnorm(n), rnorm(n), rnorm(n)) A <- matrix(rnorm(36), ncol = 6) X <- S %*% t(A) FOBIasymp(X, k = 2) FOBIasymp(X, k = 3, type = "S1") FOBIasymp(X, k = 0, type = "S2", model = "ICA")
n <- 1500 S <- cbind(runif(n), rchisq(n, 2), rexp(n), rnorm(n), rnorm(n), rnorm(n)) A <- matrix(rnorm(36), ncol = 6) X <- S %*% t(A) FOBIasymp(X, k = 2) FOBIasymp(X, k = 3, type = "S1") FOBIasymp(X, k = 0, type = "S2", model = "ICA")
In independent components analysis (ICA) gaussian components are considered as uninteresting.
The function uses boostrappping tests, based on FOBI, to decide if there are p-k
gaussian components where p
is the dimension of the data.
The function offers two different boostrapping strategies.
FOBIboot(X, k, n.boot = 200, s.boot = "B1")
FOBIboot(X, k, n.boot = 200, s.boot = "B1")
X |
a numeric data matrix with p>1 columns. |
k |
the number of non-gaussian components under the null. |
n.boot |
number of bootstrapping samples. |
s.boot |
bootstrapping strategy to be used. Possible values are |
As in FOBIasymp
the function jointly diagonalizes the regular covariance and the matrix of fourth moments. Note that in this case the matrix of fourth moments
is not made consistent under the normal model by dividing it by , as for example done by the function
cov4
where denotes the dimension
of the data. Therefore the eigenvalues of this generalized eigenvector-eigenvalue problem which correspond to normally distributed components should be
p+2
.
Given eigenvalues the function thus orders the components in descending order according to the values of
.
Under the null it is then assumed that the first k
interesting components are mutually independent and non-normal and the last p-k
components are gaussian.
Let be the ordered eigenvalues,
the correspondingly ordered unmixing matrix,
the corresponding
source vectors which give the source matrix
which can be decomposed into
and
where
is the matrix with the
non-gaussian components
and
the matrix with the gaussian components (under the null).
The test statistic is then
Two possible bootstrap tests are provided for testing that the last p-k
components are gaussian and independent from the first k components:
s.boot="B1"
:
The first strategy has the followong steps:
Take a bootstrap sample of size
from
.
Take a bootstrap sample consisting of a matrix of standard normally distributed elements.
Combine and create
.
Compute the test statistic based on .
Repeat the previous steps n.boot
times.
Note that in this bootstrapping test the assumption of ”independent components” is not used, it is only used that the last components are gaussian and independent from the first
components. Therefore this strategy can be applied in an independent component analysis (ICA) framework
and in a non-gaussian components analysis (NGCA) framework.
s.boot="B2"
:
The second strategy has the following steps:
Take a bootstrap sample of size
from
where the subsampling is done separately for each independent component.
Take a bootstrap sample consisting of a matrix of standard normally distributed elemenets.
Combine and create
.
Compute the test statistic based on .
Repeat the previous steps n.boot
times.
This bootstrapping strategy assumes a full ICA model and cannot be used in an NGCA framework.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the number of boostrapping samples used to obtain the p-value. |
method |
character string which test was performed. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number or non-gaussian components used in the testing problem. |
W |
the transformation matrix to the independent components. Also known as unmixing matrix. |
S |
data matrix with the centered independent components. |
D |
the underlying FOBI eigenvalues. |
MU |
the location of the data which was substracted before calculating the independent components. |
s.boot |
character string which boostrapping strategy was used. |
Klaus Nordhausen
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
Nordhausen, K., Oja, H., Tyler, D.E. and Virta, J. (2017), Asymptotic and Bootstrap Tests for the Dimension of the Non-Gaussian Subspace, Signal Processing Letters, 24, 887–891. <doi:10.1109/LSP.2017.2696880 >.
n <- 1500 S <- cbind(runif(n), rchisq(n, 2), rexp(n), rnorm(n), rnorm(n), rnorm(n)) A <- matrix(rnorm(36), ncol = 6) X <- S %*% t(A) FOBIboot(X, k = 2) FOBIboot(X, k = 3, s.boot = "B1") FOBIboot(X, k = 0, s.boot = "B2")
n <- 1500 S <- cbind(runif(n), rchisq(n, 2), rexp(n), rnorm(n), rnorm(n), rnorm(n)) A <- matrix(rnorm(36), ncol = 6) X <- S %*% t(A) FOBIboot(X, k = 2) FOBIboot(X, k = 3, s.boot = "B1") FOBIboot(X, k = 0, s.boot = "B2")
The ladle estimator uses the eigenvalues and eigenvectors of FOBI to estimate the number of Gaussian components in ICA or NGCA.
FOBIladle(X, n.boot = 200, ncomp = ifelse(ncol(X) > 10, floor(ncol(X)/log(ncol(X))), ncol(X) - 1))
FOBIladle(X, n.boot = 200, ncomp = ifelse(ncol(X) > 10, floor(ncol(X)/log(ncol(X))), ncol(X) - 1))
X |
numeric data matrix. |
n.boot |
number of bootstrapping samples to be used. |
ncomp |
The number of components among which the ladle estimator is to be searched. The default here follows the recommendation of Luo and Li 2016. |
The model here assumes that in ICA or NGCA there are k non-gaussian components and p-k gaussian components. The idea is then to decide which eigenvalues differ from p+2. The ladle estimate for this purpose combines the values of the scaled eigenvalues and the variation of the eigenvectors based on bootstrapping. The idea there is that for distinct eigenvales the variation of the eigenvectors is small and for equal eigenvalues the corresponding eigenvectors have large variation.
This measure is then computed assuming k=0,..., ncomp
and the ladle estimate for k is the value where the measure takes its minimum.
A list of class ladle containing:
method |
the string FOBI. |
k |
the estimated number of non-gaussian components. |
fn |
vector giving the measures of variation of the eigenvectors using the bootstrapped eigenvectors for the different number of components. |
phin |
normalized eigenvalues of the FOBI matrix. |
gn |
the main criterion for the ladle estimate - the sum of fn and phin. k is the value where gn takes its minimum |
lambda |
the eigenvalues of the FOBI matrix. |
W |
the transformation matrix to the independent components. Also known as unmixing matrix. |
S |
data matrix with the centered independent components. |
MU |
the location of the data which was substracted before calculating the independent components. |
data.name |
the name of the data for which the ladle estimate was computed. |
Klaus Nordhausen
Luo, W. and Li, B. (2016), Combining Eigenvalues and Variation of Eigenvectors for Order Determination, Biometrika, 103. 875–887. <doi:10.1093/biomet/asw051>
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) test summary(test) plot(test) ladleplot(test)
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) test summary(test) plot(test) ladleplot(test)
The ladle plot is a measure to decide about the number of interesting components. Of interest for the ladle criterion is the minimum. The function here offers however also to plot other criterion values which are part of the actual ladle criterion.
ggladleplot(x, crit = "gn", type="l", ylab = crit, xlab = "component", main = deparse(substitute(x)), ...)
ggladleplot(x, crit = "gn", type="l", ylab = crit, xlab = "component", main = deparse(substitute(x)), ...)
x |
an object of class ladle. |
crit |
the criterion to be plotted, options are |
type |
plotting type. |
ylab |
default ylab value. |
xlab |
default xlab value. |
main |
default title. |
... |
other arguments for the plotting functions. |
The main criterion of the ladle is the scaled sum of the eigenvalues and the measure of variation of the eigenvectors up to the component of interest.
The sum is denoted "gn"
and the individual parts are "fn"
for the measure of the eigenvector variation and "phin"
for the scaled eigenvalues.
The last option "lambda"
corresponds to the unscaled eigenvalues yielding then a screeplot.
Klaus Nordhausen, Joni Virta
Luo, W. and Li, B. (2016), Combining Eigenvalues and Variation of Eigenvectors for Order Determination, Biometrika, 103. 875–887. <doi:10.1093/biomet/asw051>
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) ggladleplot(test) ggladleplot(test, crit="fn") ggladleplot(test, crit="phin") ggladleplot(test, crit="lambda")
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) ggladleplot(test) ggladleplot(test, crit="fn") ggladleplot(test, crit="phin") ggladleplot(test, crit="lambda")
For an object of class ictest, plots either the pairwise scatter plot matrix using ggpairs
from GGally, or the time series plots of the underlying components using ggplot2. The user can choose if only the components considered interesting or all of them should be plotted. Aesthetics can be passed to ggpairs as well.
## S3 method for class 'ictest' ggplot(data, mapping = aes(), mapvar = NULL, which = "all", ..., environment=parent.frame())
## S3 method for class 'ictest' ggplot(data, mapping = aes(), mapvar = NULL, which = "all", ..., environment=parent.frame())
data |
object of class ictest |
mapping |
aesthetic mapping, see documentation for |
mapvar |
data.frame of the external variables used by the aesthetic mappings. If |
which |
if |
... |
arguments passed on to |
environment |
not used but needed for consistency. |
If the component matrix has the class mts
, xts
or zoo
then a time series plot will be plotted using ggplot2. Otherwise, a pairwise scatter plot matrix will be plotted using GGally.
Klaus Nordhausen, Joni Virta
# The data X <- iris[, 1:4] # The aesthetics variables mapvar <- data.frame(iris[, 5]) colnames(mapvar) <- "species" TestCov <- PCAasymp(X, k = 2) ggplot(TestCov) ggplot(TestCov, aes(color = species), mapvar = mapvar, which = "k")
# The data X <- iris[, 1:4] # The aesthetics variables mapvar <- data.frame(iris[, 5]) colnames(mapvar) <- "species" TestCov <- PCAasymp(X, k = 2) ggplot(TestCov) ggplot(TestCov, aes(color = species), mapvar = mapvar, which = "k")
For an object of class ladle, plots either the pairwise scatter plot matrix using ggpairs
from GGally, or the time series plots of the underlying components using ggplot2. The user can choose if only the components considered interesting or all of them should be plotted. Aesthetics can be passed to ggpairs as well.
## S3 method for class 'ladle' ggplot(data, mapping = aes(), mapvar = NULL, which = "all", ..., environment=parent.frame())
## S3 method for class 'ladle' ggplot(data, mapping = aes(), mapvar = NULL, which = "all", ..., environment=parent.frame())
data |
object of class ladle |
mapping |
aesthetic mapping, see documentation for |
mapvar |
data.frame of the external variables used by the aesthetic mappings. If |
which |
if |
... |
arguments passed on to |
environment |
not used but needed for consistency. |
If the component matrix has the class mts
, xts
or zoo
then a time series plot will be plotted using ggplot2. Otherwise, a pairwise scatter plot matrix will be plotted using GGally.
Klaus Nordhausen, Joni Virta
# The data X <- as.matrix(iris[, 1:4]) # The aesthetics variables mapvar <- data.frame(iris[, 5]) colnames(mapvar) <- "species" ladle_res <- PCAladle(X) # The estimate summary(ladle_res) # Plots of the components ggplot(ladle_res) ggplot(ladle_res, aes(color = species), mapvar = mapvar, which = "k")
# The data X <- as.matrix(iris[, 1:4]) # The aesthetics variables mapvar <- data.frame(iris[, 5]) colnames(mapvar) <- "species" ladle_res <- PCAladle(X) # The estimate summary(ladle_res) # Plots of the components ggplot(ladle_res) ggplot(ladle_res, aes(color = species), mapvar = mapvar, which = "k")
A generic method for ggplot2-style screeplots.
ggscreeplot(x, ...)
ggscreeplot(x, ...)
x |
An object of an appropriate class. |
... |
Additional arguments. |
Joni Virta, Klaus Nordhausen
Plots the criterion values of an ictest
object against its index number using ggplot2. Two versions of this screeplot are available.
## S3 method for class 'ictest' ggscreeplot(x, type = "barplot", main = deparse(substitute(x)), ylab = "criterion", xlab = "component", ...)
## S3 method for class 'ictest' ggscreeplot(x, type = "barplot", main = deparse(substitute(x)), ylab = "criterion", xlab = "component", ...)
x |
object of class |
type |
|
main |
main title of the plot. |
ylab |
y-axis label. |
xlab |
x-axis label. |
... |
arguments passed to and from methods. |
Klaus Nordhausen, Joni Virta
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) ggscreeplot(TestCov)
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) ggscreeplot(TestCov)
In independent components analysis (ICA) gaussian components are considered as uninteresting.
The function uses boostrappping tests, based on ICS using any combination of two scatter matrices, to decide if there are p-k
gaussian components where p
is the dimension of the data.
The function offers two different boostrapping strategies.
ICSboot(X, k, S1=cov, S2=cov4, S1args=NULL, S2args=NULL, n.boot = 200, s.boot = "B1")
ICSboot(X, k, S1=cov, S2=cov4, S1args=NULL, S2args=NULL, n.boot = 200, s.boot = "B1")
X |
a numeric data matrix with p>1 columns. |
k |
the number of non-gaussian components under the null. |
S1 |
name of the first scatter matrix function. Can only return a matrix. Default is |
.
S2 |
name of the second scatter matrix function. Can only return a matrix. Default is |
S1args |
list with optional additional arguments for |
S2args |
list with optional additional arguments for |
n.boot |
number of bootstrapping samples. |
s.boot |
bootstrapping strategy to be used. Possible values are |
While in FOBIasymp
and FOBIboot
the two scatters used are always cov
and cov4
this function can be used with any two scatter functions. In that case however the value of the Gaussian eigenvalues are in general not known and depend on the scatter functions used. Therefore the test uses as test statistic the k
successive eigenvalues with the smallest variance. Which means the default here might differ from FOBIasymp
and FOBIboot
.
Given eigenvalues the function thus orders the components in descending order according to the "variance" criterion .
Under the null it is then assumed that the first k
interesting components are mutually independent and non-normal and the last p-k
components are gaussian.
Let be the ordered eigenvalues,
the correspondingly ordered unmixing matrix,
the corresponding
source vectors which give the source matrix
which can be decomposed into
and
where
is the matrix with the
non-gaussian components
and
the matrix with the gaussian components (under the null).
Two possible bootstrap tests are provided for testing that the last p-k
components are gaussian and independent from the first k components:
s.boot="B1"
:
The first strategy has the followong steps:
Take a bootstrap sample of size
from
.
Take a bootstrap sample consisting of a matrix with gaussian random variables having
.
Combine and create
.
Compute the test statistic based on .
Repeat the previous steps n.boot
times.
Note that in this bootstrapping test the assumption of ”independent components” is not used, it is only used that the last components are gaussian and independent from the first
components. Therefore this strategy can be applied in an independent component analysis (ICA) framework
and in a non-gaussian components analysis (NGCA) framework.
s.boot="B2"
:
The second strategy has the following steps:
Take a bootstrap sample of size
from
where the subsampling is done separately for each independent component.
Take a bootstrap sample consisting of a matrix with gaussian random variables having
Combine and create
.
Compute the test statistic based on .
Repeat the previous steps n.boot
times.
This bootstrapping strategy assumes a full ICA model and cannot be used in an NGCA framework. Note that when the goal is to recover the non-gaussian independent components both scatters used must have the independence property.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the number of boostrapping samples used to obtain the p-value. |
method |
character string which test was performed and which scatters were used. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number or non-gaussian components used in the testing problem. |
W |
the transformation matrix to the independent components. Also known as unmixing matrix. |
S |
data matrix with the centered independent components. |
D |
the underlying eigenvalues. |
MU |
the location of the data which was substracted before calculating the independent components. |
s.boot |
character string which boostrapping strategy was used. |
Klaus Nordhausen
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
Nordhausen, K., Oja, H., Tyler, D.E. and Virta, J. (2017), Asymptotic and Bootstrap Tests for the Dimension of the Non-Gaussian Subspace, Signal Processing Letters, 24, 887–891. <doi:10.1109/LSP.2017.2696880>.
Radojicic, U. and Nordhausen, K. (2020), Non-Gaussian Component Analysis: Testing the Dimension of the Signal Subspace. In Maciak, M., Pestas, M. and Schindler, M. (editors) "Analytical Methods in Statistics. AMISTAT 2019", 101–123, Springer, Cham. <doi:10.1007/978-3-030-48814-7_6>.
n <- 750 S <- cbind(runif(n), rchisq(n, 2), rexp(n), rnorm(n), rnorm(n), rnorm(n)) A <- matrix(rnorm(36), ncol = 6) X <- S %*% t(A) # n.boot is small for demonstration purpose, should be larger ICSboot(X, k=1, n.boot=20) if(require("ICSNP")){ myTyl <- function(X,...) HR.Mest(X,...)$scatter myT <- function(X,...) tM(X,...)$V # n.boot is small for demonstration purpose, should be larger ICSboot(X, k=3, S1=myT, S2=myTyl, s.boot = "B2", n.boot=20) }
n <- 750 S <- cbind(runif(n), rchisq(n, 2), rexp(n), rnorm(n), rnorm(n), rnorm(n)) A <- matrix(rnorm(36), ncol = 6) X <- S %*% t(A) # n.boot is small for demonstration purpose, should be larger ICSboot(X, k=1, n.boot=20) if(require("ICSNP")){ myTyl <- function(X,...) HR.Mest(X,...)$scatter myT <- function(X,...) tM(X,...)$V # n.boot is small for demonstration purpose, should be larger ICSboot(X, k=3, S1=myT, S2=myTyl, s.boot = "B2", n.boot=20) }
The ladle estimates the rank of a symmetric matrix by combining the classical screeplot with an estimate of the rank from the bootstrap eigenvector variability of
.
ladle(x, S, n.boots = 200, ...)
ladle(x, S, n.boots = 200, ...)
x |
|
S |
Function for computing a |
n.boots |
The number of bootstrap samples. |
... |
Furhter parameters passed to |
Assume that the eigenvalues of the population version of S
are . The ladle estimates the true value of
(for example the rank of
S
) by combining the classical screeplot with estimate of from the bootstrap eigenvector variability of
S
.
For applying the ladle to either PCA, FOBI or SIR, see the dedicated functions PCAladle
, FOBIladle
, SIRladle
.
A list of class ladle
containing:
method |
The string “general”. |
k |
The estimated value of k. |
fn |
A vector giving the measures of variation of the eigenvectors using the bootstrapped eigenvectors for the different number of components. |
phin |
The normalized eigenvalues of the S matrix. |
gn |
The main criterion for the ladle estimate - the sum of fn and phin. k is the value where gn takes its minimum. |
lambda |
The eigenvalues of the covariance matrix. |
data.name |
The name of the data for which the ladle estimate was computed. |
Joni Virta
Luo, W. and Li, B. (2016), Combining Eigenvalues and Variation of Eigenvectors for Order Determination, Biometrika, 103. 875-887. <doi:10.1093/biomet/asw051>
# Function for computing the left CCA matrix S_CCA <- function(x, dim){ x1 <- x[, 1:dim] x2 <- x[, -(1:dim)] stand <- function(x){ x <- as.matrix(x) x <- sweep(x, 2, colMeans(x), "-") eigcov <- eigen(cov(x), symmetric = TRUE) x%*%(eigcov$vectors%*%diag((eigcov$values)^(-1/2))%*%t(eigcov$vectors)) } x1stand <- stand(x1) x2stand <- stand(x2) crosscov <- cov(x1stand, x2stand) tcrossprod(crosscov) } # Toy data with two canonical components n <- 200 x1 <- matrix(rnorm(n*5), n, 5) x2 <- cbind(x1[, 1] + rnorm(n, sd = sqrt(0.5)), -1*x1[, 1] + x1[, 2] + rnorm(n, sd = sqrt(0.5)), matrix(rnorm(n*3), n, 3)) x <- cbind(x1, x2) # The ladle estimate ladle_1 <- ladle(x, S_CCA, dim = 5) ladleplot(ladle_1)
# Function for computing the left CCA matrix S_CCA <- function(x, dim){ x1 <- x[, 1:dim] x2 <- x[, -(1:dim)] stand <- function(x){ x <- as.matrix(x) x <- sweep(x, 2, colMeans(x), "-") eigcov <- eigen(cov(x), symmetric = TRUE) x%*%(eigcov$vectors%*%diag((eigcov$values)^(-1/2))%*%t(eigcov$vectors)) } x1stand <- stand(x1) x2stand <- stand(x2) crosscov <- cov(x1stand, x2stand) tcrossprod(crosscov) } # Toy data with two canonical components n <- 200 x1 <- matrix(rnorm(n*5), n, 5) x2 <- cbind(x1[, 1] + rnorm(n, sd = sqrt(0.5)), -1*x1[, 1] + x1[, 2] + rnorm(n, sd = sqrt(0.5)), matrix(rnorm(n*3), n, 3)) x <- cbind(x1, x2) # The ladle estimate ladle_1 <- ladle(x, S_CCA, dim = 5) ladleplot(ladle_1)
The ladle plot is a measure to decide about the number of interesting components. Of interest for the ladle criterion is the minimum. The function here offers however also to plot other criterion values which are part of the actual ladle criterion.
ladleplot(x, crit = "gn", type="l", ylab = crit, xlab = "component", main = deparse(substitute(x)), ...)
ladleplot(x, crit = "gn", type="l", ylab = crit, xlab = "component", main = deparse(substitute(x)), ...)
x |
an object of class ladle. |
crit |
the criterion to be plotted, options are |
type |
plotting type. |
ylab |
default ylab value. |
xlab |
default xlab value. |
main |
default title. |
... |
other arguments for the plotting functions. |
The main criterion of the ladle is the scaled sum of the eigenvalues and the measure of variation of the eigenvectors up to the component of interest.
The sum is denoted "gn"
and the individual parts are "fn"
for the measure of the eigenvector variation and "phin"
for the scaled eigenvalues.
The last option "lambda"
corresponds to the unscaled eigenvalues yielding then a screeplot.
Klaus Nordhausen
Luo, W. and Li, B. (2016), Combining Eigenvalues and Variation of Eigenvectors for Order Determination, Biometrika, 103. 875–887. <doi:10.1093/biomet/asw051>
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) ladleplot(test) ladleplot(test, crit="fn") ladleplot(test, crit="phin") ladleplot(test, crit="lambda")
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) ladleplot(test) ladleplot(test, crit="fn") ladleplot(test, crit="phin") ladleplot(test, crit="lambda")
Estimates non-Gaussian signal components using projection pursuit. The projection index can be chosen among convex combinations of squares of one or several standard projection indices used in ICA.
NGPP(X, k, nl = c("skew", "pow3"), alpha = 0.8, method = "symm", eps = 1e-6, verbose = FALSE, maxiter = 100)
NGPP(X, k, nl = c("skew", "pow3"), alpha = 0.8, method = "symm", eps = 1e-6, verbose = FALSE, maxiter = 100)
X |
Numeric matrix with n rows corresponding to the observations and p columns corresponding to the variables. |
k |
Number of components to estimate, |
nl |
Vector of non-linearities, a convex combination of the corresponding squared objective functions of which is then used as the projection index. The choices include |
alpha |
Vector of positive weights between 0 and 1 given to the non-linearities. The length of |
method |
If |
eps |
Convergence tolerance. |
verbose |
If |
maxiter |
Maximum number of iterations. |
It is assumed that the data is a random sample from the model where the latent vector
consists of
-dimensional non-Gaussian subvector (the signal) and
-dimensional Gaussian subvector (the noise) and the components of
are mutually independent. Without loss of generality we further assume that the components of
have zero means and unit variances.
The objective is to estimate an inverse for the mixing matrix and in non-Gaussian projection pursuit this is done by first standardizaing the observations and then finding mutually orthogonal directions maximizing a convex combination of the chosen squared objective functions.
After estimation the found signals are ordered in decreasing order with respect to their objective function values.
A list with class 'bss' containing the following components:
W |
Estimated unmixing matrix |
S |
Matrix of size |
D |
Vector of the objective function values of the signals |
MU |
Location vector of the data which was substracted before estimating the signal components. |
Joni Virta
Virta, J., Nordhausen, K. and Oja, H., (2016), Projection Pursuit for non-Gaussian Independent Components, <https://arxiv.org/abs/1612.05445>.
# Simulated data with 2 signals n <- 500 S <- cbind(rexp(n), runif(n), rnorm(n)) A <- matrix(rnorm(9), ncol = 3) X <- S %*% t(A) res <- NGPP(X, 2) res$W %*% A # Iris data X <- as.matrix(iris[, 1:4]) res <- NGPP(X, 2, nl = c("pow3", "tanh"), alpha = 0.5) plot(res, col = iris[, 5])
# Simulated data with 2 signals n <- 500 S <- cbind(rexp(n), runif(n), rnorm(n)) A <- matrix(rnorm(9), ncol = 3) X <- S %*% t(A) res <- NGPP(X, 2) res$W %*% A # Iris data X <- as.matrix(iris[, 1:4]) res <- NGPP(X, 2, nl = c("pow3", "tanh"), alpha = 0.5) plot(res, col = iris[, 5])
Estimates the dimension of the signal subspace using NGPP to conduct sequential hypothesis testing. The test statistic is a multivariate extension of the classical Jarque-Bera statistic and the distribution of it under the null hypothesis is obtained by simulation.
NGPPest(X, nl = c("skew", "pow3"), alpha = 0.8, N = 500, eps = 1e-6, verbose = FALSE, maxiter = 100)
NGPPest(X, nl = c("skew", "pow3"), alpha = 0.8, N = 500, eps = 1e-6, verbose = FALSE, maxiter = 100)
X |
Numeric matrix with n rows corresponding to the observations and p columns corresponding to the variables. |
nl |
Vector of non-linearities, a convex combination of the corresponding squared objective functions of which is then used as the projection index. The choices include |
alpha |
Vector of positive weights between 0 and 1 given to the non-linearities. The length of |
N |
Number of normal samples to be used in simulating the distribution of the test statistic under the null hypothesis. |
eps |
Convergence tolerance. |
verbose |
If |
maxiter |
Maximum number of iterations. |
It is assumed that the data is a random sample from the model where the latent vector
consists of
-dimensional non-Gaussian subvector (the signal) and
-dimensional Gaussian subvector (the noise) and the components of
are mutually independent. Without loss of generality we further assume that the components of
have zero means and unit variances.
The algorithm first estimates full components from the data using deflation-based NGPP with the chosen non-linearities and weighting and then tests the null hypothesis
for each
. The testing is based on the fact that under the null hypothesis
the distribution of the final
components is standard multivariate normal and the significance of the test can be obtained by comparing the objective function value of the
th estimated components to the same quantity estimated from
N
samples of size from
-dimensional standard multivariate normal distribution.
Note that if maxiter
is reached at any step of the algorithm it will use the current estimated direction and continue to the next step.
A list with class 'icest' containing the following components:
statistic |
Test statistic, i.e. the objective function values of all estimated component. |
p.value |
Obtained vector of |
parameter |
Number |
method |
Character string |
data.name |
Character string giving the name of the data. |
W |
Estimated unmixing matrix |
S |
Matrix of size |
D |
Vector of the objective function values of the signals |
MU |
Location vector of the data which was substracted before estimating the signal components. |
conv |
Boolean vector telling for which components the algorithm converged ( |
Joni Virta
Virta, J., Nordhausen, K. and Oja, H., (2016), Projection Pursuit for non-Gaussian Independent Components, <https://arxiv.org/abs/1612.05445>.
# Iris data X <- as.matrix(iris[, 1:4]) # The number of simulations N should be increased in practical situations # Now we settle for N = 100 res <- NGPPest(X, N = 100) res$statistic res$p.value res$conv
# Iris data X <- as.matrix(iris[, 1:4]) # The number of simulations N should be increased in practical situations # Now we settle for N = 100 res <- NGPPest(X, N = 100) res$statistic res$p.value res$conv
Tests whether the true dimension of the signal subspace is less than or equal to a given . The test statistic is a multivariate extension of the classical Jarque-Bera statistic and the distribution of it under the null hypothesis is obtained by simulation.
NGPPsim(X, k, nl = c("skew", "pow3"), alpha = 0.8, N = 1000, eps = 1e-6, verbose = FALSE, maxiter = 100)
NGPPsim(X, k, nl = c("skew", "pow3"), alpha = 0.8, N = 1000, eps = 1e-6, verbose = FALSE, maxiter = 100)
X |
Numeric matrix with n rows corresponding to the observations and p columns corresponding to the variables. |
k |
Number of components to estimate, |
nl |
Vector of non-linearities, a convex combination of the corresponding squared objective functions of which is then used as the projection index. The choices include |
alpha |
Vector of positive weights between 0 and 1 given to the non-linearities. The length of |
N |
Number of normal samples to be used in simulating the distribution of the test statistic under the null hypothesis. |
eps |
Convergence tolerance. |
verbose |
If |
maxiter |
Maximum number of iterations. |
It is assumed that the data is a random sample from the model where the latent vector
consists of
-dimensional non-Gaussian subvector (the signal) and
-dimensional Gaussian subvector (the noise) and the components of
are mutually independent. Without loss of generality we further assume that the components of
have zero means and unit variances.
To test the null hypothesis the algorithm first estimates
components using delfation-based NGPP with the chosen non-linearities and weighting. Under the null hypothesis the distribution of the final
components is standard multivariate normal and the significance of the test is obtained by comparing the objective function value of the
th estimated components to the same quantity estimated from
N
samples of size from
-dimensional standard multivariate normal distribution.
Note that if maxiter
is reached at any step of the algorithm it will use the current estimated direction and continue to the next step.
A list with class 'ictest', inheriting from the class 'hctest', containing the following components:
statistic |
Test statistic, i.e. the objective function value of the ( |
p.value |
Obtained |
parameter |
Number |
method |
Character string denoting which test was performed. |
data.name |
Character string giving the name of the data. |
alternative |
Alternative hypothesis, i.e. |
k |
Tested dimension |
W |
Estimated unmixing matrix |
S |
Matrix of size |
D |
Vector of the objective function values of the signals |
MU |
Location vector of the data which was substracted before estimating the signal components. |
Joni Virta
Virta, J., Nordhausen, K. and Oja, H., (2016), Projection Pursuit for non-Gaussian Independent Components, <https://arxiv.org/abs/1612.05445>.
# Simulated data with 2 signals and 2 noise components n <- 200 S <- cbind(rexp(n), rbeta(n, 1, 2), rnorm(n), rnorm(n)) A <- matrix(rnorm(16), ncol = 4) X <- S %*% t(A) # The number of simulations N should be increased in practical situations # Now we settle for N = 100 res1 <- NGPPsim(X, 1, N = 100) res1 screeplot(res1) res2 <- NGPPsim(X, 2, N = 100) res2 screeplot(res2)
# Simulated data with 2 signals and 2 noise components n <- 200 S <- cbind(rexp(n), rbeta(n, 1, 2), rnorm(n), rnorm(n)) A <- matrix(rnorm(16), ncol = 4) X <- S %*% t(A) # The number of simulations N should be increased in practical situations # Now we settle for N = 100 res1 <- NGPPsim(X, 1, N = 100) res1 screeplot(res1) res2 <- NGPPsim(X, 2, N = 100) res2 screeplot(res2)
The function tests, assuming an elliptical model, that the last p-k
eigenvalues of
a scatter matrix are equal and the k
interesting components are those with a larger variance.
The scatter matrices that can be used here are the regular covariance matrix and Tyler's shape matrix.
PCAasymp(X, k, scatter = "cov", ...)
PCAasymp(X, k, scatter = "cov", ...)
X |
a numeric data matrix with p>1 columns. |
k |
the number of eigenvalues larger than the equal ones. Can be between 0 and p-2. |
scatter |
the scatter matrix to be used. Can be |
... |
arguments passed on to |
The functions assumes an elliptical model and tests if the last eigenvalues of PCA are equal. PCA can here be either be based on the regular covariance matrix or on Tyler's shape matrix.
For a sample of size , the test statistic is
where is the mean of the last
PCA eigenvalues.
The constant is for the regular covariance matrix estimated from the data whereas for Tyler's shape matrix it is simply a function of the dimension of the data.
The test statistic has a limiting chisquare distribution with degrees of freedom.
Note that the regular covariance matrix is here divided by and not by
.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the degrees of freedom of the test. |
method |
character string which test was performed. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number or larger eigenvalues used in the testing problem. |
W |
the transformation matrix to the principal components. |
S |
data matrix with the centered principal components. |
D |
the underlying eigenvalues. |
MU |
the location of the data which was substracted before calculating the principal components. |
SCATTER |
the computed scatter matrix. |
sigma1 |
the asymptotic constant needed for the asymptotic test. |
Klaus Nordhausen
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) TestCov TestTyler <- PCAasymp(X, k = 1, scatter = "tyler") TestTyler
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) TestCov TestTyler <- PCAasymp(X, k = 1, scatter = "tyler") TestTyler
For p-variate data, the augmentation estimate for PCA assumes that the last p-k eigenvalues are equal. Combining information from the eigenvalues and eigenvectors of the covariance matrix the augmentation estimator yields an estimate for k.
PCAaug(X, noise = "median", naug = 1, nrep = 1, sigma2 = NULL, alpha = NULL)
PCAaug(X, noise = "median", naug = 1, nrep = 1, sigma2 = NULL, alpha = NULL)
X |
numeric data matrix. |
noise |
name of the method to be used to estimate the noise variance. Options are |
naug |
number of components to be augmented. |
nrep |
number of repetitions for the augmentation procedure. |
sigma2 |
value of the noise variance when |
alpha |
the quantile to be used when |
The model here assumes that the eigenvalues of the covariance matrix are of the form
and the goal is to estimate the value of k. The value
corresponds then to the noise variance.
The augmented estimator adds for that purpose naug
Gaussian components with the provided noise variance which needs to be provided
(noise = "known"
) or estimated from the data. Three estimation methods are available. In the case of noise = "median"
the estimate is the median of the eigenvalues of the covariance matrix, in the case of noise = "last"
it corresponds to the last eigenvalue of the covariance matrix and in the case of noise = "quantile"
it is the mean of the eigenvalues smaller or equal to the alpha
-quantile of the eigenvalues of the covariance matrix.
The augmentation estimator uses then the augmented components to measure the variation of the eigenvalues. For a more stable result it is recommened to repeat the augmentation process several times and Lue and Li (2021) recommend to use for naug
approximately p/5
or p/10
where p
is the number of columns of X
.
The augmented estimator for this purpose combines then the values of the scaled eigenvalues and the variation measured via augmentation. The main idea there is that for distinct eigenvales the variation of the eigenvectors is small and for equal eigenvalues the corresponding eigenvectors have large variation.
The augmented estimate for k is the value where the measure takes its minimum and can be also visualized as a ladle.
For further details see Luo and Li (2021) and Radojicic et al. (2021).
A list of class ladle containing:
method |
the string PCA. |
k |
the estimated value of k. |
fn |
vector giving the measures of variation of the eigenvectors using the bootstrapped eigenvectors for the different number of components. |
phin |
normalized eigenvalues of the covariance matrix. |
gn |
the main criterion for the augmented estimate - the sum of fn and phin. k is the value where gn takes its minimum |
lambda |
the eigenvalues of the covariance matrix. |
W |
the transformation matrix to the principal components. |
S |
data matrix with the centered principal components. |
MU |
the location of the data which was substracted before calculating the principal components. |
data.name |
the name of the data for which the augmented estimate was computed. |
sigma2 |
the value used as noise variance when simulating the augmented components. |
Klaus Nordhausen
Luo, W. and Li, B. (2021), On Order Determination by Predictor Augmentation, Biometrika, 108, 557–574. <doi:10.1093/biomet/asaa077>
Radojicic, U., Lietzen, N., Nordhausen, K. and Virta, J. (2021), Dimension Estimation in Two-Dimensional PCA. In S. Loncaric, T. Petkovic and D. Petrinovic (editors) "Proceedings of the 12 International Symposium on Image and Signal Processing and Analysis (ISPA 2021)", 16–22. <doi:10.1109/ISPA52656.2021.9552114>
n <- 1000 Y <- cbind(rnorm(n, sd=2), rnorm(n,sd=2), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) testPCA <- PCAaug(Y) testPCA summary(testPCA) plot(testPCA) ladleplot(testPCA) ladleplot(testPCA, crit = "fn") ladleplot(testPCA, crit = "lambda") ladleplot(testPCA, crit = "phin")
n <- 1000 Y <- cbind(rnorm(n, sd=2), rnorm(n,sd=2), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) testPCA <- PCAaug(Y) testPCA summary(testPCA) plot(testPCA) ladleplot(testPCA) ladleplot(testPCA, crit = "fn") ladleplot(testPCA, crit = "lambda") ladleplot(testPCA, crit = "phin")
The function tests, assuming an elliptical model, that the last p-k
eigenvalues of
a scatter matrix are equal and the k
interesting components are those with a larger variance.
To obtain p-values two different bootstrapping strategies are available and the user can provide the scatter matrix to be used
as a function.
PCAboot(X, k, n.boot = 200, s.boot = "B1", S = MeanCov, Sargs = NULL)
PCAboot(X, k, n.boot = 200, s.boot = "B1", S = MeanCov, Sargs = NULL)
X |
a numeric data matrix with p>1 columns. |
k |
the number of eigenvalues larger than the equal ones. Can be between 0 and p-2. |
n.boot |
number of bootstrapping samples. |
s.boot |
bootstrapping strategy to be used. Possible values are |
S |
A function which returns a list that has as its first element a location vector and as the second element the scatter matrix. |
Sargs |
list of further arguments passed on to the function specified in |
Here the function S
needs to return a list where the first argument is a location vector and the second one a scatter matrix.
The location is used to center the data and the scatter matrix is used to perform PCA.
Consider X as the centered data and denote by W the transformation matrix to the principal components. The corresponding eigenvalues
from PCA are . Under the null,
.
Denote further by
the mean of the last
p-k
eigenvalues and by a
diagonal matrix. Assume that
is the matrix with principal components which can be decomposed into
and
where
contains the k interesting principal components and
the last
principal components.
For a sample of size , the test statistic used for the boostrapping tests is
The function offers then two boostrapping strategies:
s.boot="B1"
:
The first strategy has the following steps:
Take a bootstrap sample of size
from
and decompose it into
and
.
Every observation in is transformed with a different random orthogonal matrix.
Recombine and create
.
Compute the test statistic based on .
Repeat the previous steps n.boot
times.
s.boot="B2"
:
The second strategy has the following steps:
Scale each principal component using the matrix , i.e.
.
Take a bootstrap sample of size
from
.
Every observation in is transformed with a different random orthogonal matrix.
Recreate .
Compute the test statistic based on .
Repeat the previous steps n.boot
times.
To create the random orthogonal matrices the function rorth
is used.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the degrees of freedom of the test. |
method |
character string which test was performed. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number or larger eigenvalues used in the testing problem. |
W |
the transformation matrix to the principal components. |
S |
data matrix with the centered principal components. |
D |
the underlying eigenvalues. |
MU |
the location of the data which was substracted before calculating the principal components. |
SCATTER |
The computed scatter matrix. |
scatter |
character string denoting which scatter function was used. |
s.boot |
character string denoting which bootstrapping test version was used. |
Klaus Nordhausen
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) # for demonstration purpose the n.boot is chosen small, should be larger in real applications TestCov <- PCAboot(X, k = 2, n.boot=30) TestCov TestTM <- PCAboot(X, k = 1, n.boot=30, s.boot = "B2", S = "tM", Sargs = list(df=2)) TestTM
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) # for demonstration purpose the n.boot is chosen small, should be larger in real applications TestCov <- PCAboot(X, k = 2, n.boot=30) TestCov TestTM <- PCAboot(X, k = 1, n.boot=30, s.boot = "B2", S = "tM", Sargs = list(df=2)) TestTM
For p-variate data, the Ladle estimate for PCA assumes that the last p-k eigenvalues are equal. Combining information from the eigenvalues and eigenvectors of the covariance matrix the ladle estimator yields an estimate for k.
PCAladle(X, n.boot = 200, ncomp = ifelse(ncol(X) > 10, floor(ncol(X)/log(ncol(X))), ncol(X) - 1))
PCAladle(X, n.boot = 200, ncomp = ifelse(ncol(X) > 10, floor(ncol(X)/log(ncol(X))), ncol(X) - 1))
X |
numeric data matrix. |
n.boot |
number of bootstrapping samples to be used. |
ncomp |
The number of components among which the ladle estimator is to be searched. The default here follows the recommendation of Luo and Li 2016. |
The model here assumes that the eigenvalues of the covariance matrix are of the form
and the goal is to estimate the value of k. The ladle estimate for this purpose combines the values of the
scaled eigenvalues and the variation of the eigenvectors based on bootstrapping. The idea there is that for distinct eigenvales the variation of the eigenvectors
is small and for equal eigenvalues the corresponding eigenvectors have large variation.
This measure is then computed assuming k=0,..., ncomp
and the ladle estimate for k is the value where the measure takes its minimum.
A list of class ladle containing:
method |
the string PCA. |
k |
the estimated value of k. |
fn |
vector giving the measures of variation of the eigenvectors using the bootstrapped eigenvectors for the different number of components. |
phin |
normalized eigenvalues of the covariance matrix. |
gn |
the main criterion for the ladle estimate - the sum of fn and phin. k is the value where gn takes its minimum |
lambda |
the eigenvalues of the covariance matrix. |
W |
the transformation matrix to the principal components. |
S |
data matrix with the centered principal components. |
MU |
the location of the data which was substracted before calculating the principal components. |
data.name |
the name of the data for which the ladle estimate was computed. |
Klaus Nordhausen
Luo, W. and Li, B. (2016), Combining Eigenvalues and Variation of Eigenvectors for Order Determination, Biometrika, 103, 875–887. <doi:10.1093/biomet/asw051>
n <- 1000 Y <- cbind(rnorm(n, sd=2), rnorm(n,sd=2), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) testPCA <- PCAladle(Y) testPCA summary(testPCA) plot(testPCA) ladleplot(testPCA) ladleplot(testPCA, crit = "fn") ladleplot(testPCA, crit = "lambda") ladleplot(testPCA, crit = "phin")
n <- 1000 Y <- cbind(rnorm(n, sd=2), rnorm(n,sd=2), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) testPCA <- PCAladle(Y) testPCA summary(testPCA) plot(testPCA) ladleplot(testPCA) ladleplot(testPCA, crit = "fn") ladleplot(testPCA, crit = "lambda") ladleplot(testPCA, crit = "phin")
The test tests the equality of the last eigenvalues assuming normal distributed data using the regular covariance matrix.
PCAschott(X, k)
PCAschott(X, k)
X |
a numeric data matrix with p>1 columns. |
k |
the number of eigenvalues larger than the equal ones. Can be between 0 and p-2. |
The functions assumes multivariate normal data and tests if the last eigenvalues of PCA are equal.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the degrees of freedom of the test. |
method |
character string which test was performed. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number or larger eigenvalues used in the testing problem. |
W |
the transformation matrix to the principal components. |
S |
data matrix with the centered principal components. |
D |
the underlying eigenvalues. |
MU |
the mean vector of the data which was substracted before calculating the principal components. |
SCATTER |
the computed covariance matrix matrix. |
Klaus Nordhausen
Schott, J.R. (2006), A High-Dimensional Test for the Equality of the Smallest Eigenvalues of a Covariance Matrix, Journal of Multivariate Analysis, 97, 827–843. <doi:10.1016/j.jmva.2005.05.003>
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) PCAschott(X, 2)
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) PCAschott(X, 2)
For an object of class ictest, plots either the pairwise scatter plot matrix, or the time series plots of the underlying components. The user can choose if only the components considered interesting or all of them should be plotted.
## S3 method for class 'ictest' plot(x, which = "all", ...)
## S3 method for class 'ictest' plot(x, which = "all", ...)
x |
object of class ictest |
which |
if |
... |
other arguments passed on to |
If the component matrix has the class mts
, xts
or zoo
, then a time series plot will be plotted. Otherwise, the pairwise scatter plot matrix will be plotted.
Klaus Nordhausen
ggplot.ictest, pairs, plot.ts, plot.zoo, plot.xts
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) plot(TestCov) plot(TestCov, which = "k")
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) plot(TestCov) plot(TestCov, which = "k")
An object of class ladle contains always the source components as estimated by the corresponding statistical method. This function either plots all of the components or only this considered interesting according to the ladle estimate.
## S3 method for class 'ladle' plot(x, which = "all", ...)
## S3 method for class 'ladle' plot(x, which = "all", ...)
x |
an object of class ladle. |
which |
if |
... |
other arguments passed on to |
If the component matrix has the class mts
, xts
or zoo
, then a time series plot will be plotted. Otherwise, the pairwise scatter plot matrix will be plotted.
Klaus Nordhausen
pairs
, plot.ts
, plot.zoo
, plot.xts
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) plot(test)
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) plot(test)
Basic printing of an object of class ladle. Prints basically everything but the estimated components.
## S3 method for class 'ladle' print(x, ...)
## S3 method for class 'ladle' print(x, ...)
x |
an object of class ladle. |
... |
further arguments to be passed to or from methods. |
Klaus Nordhausen
summary.ladle
, plot.ladle
, ladleplot
, FOBIladle
, PCAladle
, SIRladle
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) test
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) test
A function to generate bivariate data with the scatterplot resembling the greek letter mu.
rMU(n)
rMU(n)
n |
the sample size. |
A n
times 2
matrix
Klaus Nordhausen, Joni Virta
x <- rMU(1000) plot(x)
x <- rMU(1000) plot(x)
A function to generate bivariate data with the scatterplot resembling the greek letter Omega.
rOMEGA(n)
rOMEGA(n)
n |
the sample size. |
A n
times 2
matrix
Klaus Nordhausen, Joni Virta
x <- rOMEGA(1000) plot(x)
x <- rOMEGA(1000) plot(x)
A function to create a random orthogonal matrix uniformly distributed with respect to the Haar measure.
rorth(k)
rorth(k)
k |
the desired numer of columns (=rows) of the orthogonal matrix. |
The function fills a k
xk
matrix with N(0,1) random variables and perfroms then a QR decompoistion using qr
. If the diagonal elements of R are all positive the resulting orthogonal matrix Q is uniform distributed wrt to the Haar measure. Note that the function currently does not check if
all diagonal measurements are indeed positive (however this will happen with probability 1 in theory).
An orthogonal k
times k
matrix
Klaus Nordhausen
Stewart, G.W. (1980), The efficient generation of random orthogonal matrices with an application to condition estimators, SIAM Journal on Numerical Analysis, 17, 403–409. <doi:10.1137/0717034>.
Orth <- rorth(4) crossprod(Orth) tcrossprod(Orth)
Orth <- rorth(4) crossprod(Orth) tcrossprod(Orth)
Plots the criterion values of an ictest
object against its index number. Two versions of this screeplot are available.
## S3 method for class 'ictest' screeplot(x, type = "barplot", main = deparse(substitute(x)), ylab = "criterion", xlab = "component", ...)
## S3 method for class 'ictest' screeplot(x, type = "barplot", main = deparse(substitute(x)), ylab = "criterion", xlab = "component", ...)
x |
object of class |
type |
|
main |
main title of the plot. |
ylab |
y-axis label. |
xlab |
x-axis label. |
... |
other arguments for the plotting functions. |
Klaus Nordhausen
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) screeplot(TestCov)
n <- 200 X <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5), rnorm(n), rnorm(n), rnorm(n)) TestCov <- PCAasymp(X, k = 2) screeplot(TestCov)
Using the two scatter matrices approach (SICS) for sliced inversion regression (SIR), the function tests
if the last p-k
components have zero eigenvalues, where p
is the number of explaining variables. Hence the assumption is that the first k
components are relevant for modelling the response y
and the remaining components are not.
SIRasymp(X, y, k, h = 10, ...)
SIRasymp(X, y, k, h = 10, ...)
X |
a numeric data matrix of explaining variables. |
y |
a numeric vector specifying the response. |
k |
the number of relevant components under the null hypothesis. |
h |
the number of slices used in SIR. Passed on to function |
... |
other arguments passed on to |
Under the null the first k
eigenvalues contained in D
are non-zero and the remaining p-k
are zero.
For a sample of size , the test statistic
is then n times the sum of these last p-k eigenvalue and has under the null a chisquare distribution with
degrees of freedom,
therefore it is required that
.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the degrees of freedom of the test. |
method |
character string which test was performed. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number of non-zero eigenvalues used in the testing problem. |
W |
the transformation matrix to the underlying components. |
S |
data matrix with the centered underlying components. |
D |
the underlying eigenvalues. |
MU |
the location of the data which was substracted before calculating the components. |
Klaus Nordhausen
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
X <- matrix(rnorm(1000), ncol = 5) eps <- rnorm(200, sd = 0.1) y <- 2 + 0.5 * X[, 1] + 2 * X[, 3] + eps SIRasymp(X, y, k = 0) SIRasymp(X, y, k = 1)
X <- matrix(rnorm(1000), ncol = 5) eps <- rnorm(200, sd = 0.1) y <- 2 + 0.5 * X[, 1] + 2 * X[, 3] + eps SIRasymp(X, y, k = 0) SIRasymp(X, y, k = 1)
Using the two scatter matrices approach (SICS) for sliced inversion regression (SIR) the function tests
if the last p-k
components have zero eigenvalues, where p
is the number of explaining variables. Hence the assumption is that the first k
components are relevant for modelling the response y
and the remaining components are not. The function performs bootstrapping to obtain a p-value.
SIRboot(X, y, k, h = 10, n.boot = 200, ...)
SIRboot(X, y, k, h = 10, n.boot = 200, ...)
X |
a numeric data matrix of explaining variables. |
y |
a numeric vector specifying the response. |
k |
the number of relevant components under the null hypothesis. |
h |
the number of slices used in SIR. Passed on to function |
n.boot |
number of bootstrapping samples. |
... |
other arguments passed on to |
Under the null hypthesis the last p-k eigenvalue as given in D are zero. The test statistic is then the sum of these eigenvalues.
Denote W as the transformation matrix to the supervised invariant coordinates (SIC) ,
, i.e.
where MU
is the location.
Let be the submatrix of the SICs which are relevant and
the submatrix of the SICs which are irrelevant for the response y under the null.
The boostrapping has then the following steps:
Take a boostrap sample of size
from
.
Take a boostrap sample of size
from
.
Combine and create
.
Compute the test statistic based on .
Repeat the previous steps n.boot
times.
A list of class ictest inheriting from class htest containing:
statistic |
the value of the test statistic. |
p.value |
the p-value of the test. |
parameter |
the number of boostrapping samples used to compute the p-value. |
method |
character string which test was performed. |
data.name |
character string giving the name of the data. |
alternative |
character string specifying the alternative hypothesis. |
k |
the number of non-zero eigenvalues used in the testing problem. |
W |
the transformation matrix to the underlying components. |
S |
data matrix with the centered underlying components. |
D |
the underlying eigenvalues. |
MU |
the location of the data which was substracted before calculating the components. |
Klaus Nordhausen
Nordhausen, K., Oja, H. and Tyler, D.E. (2022), Asymptotic and Bootstrap Tests for Subspace Dimension, Journal of Multivariate Analysis, 188, 104830. <doi:10.1016/j.jmva.2021.104830>.
X <- matrix(rnorm(1000), ncol = 5) eps <- rnorm(200, sd = 0.1) y <- 2 + 0.5 * X[, 1] + 2 * X[, 3] + eps SIRboot(X, y, k = 0) SIRboot(X, y, k = 1)
X <- matrix(rnorm(1000), ncol = 5) eps <- rnorm(200, sd = 0.1) y <- 2 + 0.5 * X[, 1] + 2 * X[, 3] + eps SIRboot(X, y, k = 0) SIRboot(X, y, k = 1)
In the supervised dimension reduction context with response y and explaining variables x, this functions provides the ladle estimate for the dimension of the central subspace for SIR.
SIRladle(X, y, h = 10, n.boot = 200, ncomp = ifelse(ncol(X) > 10, floor(ncol(X)/log(ncol(X))), ncol(X) - 1), ...)
SIRladle(X, y, h = 10, n.boot = 200, ncomp = ifelse(ncol(X) > 10, floor(ncol(X)/log(ncol(X))), ncol(X) - 1), ...)
X |
numeric data matrix. |
y |
numeric response vector. |
h |
number of slices in SIR. |
n.boot |
number of bootstrapping samples to be used. |
ncomp |
The number of components among which the ladle estimator is to be searched. The default here follows the recommendation of Luo and Li 2016. |
... |
arguments passed on to |
The idea here is that the eigenvalues of the SIR-M matrix are of the form and the eigenvectors
of the non-zero eigenvalue span the central subspace.
The ladle estimate for k for this purpose combines the values of the scaled eigenvalues and the variation of the eigenvectors based on bootstrapping. The idea there is that for distinct eigenvales the variation of the eigenvectors is small and for equal eigenvalues the corresponding eigenvectors have large variation.
This measure is then computed assuming k=0,..., ncomp
and the ladle estimate for k is the value where the measure takes its minimum.
A list of class ladle containing:
method |
the string SIR. |
k |
the estimated value of k. |
fn |
vector giving the measures of variation of the eigenvectors using the bootstrapped eigenvectors for the different number of components. |
phin |
normalized eigenvalues of the M matrix in the SIR case. |
gn |
the main criterion for the ladle estimate - the sum of fn and phin. k is the value where gn takes its minimum |
lambda |
the eigenvalues of the M matrix in the SIR case. |
W |
the transformation matrix to supervised components. |
S |
data matrix with the centered supervised components. |
MU |
the location of the data which was substracted before calculating the supervised components. |
data.name |
the name of the data for which the ladle estimate was computed. |
Klaus Nordhausen
Luo, W. and Li, B. (2016), Combining Eigenvalues and Variation of Eigenvectors for Order Determination, Biometrika, 103. 875–887. <doi:10.1093/biomet/asw051>
n <- 1000 X <- cbind(rnorm(n), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) eps <- rnorm(n, sd=0.02) y <- 4*X[,1] + 2*X[,2] + eps test <- SIRladle(X, y) test summary(test) plot(test) pairs(cbind(y, components(test))) ladleplot(test) ladleplot(test, crit = "fn") ladleplot(test, crit = "lambda") ladleplot(test, crit = "phin")
n <- 1000 X <- cbind(rnorm(n), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) eps <- rnorm(n, sd=0.02) y <- 4*X[,1] + 2*X[,2] + eps test <- SIRladle(X, y) test summary(test) plot(test) pairs(cbind(y, components(test))) ladleplot(test) ladleplot(test, crit = "fn") ladleplot(test, crit = "lambda") ladleplot(test, crit = "phin")
Summarizes an ladle object
## S3 method for class 'ladle' summary(object, ...)
## S3 method for class 'ladle' summary(object, ...)
object |
an object of class ladle. |
... |
further arguments to be passed to or from methods. |
Klaus Nordhausen
print.ladle
, plot.ladle
, ladleplot
, FOBIladle
, PCAladle
, SIRladle
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) summary(test)
n <- 1000 X <- cbind(rexp(n), rt(n,5), rnorm(n), rnorm(n), rnorm(n), rnorm(n)) test <- FOBIladle(X) summary(test)