set.seed(108)
n <- 200
p <- 20
mu <- (1:p)/p
cov <- diag(p)
data <- MASS::mvrnorm(n, mu, cov)
## Define the dimension of interest
r <- 4
## Construct difference matrix for dimension r
difference.matrix.r <- matrix(rep(data[, r], p - 1), ncol = p - 1, byrow = FALSE) - data[, -r]
## softmin.LOO (SML)
argmax.HT(difference.matrix.r)
## use seed
argmax.HT(difference.matrix.r, seed=19)
## With known true difference
true.mean.diff <- mu[r] - mu[-r]
argmax.HT(difference.matrix.r, true.mean = true.mean.diff)
## Without scaling
argmax.HT(difference.matrix.r, scale.input = FALSE)
## With a user-specified lambda
argmax.HT(difference.matrix.r, lambda = sqrt(n) / 2.5)
## Add a seed for reproducibility
argmax.HT(difference.matrix.r, seed = 17)
## argmin.LOO (HML)
argmax.HT(difference.matrix.r, method = "HML")
## nonsplit method
argmax.HT(difference.matrix.r, method = "NS", lambda = sqrt(n)/2.5)
## Bonferroni method (choose t test for normal data)
argmax.HT(difference.matrix.r, method = "MT", test = "t")
## Gupta method (pass full data matrix)
critical.val <- get.quantile.gupta.selection(p = length(mu))
argmax.HT(data, r, method = "GTA", critical.val = critical.val)
Run the code above in your browser using DataLab