
<!-- README.md is generated from README.Rmd. Please edit that file -->

# HDNRA

<!-- badges: start -->

[![License:
GPL-3.0](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![R-CMD-check](https://github.com/nie23wp8738/HDNRA/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nie23wp8738/HDNRA/actions/workflows/R-CMD-check.yaml)

<!-- badges: end -->

The R package **HDNRA** provides inverse-free high-dimensional location
tests for two-sample and general linear hypothesis testing (GLHT)
problems under equal or unequal covariance structures. It implements
classical normal-approximation-based procedures, normal-reference tests
based on covariance-matched Gaussian companions, and F-type
normal-reference calibrations for heteroscedastic Behrens–Fisher and
GLHT settings. Computationally intensive components are implemented in
C++ through [Rcpp](https://github.com/RcppCore/Rcpp) and
[RcppArmadillo](https://github.com/RcppCore/RcppArmadillo).

Version 2.1.0 contains **24 public testing routines** and two real data
sets.

## Implemented data sets and testing routines

Two real data sets in `HDNRA`:

- [COVID19](https://nie23wp8738.github.io/HDNRA/reference/COVID19.html)
- [corneal](https://nie23wp8738.github.io/HDNRA/reference/corneal.html)

Seven normal-reference tests for the two-sample problem:

- [ZGZC2020.TS.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZGZC2020.TS.2cNRT.html)
- [ZZ2022.TS.3cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZ2022.TS.3cNRT.html)
- [ZZZ2020.TS.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZZ2020.TS.2cNRT.html)
- [ZWZ2023.TSBF.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZWZ2023.TSBF.2cNRT.html)
- [ZZ2022.TSBF.3cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZ2022.TSBF.3cNRT.html)
- [ZZGZ2021.TSBF.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZGZ2021.TSBF.2cNRT.html)
- [ZZZ2023.TSBF.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZZ2023.TSBF.2cNRT.html)

Seven normal-reference tests for the GLHT/GLHTBF problem:

- [ZGZ2017.GLHT.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZGZ2017.GLHT.2cNRT.html)
- [ZZ2022.GLHT.3cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZ2022.GLHT.3cNRT.html)
- [ZZZ2022.GLHT.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZZ2022.GLHT.2cNRT.html)
- [ZZ2022.GLHTBF.3cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZ2022.GLHTBF.3cNRT.html)
- [ZZG2022.GLHTBF.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/ZZG2022.GLHTBF.2cNRT.html)
- [WZ2026.GLHTBF.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/WZ2026.GLHTBF.2cNRT.html)
- [CCXH2024.GLHTBF.2cNRT](https://nie23wp8738.github.io/HDNRA/reference/CCXH2024.GLHTBF.2cNRT.html)

Four normal-approximation-based tests for the two-sample problem:

- [BS1996.TS.NABT](https://nie23wp8738.github.io/HDNRA/reference/BS1996.TS.NABT.html)
- [SD2008.TS.NABT](https://nie23wp8738.github.io/HDNRA/reference/SD2008.TS.NABT.html)
- [CQ2010.TSBF.NABT](https://nie23wp8738.github.io/HDNRA/reference/CQ2010.TSBF.NABT.html)
- [SKK2013.TSBF.NABT](https://nie23wp8738.github.io/HDNRA/reference/SKK2013.TSBF.NABT.html)

Six normal-approximation-based and benchmark tests for the GLHT/GLHTBF
problem:

- [FHW2004.GLHT.NABT](https://nie23wp8738.github.io/HDNRA/reference/FHW2004.GLHT.NABT.html)
- [SF2006.GLHT.NABT](https://nie23wp8738.github.io/HDNRA/reference/SF2006.GLHT.NABT.html)
- [YS2012.GLHT.NABT](https://nie23wp8738.github.io/HDNRA/reference/YS2012.GLHT.NABT.html)
- [ZGZ2017.GLHTBF.NABT](https://nie23wp8738.github.io/HDNRA/reference/ZGZ2017.GLHTBF.NABT.html)
- [S2007.ks.NABT](https://nie23wp8738.github.io/HDNRA/reference/S2007.ks.NABT.html)
- [LHNB2025.GLHTBF.NABT](https://nie23wp8738.github.io/HDNRA/reference/LHNB2025.GLHTBF.NABT.html)

## Installation

Install the CRAN release with:

``` r
install.packages("HDNRA")
```

You can also install the development version from
[GitHub](https://github.com/):

``` r
# Installing from GitHub requires devtools or remotes.
install.packages("devtools")
# Or:
install.packages("remotes")

# Install the development version from GitHub.
devtools::install_github("nie23wp8738/HDNRA")
# Or:
remotes::install_github("nie23wp8738/HDNRA")
```

## Usage

### Load the package

``` r
library(HDNRA)
```

### Example data

Package `HDNRA` comes with two real data sets:

``` r
# A COVID-19 transcriptomic data set for the two-sample problem.
?COVID19
data(COVID19)
dim(COVID19)

group1 <- as.matrix(COVID19[c(2:19, 82:87), ])      # healthy controls
group2 <- as.matrix(COVID19[-c(1:19, 82:87), ])     # COVID-19 patients

dim(group1)
dim(group2)

# A corneal topography data set for the GLHT problem.
?corneal
data(corneal)
dim(corneal)

group1 <- as.matrix(corneal[1:43, ])      # normal group
group2 <- as.matrix(corneal[44:57, ])     # unilateral suspect group
group3 <- as.matrix(corneal[58:78, ])     # suspect map group
group4 <- as.matrix(corneal[79:150, ])    # clinical keratoconus group

dim(group1)
dim(group2)
dim(group3)
dim(group4)
```

### Example for the two-sample problem

A simple example using the F-type normal-reference Behrens–Fisher test
`ZWZ2023.TSBF.2cNRT()` with the `COVID19` data set:

``` r
data("COVID19")

group1 <- as.matrix(COVID19[c(2:19, 82:87), ])
group2 <- as.matrix(COVID19[-c(1:19, 82:87), ])

ZWZ2023.TSBF.2cNRT(group1, group2)
```

### Example for the GLHT problem

A simple example using the F-type normal-reference GLHTBF test
`WZ2026.GLHTBF.2cNRT()` with the `corneal` data set:

``` r
data("corneal")

group1 <- as.matrix(corneal[1:43, ])
group2 <- as.matrix(corneal[44:57, ])
group3 <- as.matrix(corneal[58:78, ])
group4 <- as.matrix(corneal[79:150, ])

Y <- list(group1, group2, group3, group4)
k <- length(Y)
n <- vapply(Y, nrow, integer(1))
p <- ncol(Y[[1]])

# Omnibus one-way contrast against the last group.
G <- cbind(diag(k - 1), rep(-1, k - 1))

WZ2026.GLHTBF.2cNRT(Y, G, n, p)
```

A rank-one heteroscedastic GLHTBF example can be run with
`CCXH2024.GLHTBF.2cNRT()`:

``` r
B <- c(-2, 1, 2, -1)
CCXH2024.GLHTBF.2cNRT(Y, B, n, p, alpha = 0.05)
```

The random-integration normal-approximation GLHTBF routine
`LHNB2025.GLHTBF.NABT()` uses a rank-one coefficient vector and tuning
vectors `O` and `A`:

``` r
B <- c(-2, 1, 2, -1)
A <- rep(sqrt(5) * p^(-3 / 8), p)
eps <- 2
O <- sqrt(eps * (1 + 2 * (1:p) / (3 * p)))

LHNB2025.GLHTBF.NABT(Y, B, O, A, n, p)
```

## Code of Conduct

Please note that the HDNRA project is released with a [Contributor Code
of
Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.
