pcarbo / varbvs

Large-scale Bayesian variable selection for R and MATLAB.
http://pcarbo.github.io/varbvs
GNU General Public License v3.0
42 stars 14 forks source link

question on assigning prior logodds to input data #21

Closed YSanchezAraujo closed 6 years ago

YSanchezAraujo commented 6 years ago

Hi,

I'm trying to run a logistic regression like so:

fit <- varbvs(X, Z, y, family="binomial", logodds=matrix(lgs, 1))

with the dimension info for example:

dim(X) # 1536, 170
dim(Z) # 1536, 8
length(y) # 1536
length(lgs) # 170

so I'd like each prior value of lgs for the logoods to go to it's corresponding column in X

is this the correct way to go about this?

from: https://github.com/pcarbo/varbvs/blob/master/varbvs-R/R/varbvs.R#L105

it seems that what I would need instead is:

fit <- varbvs(X, Z, y, family="binomial", logodds=matrix(lgs))

however when I do that I get:

Welcome to           --       *                              *
VARBVS version 2.4-0 --       |              |               |
large-scale Bayesian --       ||           | |    |          || |     |   |
variable selection   -- |     || | |    |  | ||  ||        |||| ||    |   ||
****************************************************************************
Copyright (C) 2012-2017 Peter Carbonetto.
See http://www.gnu.org/licenses/gpl.html for the full license.
Fitting variational approximation for Bayesian variable selection model.
family:     binomial   num. hyperparameter settings: 1
samples:    1536       convergence tolerance         1.0e-04
variables:  170        iid variable selection prior: no
covariates: 8          fit prior var. of coefs (sa): yes
intercept:  yes        fit approx. factors (eta):    yes
        variational    max.   incl variance params
 iter   lower bound  change   vars   sigma      sa
 0253 -9.123741e+02 1.0e-04 0089.2      NA 8.6e-03
Error in varbvs(X, Z, y, family = "binomial", logodds = matrix(lgs)) :
  object 'fit' not found
pcarbo commented 6 years ago

@YSanchezAraujo I believe your example should work. There may be a bug in varbvs version 2.4-0. Please try this:

  1. Install the latest version of varbvs from GitHub (2.5-2).

  2. Try running:

library(varbvs)
demo("varbvs.cc")
logodds <- matrix(c(rep(-2,500),rep(-3,500)))
fit2 <- varbvs(X,Z,y,"binomial",logodds = logodds)

Does that work for you? If so, perhaps you can adapt this example as needed to your problem.

YSanchezAraujo commented 6 years ago

@pcarbo thanks it was indeed the older version that was causing the problem