Learn R Programming

NormalBetaPrime (version 2.2)

dl.normalmeans: Normal Means Estimation and Hypothesis Testing with the Dirichlet-Laplace Prior

Description

This function implements the Dirichlet-Laplace model of Bhattacharya et al. (2015) for obtaining a sparse estimate of \(\theta = (\theta_1, ..., \theta_n)\) in the normal means problem,

$$X_i = \theta_i + \epsilon_i,$$

where \(\epsilon_i \sim N(0, \sigma^2)\). This is achieved by placing the Dirichlet-Laplace (DL) prior on the individual \(\theta_i\)'s. The sparsity parameter \(\tau\) in the \(Dir(\tau, \ldots, \tau)\) prior can be specified a priori, or it can be estimated from the data, either by: 1) using the estimate of sparsity level by van der Pas et al. (2014), 2) by taking a restricted marginal maximum likelihood (REML) estimate on \([1/n, 1]\), 3) endowing \(\tau\) with a uniform prior, \(U(1/n, 1)\), or 4) endowing \(\tau\) with a standard Cauchy prior truncated to \([1/n, 1]\). Multiple testing can also be performed by either thresholding the shrinkage factor in the posterior mean, or by examining the marginal 95 percent credible intervals.

Usage

dl.normalmeans(x, tau.est=c("fixed", "est.sparsity", "reml", "uniform", 
               "truncatedCauchy"), tau=1/length(x), sigma2=1, 
               var.select = c("threshold", "intervals"), 
               max.steps=10000, burnin=5000)

Arguments

x

an \(n \times 1\) multivariate normal vector.

tau.est

The method for estimating the sparsity parameter \(\tau\). If "fixed" is chosen, then \(\tau\) is not estimated from the data. If "est.sparsity" is chosen, the empirical Bayes estimate of sparsity level from van der Pas et al. (2014) is used. If "reml" is chosen, \(\tau\) is estimated from restricted marginal maximum likelihood on \([1/n, 1]\). If "uniform" is chosen, \(\tau\) is estimated with a uniform prior on \([1/n, 1]\). If "truncatedCauchy" is chosen, \(\tau\) is estimated with a standard Cauchy prior truncated to \([1/n, 1]\).

tau

The concentration parameter \(\tau\) in the \(Dir(\tau, \ldots, \tau)\) prior. Controls the sparsity of the model. Defaults to \(1/n\), but user may specify a different value for tau (\(\tau > 0\)). This is ignored if the method "est.sparsity", "reml", "unif", or "truncatedCauchy" is used to estimate \(\tau\).

sigma2

The variance parameter. Defaults to 1. User needs to specify the noise parameter if it is different from 1 (\(\sigma^2 > 0\)).

var.select

The method of variable selection. "threshold" selects variables by thresholding the shrinkage factor in the posterior mean. "intervals" will classify \(\theta_i\)'s as either signals (\(\theta_i \neq 0\)) or as noise (\(\theta_i = 0\)) by examining the 95 percent posterior credible intervals.

max.steps

The total number of iterations to run in the Gibbs sampler. Defaults to 10,000.

burnin

The number of burn-in iterations for the Gibbs sampler. Defaults to 5,000.

Value

The function returns a list containing the following components:

theta.hat

The posterior mean of \(\theta\).

theta.med

The posterior median of \(\theta\).

theta.var

The posterior variance estimates for each \(\theta_i, i=1,\ldots,p\).

theta.intervals

The 95 percent credible intervals for all \(n\) components of \(\theta\).

dl.classifications

An \(n\)-dimensional binary vector with "1" if the covariate is selected and "0" if it is deemed irrelevant.

tau.estimate

The estimate of the sparsity level. If user specified "fixed" for tau.est, then it simply returns the fixed \(\tau\). If user specified "uniform" or "truncatedCauchy", it returns the posterior mean of \(\pi(\tau |X_1, \ldots, X_n)\).

Details

The function implements sparse estimation and multiple hypothesis testing on a multivariate normal mean vector, \(\theta = (\theta_1, \ldots, \theta_n)\) with the Dirichlet-Laplace prior of Bhattacharya et al. (2015). The full model is:

$$X | \theta \sim N_n( \theta, \sigma^2 I_n),$$ $$\theta_i | (\psi_i, \phi_i, \omega) \sim N(0, \sigma^2 \psi_i \phi_i^2 \omega^2), i = 1, \ldots, n,$$ $$\psi_i \sim Exp(1/2), i = 1, \ldots, n,$$ $$ (\phi_1, \ldots, \phi_n) \sim Dir(\tau, \ldots, \tau),$$ $$\omega \sim G(n \tau, 1/2).$$

\(\tau\) is the main parameter that controls the sparsity of the solution. It can be estimated by: the empirical Bayes estimate of the estimated sparsity ("est.sparsity") given in van der Pas et al. (2014), restricted marginal maximum likelihood in the interval \([1/n, 1]\) ("reml"), a uniform prior \(\tau \sim U(1/n, 1)\) ("uniform"), or by a standard Cauchy prior truncated to \([1/n, 1]\) ("truncatedCauchy").

The posterior mean is of the form \([E(1-\kappa_i | X_1, \ldots, X_n)] X_i, i = 1, \ldots, n\). The "threshold" method for variable selection is to classify \(\theta_i\) as signal (\(\theta_i \neq 0\)) if \(E(1 - \kappa_i | X_1, \ldots, X_n) > 1/2\).

References

Bhattacharya, A., Pati, D., Pillai, N. S., and Dunson, D. B. (2015). "Dirichlet-Laplace priors for optimal shrinkage." Journal of the American Statistical Association, 110(512):1479-1490.

van der Pas, S. L., Kleijn, B. J. K., and van der Vaart, A. W. (2014). "The horseshoe estimator: Posterior concentration around nearly black vectors." Electronic Journal of Statistics, 8(2):2585-2618.

van der Pas, S. L., Szabo, B. T., and van der Vaart, A. (2017). "Adaptive posterior contraction rates for the horseshoe." Electronic Journal of Statistics, 11(2):3196-3225.

Examples

Run this code
# NOT RUN {
###################################################
# Example on synthetic data.                      # 
# 5 percent of entries in theta are set to A = 7. #
###################################################
n <- 100
sparsity.level <- 5
A <- 7

# Initialize theta vector of all zeros
theta.true <- rep(0,n)
# Set (sparsity.level) percent of them to be A
q <- floor(n*(sparsity.level/100))
# Pick random indices of theta.true to equal A
signal.indices <- sample(1:n, size=q, replace=FALSE)

###################
# Generate data X #
###################
theta.true[signal.indices] <- A
X <- theta.true + rnorm(n,0,1)


#########################
# Run the DL model on X #
#########################
# For optimal performance, should set max.steps=10,000 and burnin=5000.

# Estimate tau from the empirical Bayes estimate of sparsity level
dl.model <- dl.normalmeans(X, tau.est="est.sparsity", sigma2=1, var.select="threshold", 
                          max.steps=1000, burnin=500)

dl.model$theta.med           # Posterior median estimates
dl.model$dl.classifications  # Classifications
dl.model$tau.estimate        # Estimate of sparsity level

# }

Run the code above in your browser using DataLab