<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html>
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Compute numerical estimate of Bayes factor. — varbvsbf • varbvs</title>

<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script>
<!-- Bootstrap -->

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<!-- Font Awesome icons -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">


<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../jquery.sticky-kit.min.js"></script>
<script src="../pkgdown.js"></script>

<!-- mathjax -->
<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->


  </head>

  <body>
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="../index.html">varbvs</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">Home</a>
</li>
<li>
  <a href="../articles/index.html">Vignettes</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
      </ul>
      
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="http://github.com/pcarbo/varbvs">
    <span class="fa fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      
      </header>

      <div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Compute numerical estimate of Bayes factor.</h1>
    </div>

    
    <p>The Bayes factor is the ratio of the marginal likelihoods
  under two different models (see Kass &amp; Raftery, 1995). Function
  <code>varbvsbf</code> provides a convenient interface for computing the
  Bayes factor comparing the fit of two different <code>varbvs</code> models.</p>
    

    <pre><span class='fu'>varbvsbf</span> (<span class='no'>fit0</span>, <span class='no'>fit1</span>)

  <span class='fu'>bayesfactor</span> (<span class='no'>logw0</span>, <span class='no'>logw1</span>)</pre>
    
    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>fit0</th>
      <td><p>An output returned from <code><a href='varbvs.html'>varbvs</a></code>.</p></td>
    </tr>
    <tr>
      <th>fit1</th>
      <td><p>Another output returned from <code><a href='varbvs.html'>varbvs</a></code>.</p></td>
    </tr>
    <tr>
      <th>logw0</th>
      <td><p>log-probabilities or log-importance weights under H0.</p></td>
    </tr>
    <tr>
      <th>logw1</th>
      <td><p>log-probabilities or log-importance weights under H1.</p></td>
    </tr>
    </table>
    
    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>The estimated Bayes factor.</p>
    
    <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>

    <p>Computes numerical estimate of
$$
  BF = Pr(data | H1) / Pr(data | H0),
$$
the probability of the data given the "alternative" hypothesis (H1) over
the probability of the data given the "null" hypothesis (H0). This is
also known as a Bayes factor (see Kass &amp; Raftery, 1995). Here we assume
that although these probabilities cannot be computed analytically
because they involve intractable integrals, we can obtain reasonable
estimates of these probabilities with a simple numerical approximation
over some latent variable assuming the prior over this latent variable
is uniform. The inputs are the log-probabilities
$$
  Pr(data, Z0 | H0) = Pr(data | Z0, H0) x Pr(Z0 | H0),
  Pr(data, Z1 | H1) = Pr(data | Z1, H1) x Pr(Z1 | H1),
$$
where Pr(Z0 | H0) and Pr(Z1 | H1) are uniform over all Z0 and Z1.</p>
<p>Alternatively, this function can be viewed as computing an importance
sampling estimate of the Bayes factor; see, for example, R. M. Neal,
"Annealed importance sampling", Statistics and Computing, 2001. This
formulation described above is a special case of importance sampling
when the settings of the latent variable Z0 and A1 are drawn from the
same (uniform) distribution as the prior, Pr(Z0 | H0) and Pr(Z1 | H1),
respectively.</p>
    
    <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2>

    <p>P. Carbonetto and M. Stephens (2012). Scalable variational inference
  for Bayesian variable selection in regression, and its accuracy in
  genetic association studies. <em>Bayesian Analysis</em> <b>7</b>,
  73--108.</p>
<p>R. E. Kass and A. E. Raftery (1995). Bayes Factors. <em>Journal of the
  American Statistical Association</em> <b>90</b>, 773--795.</p>
<p>R. M. Neal (2001). Annealed importance sampling. <em>Statistics and
  Computing</em> <b>11</b>, 125--139.</p>
    
    <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>

    <p><code><a href='varbvs.html'>varbvs</a></code>, <code><a href='normalizelogweights.html'>normalizelogweights</a></code></p>
    

  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
    <h2>Contents</h2>
    <ul class="nav nav-pills nav-stacked">
      <li><a href="#arguments">Arguments</a></li>
      
      <li><a href="#value">Value</a></li>

      <li><a href="#details">Details</a></li>

      <li><a href="#references">References</a></li>

      <li><a href="#see-also">See also</a></li>
          </ul>

    <h2>Author</h2>
    Peter Carbonetto <a href='mailto:peter.carbonetto@gmail.com'>peter.carbonetto@gmail.com</a>
  </div>
</div>

      <footer>
      <div class="copyright">
  <p>Developed by Peter Carbonetto, Matthew Stephens, David Gerard.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p>
</div>

      </footer>
   </div>

  </body>
</html>
