Multivariate Bayesian variable selection regression

Improving calculation of multivariate multiple regression

A prototype for multivariate multiple regression computation assuming fixed residual covariance matrix.

In [1]:
data = mvsusieR::mvsusie_sim2(1000,7000,50,0.8)

Here we do not use an existing R routine because lm is very slow (even using .lm.fit compared to providing pre-computed d as done below).

In [2]:
method_1 = function(d,X,y,residual_covar,p) {
    XtY=t(X)%*%y
    bhat = diag(1/d) %*% XtY
    s2 = diag(residual_covar)
    sbhat = sqrt(do.call(rbind, lapply(1:p, function(j) s2 / d[j])))
    return(list(b=bhat,s=sbhat))
}
In [3]:
method = method_1
In [5]:
res = with(data, method(d,X,y,diag(r),p))

The speed is decent but the code seems ugly. Must be a more elegant matrix representation (and hopefully faster)?


Copyright © 2016-2020 Gao Wang et al at Stephens Lab, University of Chicago