<!-- 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>Internal varbvs functions — varbvs-internal • 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>Internal varbvs functions</h1>
    </div>

    
    <p>Internal varbvs functions</p>
    

    <pre><span class='fu'>diagsq</span>(<span class='no'>X</span>,<span class='kw'>a</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)
<span class='fu'>diagsqt</span>(<span class='no'>X</span>,<span class='kw'>a</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)
<span class='fu'>var1</span>(<span class='no'>x</span>)
<span class='fu'>var1.cols</span>(<span class='no'>X</span>)
<span class='fu'>varbvspve</span>(<span class='no'>X</span>,<span class='no'>fit</span>,<span class='kw'>nr</span> <span class='kw'>=</span> <span class='fl'>1000</span>)
<span class='fu'>varbvsnorm</span>(<span class='no'>X</span>,<span class='no'>y</span>,<span class='no'>sigma</span>,<span class='no'>sa</span>,<span class='no'>logodds</span>,<span class='no'>alpha</span>,<span class='no'>mu</span>,<span class='kw'>tol</span> <span class='kw'>=</span> <span class='fl'>1e-4</span>,<span class='kw'>maxiter</span> <span class='kw'>=</span> <span class='fl'>1e4</span>,
           <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,<span class='kw'>outer.iter</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,<span class='kw'>update.sigma</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
           <span class='kw'>update.sa</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,<span class='kw'>n0</span> <span class='kw'>=</span> <span class='fl'>10</span>,<span class='kw'>sa0</span> <span class='kw'>=</span> <span class='fl'>1</span>)
<span class='fu'>varbvsbin</span>(<span class='no'>X</span>,<span class='no'>y</span>,<span class='no'>sa</span>,<span class='no'>logodds</span>,<span class='no'>alpha</span>,<span class='no'>mu</span>,<span class='no'>eta</span>,<span class='kw'>tol</span> <span class='kw'>=</span> <span class='fl'>1e-4</span>,<span class='kw'>maxiter</span> <span class='kw'>=</span> <span class='fl'>1e4</span>,
          <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,<span class='kw'>outer.iter</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,<span class='kw'>update.sa</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
          <span class='kw'>optimize.eta</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,<span class='kw'>n0</span> <span class='kw'>=</span> <span class='fl'>10</span>,<span class='kw'>sa0</span> <span class='kw'>=</span> <span class='fl'>1</span>)
<span class='fu'>varbvsbinz</span>(<span class='no'>X</span>,<span class='no'>Z</span>,<span class='no'>y</span>,<span class='no'>sa</span>,<span class='no'>logodds</span>,<span class='no'>alpha</span>,<span class='no'>mu</span>,<span class='no'>eta</span>,<span class='kw'>tol</span> <span class='kw'>=</span> <span class='fl'>1e-4</span>,<span class='kw'>maxiter</span> <span class='kw'>=</span> <span class='fl'>1e4</span>,
           <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,<span class='kw'>outer.iter</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,<span class='kw'>update.sa</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
           <span class='kw'>optimize.eta</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,<span class='kw'>n0</span> <span class='kw'>=</span> <span class='fl'>10</span>,<span class='kw'>sa0</span> <span class='kw'>=</span> <span class='fl'>1</span>)</pre>
        
    <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>

    <p>These functions are only intended to be used by expert
  users. Here we provide brief descriptions of some of these internal
  functions. <code>diagsq(X,a)</code> and <code>diagsqt(X,a)</code> compute the
  diagonal entries of the matrix products \(X'*A*X\) and \(X*A*X'\),
  respectively, where <code>A = diag(a)</code>, but the computation is done
  more efficiently, and without having to store an intermediate matrix
  of the same size as the matrix.</p>
<p><code>var1(x)</code> returns the second moment of vector x about its mean.
    <code>var1.cols(X)</code> computes the second moment of each column of X about
  its mean.</p>
<p><code>varbvspve</code> draws posterior estimates of the proportion of
  variance in Y explained by the Bayesian variable selection model
  fitted using a variational approximation. This function is only valid
  for the linear regression model <code>(family = "gaussian")</code>.</p>
<p>Functions <code>varbvsnorm</code>, <code>varbvsbin</code> and <code>varbvsbinz</code>
  implement the co-ordinate ascent algorithm to fit the fully-factorized
  variational approximation for Bayesian variable selection, conditioned
  on settings of the hyperparameters. These functions implement the
  algorithm for the linear regression, logistic regression with an
  intercept, and logistic regression with arbitrary covariates,
  respectively.</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="#details">Details</a></li>
          </ul>

    <h2>Author</h2>
    Peter Carbonetto &lt;peter.carbonetto@gmail.com&gt;
  </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>
