ebmr: Fit Empirical Bayes Multiple Regression Model

ebmrR Documentation

Fit Empirical Bayes Multiple Regression Model

Description

Fits multiple regression model using a new empirical Bayes variational approach based on generalized ridge regression (GRR).

Usage

ebmr(
  X,
  y,
  tol = 1e-08,
  maxiter = 1000,
  ebnv_fn = ebnv.exp,
  compute_mode = FALSE
)

ebmr.update(
  fit,
  tol = 1e-08,
  maxiter = 1000,
  ebnv_fn = ebnv.exp,
  compute_mode = FALSE,
  update_residual_variance = TRUE
)

Arguments

X

An n times p numeric matrix of covariates.

y

An n vector of responses.

tol

Small real number controlling convergence tolerance; algorithm stops when elbo changes less than tol.

maxiter

Integer indicating maximum number of iterations.

ebnv_fn

Function for solving the Empirical Bayes Normal Variances problem.

compute_mode

Boolean indicating whether to use the mode (rather than the mean). If used with ebnv_fn = ebnv.exp then this produces the Lasso solution rather than Bayesian Lasso.

fit

The previous EBMR fit

Value

An object of class "ebmr" that contains fit details.

Functions

  • ebmr.update: Updates a previous EBMR fit, usually using a new prior family

Examples

set.seed(100)
n = 50
p = 200
X = matrix(rnorm(n*p),nrow=n,ncol=p)
btrue = rep(0,p)
btrue[1] = 1
btrue[2] = -1
y = X %*% btrue + rnorm(n)

y.fit.ebr = ebmr(X,y, maxiter = 200, ebnv_fn = ebnv.pm)
y.fit.eblasso = ebmr(X,y, maxiter = 200, ebnv_fn = ebnv.exp)
y.fit.eblasso.mode = ebmr(X,y, maxiter = 200, ebnv_fn = ebnv.exp, compute_mode=TRUE)

y.fit.ebash = ebmr.alpha:::ebmr.set.prior(y.fit.eblasso,ebmr.alpha:::exp2np(y.fit.eblasso$g))
y.fit.ebash = ebmr.update(y.fit.ebash, maxiter = 200, ebnv_fn = ebnv.np)

plot(btrue, coef(y.fit.ebr))
plot(btrue, coef(y.fit.eblasso), col=2)
plot(btrue, coef(y.fit.eblasso.mode), col=3)
plot(btrue, coef(y.fit.ebash), col=4)

stephenslab/ebmr.alpha documentation built on March 30, 2022, 3:49 a.m.