ebrr_svd: Empirical Bayes ridge regression by SVD

View source: R/ebrr_svd.R

ebrr_svdR Documentation

Empirical Bayes ridge regression by SVD

Description

Fits Empirical Bayes ridge regression model by svd approach

Usage

ebrr_svd(X, y, tol = 1e-10, maxiter = 1000)

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

Details

This is based on my investigations at https://stephens999.github.io/misc/ridge_em_svd.html It first performs an svd on X and then estimates the hyper-parameters by iterative EM

Value

an object of class "ebmr" that contains fit details

Examples

set.seed(100)
n= 100
p = n
X = matrix(0,nrow=n,ncol=n)
for(i in 1:n){
X[i:n,i] = 1:(n-i+1)
}
btrue = rep(0,n)
btrue[40] = 8
btrue[41] = -8
y = X %*% btrue + rnorm(n)
plot(y,main="true (black); fitted values from RR (red)")
lines(X %*% btrue)
lines(X %*% coef(y.ebrr), col=2)


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