Performs dimension estimation using various search strategies (forward, backward, binary) and hypothesis testing methods that evaluate whether the true dimension \(d \leq k\). The search continues until a p-value exceeds the specified alpha threshold, which indicates that the null hypothesis is not rejected. The search can optionally continue to test all values, as there may not be a global optimum in the tested range.
kSearch(
X,
method,
search = c("forward", "backward", "binary"),
alpha = 0.05,
early_stop = NULL,
min_dim = NULL,
max_dim = NULL,
...
)An object of class ictest inheriting from htest, with additional elements:
tested.ksAn integer vector of all tested values of k during the search.
tested.ks.pvalsA numeric vector of p-values corresponding to each tested k.
A data matrix with \(p>1\) columns.
A function that performs a hypothesis test given X and dimension k.
For more details on supported tests, see the
"Details" section below.
A character string specifying the search strategy.
Options are forward (default), backward and binary. For more details on search techniques, see the
"Details" section below.
A numeric significance level (default = 0.05) used as the threshold for rejecting the null hypothesis.
Logical or NULL. Controls whether the search stops early once the null hypothesis is not rejected.
If NULL (default), the behavior is determined by the selected search strategy: TRUE for "forward" and "backward",
and FALSE for "binary". If explicitly set to TRUE or FALSE, this overrides the strategy's default behavior.
Optional integer to limit the minimum dimension to search. By default, this is set according to the method being used.
Optional integer to limit the maximum dimension to search. By default, this is set according to the method being used.
Additional arguments passed to the testing function method.
Katariina Perkonoja
This function is designed to work with the following tests:
FOBIasymp, FOBIboot
ICSboot
NGPPsim
PCAasymp, PCAboot, PCAschott, PCAlrt
SIRasymp, SIRboot
These tests evaluate the null hypothesis that the true dimension \(d \leq k\), and return a p-value indicating whether the null is rejected or not.
The search work as follows:
"forward" (default) performs a linear search starting from the smallest possible value of k and incrementing upward. Returns the smallest k where the null is not rejected.
"backward" performs a linear search starting from the largest possible value of k and decrementing downward. Returns k+1, where k is the largest dimension where the null is rejected.
"binary" splits the possible range of ks in half and performs a binary search. This search may skip testing some possible k values, but it is typically faster than linear search.
The binary search assumes that the null hypothesis is rejected for all k below the true dimension and
not rejected above it. If the p-values do not behave monotonically in k, the binary search can return a
different value than the linear searches, which should then be preferred.
If no tested value of k gives a p-value above alpha, a warning is given and the returned object
of class kSearch contains only k = NA and the tested values of k with their p-values.
# Applying forward search with PCAasymp while evaluating
# all valid values of k (early_stop = FALSE)
n <- 200
S <- cbind(rnorm(n, sd = 2), rnorm(n, sd = 1.5),
rnorm(n), rnorm(n), rnorm(n))
A <- rorth(5)
X <- S %*% t(A)
result <- kSearch(
X = X,
method = PCAasymp,
alpha = 0.05,
search = "forward",
early_stop = FALSE
)
result
Run the code above in your browser using DataLab