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

Undefined function or variable 'fit' #27

Closed xiangzhu closed 6 years ago

xiangzhu commented 6 years ago

https://github.com/pcarbo/varbvs/blob/022e0da046ece29256a2237a757983bc5902647e/varbvs-MATLAB/varbvs.m#L815

Hi Peter -- there is a minor issue in the current varbvs.m. I think it can be easily fixed by removing fit.:

if ns == 1
    w    = 1;
    pip  = alpha;
    beta = mu;
  else

FYI, below is the example where I found this error:

>> % run VARBVS on simulated data
>> sigma   = true_para{3};
>> sigma   = sigma^2;
>> sa      = (sigb^2)/sigma;
>> logodds = log10(pip/(1-pip));
>>
>> options.maxiter = 1e8;
>> options.sigma   = sigma;
>> options.sa      = sa;
>> options.logodds = logodds;
>> tic;
>> fit = varbvs(Xgene,[],y,[],'gaussian',options);
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:     gaussian   num. hyperparameter settings: 1
samples:    1458       convergence tolerance         1.0e-04
variables:  18338      iid variable selection prior: yes
covariates: 0          fit prior var. of coefs (sa): no
intercept:  yes        fit residual var. (sigma):    no
        variational    max.   incl variance params
 iter   lower bound  change   vars   sigma      sa
00573 -1.139339e+04 9.8e-05 3637.2 2.9e+05 3.5e-06
Undefined function or variable 'fit'.

Error in varbvs (line 815)
    pip  = fit.alpha;

>> toc;
Elapsed time is 127.495011 seconds.
pcarbo commented 6 years ago

@xiangzhu, thanks for reporting this bug. I think I fixed the issue but let me know if I did not.