Exact and Log-Scale Tail Probabilities for Roy's Largest Root

Provides distribution functions and log-scale tail probabilities for Roy's largest root in single and double Wishart (Jacobi ensemble) settings. This package is derived from the 'rootWishart' package by Maxime Turgeon and extends it with numerically robust log-CDF/log-survival evaluation, tail-aware adaptive precision, and high-dimensional validation utilities, based on Chiani (2014) and Chiani (2016) .


rootWishartHD

rootWishartHD computes CDFs, log-CDFs, log-survival probabilities, p-values, and critical values for Roy's largest root in single- and double-Wishart (Jacobi / multivariate beta) settings. It is derived from Maxime Turgeon's rootWishart codebase and adds scaled Pfaffian evaluation, log-tail wrappers, adaptive multiprecision, and high-dimensional validation utilities.

Installation

# from a local source checkout
install.packages(".", repos = NULL, type = "source")

Basic use

library(rootWishartHD)

theta <- c(0.5, 0.8, 0.9)       # theta scale, 0 <= theta <= 1
F <- doubleWishart(theta, s = 5, m = 10, n = 10, verbose = FALSE)

log_sf <- doubleWishart_log(theta, s = 5, m = 10, n = 10,
                            tail = "upper", type = "arbitrary",
                            verbose = FALSE)

pval <- doubleWishart_pvalue(theta, s = 5, m = 10, n = 10,
                             input = "theta", verbose = FALSE)

The double-Wishart API uses the Jacobi scale theta = lambda / (1 + lambda). If your statistic is a beta type II or generalized-root value lambda, convert it before calling CDF functions, or use doubleWishart_pvalue(..., input = "lambda").

Multiprecision backend

The CRAN-safe default is

DW_USE_MPFR=0

which uses Boost's header-only cpp_dec_float backend from the BH package. This needs no system MPFR/GMP libraries and is the recommended portable setting for CRAN, Windows, macOS, and clean Linux machines.

To force the multiprecision path at runtime, use either

options(rootWishartHD.force_multiprecision = TRUE)

or pass force_multiprecision = TRUE to the CDF/log-tail wrappers.

For local source builds, users who specifically want MPFR/GMP can opt in with

DW_USE_MPFR=1 R CMD INSTALL rootWishartHD_0.95.1.tar.gz

or from a source directory:

DW_USE_MPFR=1 R CMD INSTALL .

Runtime adaptive precision (adaptive = TRUE) requires an MPFR/GMP build because it changes the decimal precision during evaluation. With the default DW_USE_MPFR=0 build, adaptive = TRUE is downgraded to fixed cpp_dec_float precision with a warning. To increase the fixed precision, build with for example DW_MP_DIGITS=300 R CMD INSTALL ..

You need MPFR and GMP development libraries available to the compiler. Check the compiled backend with

rootWishartHD_mpfr_enabled()

If MPFR is explicitly requested through the deprecated force_mpfr interface or old options(rootWishart.force_mpfr = TRUE), but the package was compiled with DW_USE_MPFR=0, rootWishartHD warns once and falls back to Boost cpp_dec_float.

Validation scripts

Fast tests are under inst/tinytest/ and are run by R CMD check. Longer numerical sweeps are installed under inst/validation/ and are not run automatically:

source(system.file("validation", "test_doubleWishartHD_sweep.R",
                   package = "rootWishartHD"))

Those scripts may use arbitrary precision, local caches, and multiple workers; they are intended for release validation rather than CRAN check-time execution.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rootWishartHD")

0.95.2 by Stepan Grinek, 3 months ago


https://github.com/stepanv1/rootWishartHD


Report a bug at https://github.com/stepanv1/rootWishartHD/issues


Browse source code at https://github.com/cran/rootWishartHD


Authors: Stepan Grinek [aut, cre] , Maxime Turgeon [ctb] (Original rootWishart package codebase)


Documentation:   PDF Manual  


GPL (>= 2) license


Imports Rcpp

Suggests tinytest, knitr, rmarkdown, rWishart, corpcor

Linking to Rcpp, RcppEigen, BH


See at CRAN