| Title: | Local Manifold Dispersion Test for Heteroskedasticity |
|---|---|
| Description: | Implements the Local Manifold Dispersion Test (LMDT) for detecting complex, non-linear, and high-dimensional heteroskedasticity in linear regression models. LMDT measures the spectral smoothness (Dirichlet energy) of robust log-dispersion residuals over a self-tuning k-nearest neighbors graph Laplacian, as formulated in Jabbar (2026). The test statistic is asymptotically distribution-free with respect to error kurtosis and accommodates high-dimensional covariates (p > 50) via Gavish-Donoho optimal hard thresholding and supervised metric learning. |
| Authors: | Ahmed Sattar Jabbar [aut, cre] |
| Maintainer: | Ahmed Sattar Jabbar <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-10-24 11:23:32 UTC |
| Source: | https://github.com/cran/LMDT |
Implements the Local Manifold Dispersion Test (LMDT) for detecting complex, non-linear, and high-dimensional heteroskedasticity in linear regression models. LMDT measures the graph-spectral Dirichlet energy of robust log-dispersion residuals over a self-tuning k-nearest neighbors normalized graph Laplacian.
The primary user function is lmdt_test, which supports both
formula and matrix interfaces.
Ahmed Sattar Jabbar [email protected]
Jabbar, A. S. (2026). The Local Manifold Dispersion Test: A Nonparametric Graph-Spectral Approach for Detecting Complex and High-Dimensional Heteroskedasticity. Working Paper.
Constructs an undirected, self-tuning k-nearest neighbors affinity graph and its normalized Laplacian matrix from a covariate matrix.
lmdt_graph(X, k = NULL)lmdt_graph(X, k = NULL)
X |
A numeric matrix or data frame of covariates (n x p). |
k |
Number of nearest neighbors. Default is adaptive rule of thumb. |
A list containing matrices W, S, L, local scales sigma, and vertex degrees.
set.seed(42) X <- matrix(rnorm(50 * 2), ncol = 2) g <- lmdt_graph(X, k = 5) dim(g$S)set.seed(42) X <- matrix(rnorm(50 * 2), ncol = 2) g <- lmdt_graph(X, k = 5) dim(g$S)
Computes correlation-based feature weights to soft-threshold uninformative ambient noise coordinates.
lmdt_metric(X, u, lambda = 0.15)lmdt_metric(X, u, lambda = 0.15)
X |
A numeric matrix of covariates (n x p). |
u |
A numeric vector of log-dispersion scores. |
lambda |
Shrinkage prior in (0, 1). Default is 0.15. |
A rescaled covariate matrix with filtered noise dimensions.
set.seed(42) X <- matrix(rnorm(50 * 10), nrow = 50, ncol = 10) u <- rnorm(50) X_rescaled <- lmdt_metric(X, u, lambda = 0.15) dim(X_rescaled)set.seed(42) X <- matrix(rnorm(50 * 10), nrow = 50, ncol = 10) u <- rnorm(50) X_rescaled <- lmdt_metric(X, u, lambda = 0.15) dim(X_rescaled)
Filters high-dimensional correlated features by hard-thresholding singular values at the Gavish–Donoho (2014) optimal threshold.
lmdt_pca(X)lmdt_pca(X)
X |
A numeric matrix of covariates (n x p). |
A matrix of retained principal components.
set.seed(42) X <- matrix(rnorm(100 * 20), nrow = 100, ncol = 20) X_clean <- lmdt_pca(X) ncol(X_clean)set.seed(42) X <- matrix(rnorm(100 * 20), nrow = 100, ncol = 20) X_clean <- lmdt_pca(X) ncol(X_clean)
Performs the Local Manifold Dispersion Test (LMDT) for regression heteroskedasticity.
lmdt_test(x, ...) ## S3 method for class 'formula' lmdt_test(formula, data = list(), ...) ## S3 method for class 'lm' lmdt_test(x, ...) ## Default S3 method: lmdt_test( x, y, k = NULL, method = c("permutation", "asymptotic", "wild_bootstrap"), alternative = c("one.sided", "two.sided"), denoise = c("none", "pca", "metric"), B = 499L, c = 1e-04, lambda = 0.15, ... )lmdt_test(x, ...) ## S3 method for class 'formula' lmdt_test(formula, data = list(), ...) ## S3 method for class 'lm' lmdt_test(x, ...) ## Default S3 method: lmdt_test( x, y, k = NULL, method = c("permutation", "asymptotic", "wild_bootstrap"), alternative = c("one.sided", "two.sided"), denoise = c("none", "pca", "metric"), B = 499L, c = 1e-04, lambda = 0.15, ... )
x |
A numeric design matrix of regressors, or a formula. |
... |
Further arguments passed to methods. |
formula |
A symbolic regression formula (e.g. |
data |
An optional data frame containing model variables. |
y |
A numeric vector of regression residuals or response variable. |
k |
An integer number of nearest neighbors. Default uses adaptive rule of thumb. |
method |
P-value calibration: |
alternative |
Alternative hypothesis: |
denoise |
High-dimensional pre-filtering: |
B |
Number of bootstrap or permutation replications. Default is 499. |
c |
Positive stabilizer for log-dispersion transform. Default is 1e-4. |
lambda |
Shrinkage prior for metric learning. Default is 0.15. |
An object of class "lmdt" and "htest".
Jabbar, A. S. (2026). The Local Manifold Dispersion Test: A Nonparametric Graph-Spectral Approach for Detecting Complex and High-Dimensional Heteroskedasticity. Working Paper.
set.seed(42) n <- 100 x1 <- rnorm(n) x2 <- rnorm(n) e <- rnorm(n, sd = exp(0.5 * x1)) y <- 1 + 2 * x1 + 3 * x2 + e fit <- lm(y ~ x1 + x2) # Using formula interface with asymptotic calibration test_asymp <- lmdt_test(y ~ x1 + x2, method = "asymptotic") print(test_asymp) # Using Wild Bootstrap calibration test_boot <- lmdt_test(y ~ x1 + x2, method = "wild_bootstrap", B = 199) print(test_boot)set.seed(42) n <- 100 x1 <- rnorm(n) x2 <- rnorm(n) e <- rnorm(n, sd = exp(0.5 * x1)) y <- 1 + 2 * x1 + 3 * x2 + e fit <- lm(y ~ x1 + x2) # Using formula interface with asymptotic calibration test_asymp <- lmdt_test(y ~ x1 + x2, method = "asymptotic") print(test_asymp) # Using Wild Bootstrap calibration test_boot <- lmdt_test(y ~ x1 + x2, method = "wild_bootstrap", B = 199) print(test_boot)
Produces diagnostic plots displaying the null distribution of the test statistic (under bootstrap/permutation or asymptotic Gaussian) and the ordered log-dispersion profile.
## S3 method for class 'lmdt' plot(x, ...)## S3 method for class 'lmdt' plot(x, ...)
x |
An object of class |
... |
Additional graphical parameters passed to plotting functions. |
Invisibly returns x.
set.seed(42) fit <- lm(rnorm(50) ~ matrix(rnorm(100), 50, 2)) res <- lmdt_test(fit, method = "asymptotic") plot(res)set.seed(42) fit <- lm(rnorm(50) ~ matrix(rnorm(100), 50, 2)) res <- lmdt_test(fit, method = "asymptotic") plot(res)
Print and summary methods for objects of class "lmdt".
## S3 method for class 'lmdt' print(x, digits = 4, ...) ## S3 method for class 'lmdt' summary(object, ...)## S3 method for class 'lmdt' print(x, digits = 4, ...) ## S3 method for class 'lmdt' summary(object, ...)
x |
An object of class |
digits |
Number of significant digits. |
object |
An object of class |
... |
Additional arguments. |
Invisibly returns the input object.