<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><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>Add draws from the posterior fit, predictions, or residuals of a model to a data frame — add_epred_draws • tidybayes</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/paper/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css"><script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"><script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet"><meta property="og:title" content="Add draws from the posterior fit, predictions, or residuals of a model to a data frame — add_epred_draws"><meta property="og:description" content="Given a data frame and a model, adds draws from the linear/link-level predictor,
the expectation of the posterior predictive, the posterior predictive, or the residuals of a model to
the data frame in a long format."><meta property="og:image" content="https://mjskay.github.io/tidybayes/logo.svg"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></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]--><!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=UA-93322-5"></script><script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-93322-5');
</script></head><body data-spy="scroll" data-target="#toc">


    <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" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">tidybayes</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">3.0.7</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav"><li>
  <a href="../articles/tidybayes.html">Get started</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
    Articles

    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu"><li>
      <a href="../articles/tidy-brms.html">Extracting and visualizing tidy draws from brms models</a>
    </li>
    <li>
      <a href="../articles/tidy-posterior.html">Using tidybayes with the posterior package</a>
    </li>
    <li>
      <a href="../articles/tidy-rstanarm.html">Extracting and visualizing tidy draws from rstanarm models</a>
    </li>
    <li>
      <a href="../articles/tidybayes-residuals.html">Extracting and visualizing tidy residuals from Bayesian models</a>
    </li>
  </ul></li>
<li>
  <a href="../news/index.html">Changelog</a>
</li>
      </ul><ul class="nav navbar-nav navbar-right"><li>
  <a href="https://github.com/mjskay/tidybayes/" class="external-link">
    <span class="fab 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>Add draws from the posterior fit, predictions, or residuals of a model to a data frame</h1>
    <small class="dont-index">Source: <a href="https://github.com/mjskay/tidybayes/blob/HEAD/R/epred_draws.R" class="external-link"><code>R/epred_draws.R</code></a>, <a href="https://github.com/mjskay/tidybayes/blob/HEAD/R/linpred_draws.R" class="external-link"><code>R/linpred_draws.R</code></a>, <a href="https://github.com/mjskay/tidybayes/blob/HEAD/R/predicted_draws.R" class="external-link"><code>R/predicted_draws.R</code></a>, and 1 more</small>
    <div class="hidden name"><code>add_predicted_draws.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Given a data frame and a model, adds draws from the linear/link-level predictor,
the expectation of the posterior predictive, the posterior predictive, or the residuals of a model to
the data frame in a long format.</p>
    </div>

    <div id="ref-usage">
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">add_epred_draws</span><span class="op">(</span></span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".epred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">epred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".epred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Default S3 method</span></span>
<span><span class="fu">epred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".epred"</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for class 'stanreg'</span></span>
<span><span class="fu">epred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".epred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for class 'brmsfit'</span></span>
<span><span class="fu">epred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".epred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">add_linpred_draws</span><span class="op">(</span></span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".linpred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  <span class="va">n</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">linpred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".linpred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  <span class="va">n</span>,</span>
<span>  <span class="va">scale</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Default S3 method</span></span>
<span><span class="fu">linpred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".linpred"</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for class 'stanreg'</span></span>
<span><span class="fu">linpred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".linpred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for class 'brmsfit'</span></span>
<span><span class="fu">linpred_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".linpred"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  dpar <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">add_predicted_draws</span><span class="op">(</span></span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".prediction"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  <span class="va">n</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">predicted_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".prediction"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  <span class="va">n</span>,</span>
<span>  <span class="va">prediction</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Default S3 method</span></span>
<span><span class="fu">predicted_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".prediction"</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for class 'stanreg'</span></span>
<span><span class="fu">predicted_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".prediction"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for class 'brmsfit'</span></span>
<span><span class="fu">predicted_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".prediction"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">add_residual_draws</span><span class="op">(</span></span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".residual"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  <span class="va">n</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">residual_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".residual"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span>,</span>
<span>  <span class="va">n</span>,</span>
<span>  <span class="va">residual</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Default S3 method</span></span>
<span><span class="fu">residual_draws</span><span class="op">(</span><span class="va">object</span>, <span class="va">newdata</span>, <span class="va">...</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for class 'brmsfit'</span></span>
<span><span class="fu">residual_draws</span><span class="op">(</span></span>
<span>  <span class="va">object</span>,</span>
<span>  <span class="va">newdata</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  value <span class="op">=</span> <span class="st">".residual"</span>,</span>
<span>  ndraws <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  seed <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  re_formula <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  category <span class="op">=</span> <span class="st">".category"</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div id="arguments">
    <h2>Arguments</h2>


<dl><dt id="arg-newdata">newdata<a class="anchor" aria-label="anchor" href="#arg-newdata"></a></dt>
<dd><p>Data frame to generate predictions from.</p></dd>


<dt id="arg-object">object<a class="anchor" aria-label="anchor" href="#arg-object"></a></dt>
<dd><p>A supported Bayesian model fit that can provide fits and predictions. Supported models
are listed in the second section of <a href="tidybayes-models.html">tidybayes-models</a>: <em>Models Supporting Prediction</em>. While other
functions in this package (like <code><a href="spread_draws.html">spread_draws()</a></code>) support a wider range of models, to work with
<code>add_epred_draws()</code>, <code>add_predicted_draws()</code>, etc. a model must provide an interface for generating
predictions, thus more generic Bayesian modeling interfaces like <code>runjags</code> and <code>rstan</code> are not directly
supported for these functions (only wrappers around those languages that provide predictions, like <code>rstanarm</code>
and <code>brm</code>, are supported here).</p></dd>


<dt id="arg--">...<a class="anchor" aria-label="anchor" href="#arg--"></a></dt>
<dd><p>Additional arguments passed to the underlying prediction method for the type of
model given.</p></dd>


<dt id="arg-value">value<a class="anchor" aria-label="anchor" href="#arg-value"></a></dt>
<dd><p>The name of the output column:</p><ul><li><p>for <code>[add_]epred_draws()</code>, defaults to <code>".epred"</code>.</p></li>
<li><p>for <code>[add_]predicted_draws()</code>, defaults to <code>".prediction"</code>.</p></li>
<li><p>for <code>[add_]linpred_draws()</code>, defaults to <code>".linpred"</code>.</p></li>
<li><p>for <code>[add_]residual_draws()</code>, defaults to <code>".residual"</code></p></li>
</ul></dd>


<dt id="arg-ndraws">ndraws<a class="anchor" aria-label="anchor" href="#arg-ndraws"></a></dt>
<dd><p>The number of draws to return, or <code>NULL</code> to return all draws.</p></dd>


<dt id="arg-seed">seed<a class="anchor" aria-label="anchor" href="#arg-seed"></a></dt>
<dd><p>A seed to use when subsampling draws (i.e. when <code>ndraws</code> is not <code>NULL</code>).</p></dd>


<dt id="arg-re-formula">re_formula<a class="anchor" aria-label="anchor" href="#arg-re-formula"></a></dt>
<dd><p>formula containing group-level effects to be considered in the prediction.
If <code>NULL</code> (default), include all group-level effects; if <code>NA</code>, include no group-level effects.
Some model types (such as <a href="https://paul-buerkner.github.io/brms/reference/brmsfit-class.html" class="external-link">brms::brmsfit</a> and <a href="https://mc-stan.org/rstanarm/reference/stanreg-objects.html" class="external-link">rstanarm::stanreg-objects</a>) allow
marginalizing over grouping factors by specifying new levels of a factor in <code>newdata</code>. In the case of
<code><a href="https://paul-buerkner.github.io/brms/reference/brm.html" class="external-link">brms::brm()</a></code>, you must also pass <code>allow_new_levels = TRUE</code> here to include new levels (see
<code><a href="https://paul-buerkner.github.io/brms/reference/posterior_predict.brmsfit.html" class="external-link">brms::posterior_predict()</a></code>).</p></dd>


<dt id="arg-category">category<a class="anchor" aria-label="anchor" href="#arg-category"></a></dt>
<dd><p>For <em>some</em> ordinal, multinomial, and multivariate models (notably, <code><a href="https://paul-buerkner.github.io/brms/reference/brm.html" class="external-link">brms::brm()</a></code> models but
<em>not</em> <code><a href="https://mc-stan.org/rstanarm/reference/stan_polr.html" class="external-link">rstanarm::stan_polr()</a></code> models), multiple sets of rows will be returned per input row for
<code>epred_draws()</code> or <code>predicted_draws()</code>, depending on the model type. For ordinal/multinomial models,
these rows correspond to different categories of the response variable. For multivariate models, these correspond to
different response variables. The <code>category</code> argument specifies the name of the column
to put the category names (or variable names) into in the resulting data frame. The default name of this column
(<code>".category"</code>) reflects the fact that this functionality was originally used only for ordinal models and
has been re-used for multivariate models. The fact that multiple rows per response are returned only for some
model types reflects the fact that tidybayes takes the approach of tidying whatever output is given to us, and
the output from different modeling functions differs on this point.
See <code><a href="../articles/tidy-brms.html">vignette("tidy-brms")</a></code> and <code><a href="../articles/tidy-rstanarm.html">vignette("tidy-rstanarm")</a></code> for examples of dealing with output
from ordinal models using both approaches.</p></dd>


<dt id="arg-dpar">dpar<a class="anchor" aria-label="anchor" href="#arg-dpar"></a></dt>
<dd><p>For <code>add_epred_draws()</code> and <code>add_linpred_draws()</code>: Should distributional regression
parameters be included in the output? Valid only for models that support distributional regression parameters,
such as submodels for variance parameters (as in <code><a href="https://paul-buerkner.github.io/brms/reference/brm.html" class="external-link">brms::brm()</a></code>). If <code>TRUE</code>, distributional regression
parameters are included in the output as additional columns named after each parameter
(alternative names can be provided using a list or named vector, e.g. <code>c(sigma.hat = "sigma")</code>
would output the <code>"sigma"</code> parameter from a model as a column named <code>"sigma.hat"</code>).
If <code>NULL</code> or <code>FALSE</code> (the default), distributional regression parameters are not included.</p></dd>


<dt id="arg-n">n<a class="anchor" aria-label="anchor" href="#arg-n"></a></dt>
<dd><p>(Deprecated). Use <code>ndraws</code>.</p></dd>


<dt id="arg-scale">scale<a class="anchor" aria-label="anchor" href="#arg-scale"></a></dt>
<dd><p>(Deprecated). Use the appropriate function (<code>epred_draws()</code> or <code>linpred_draws()</code>)
depending on what type of distribution you want. For <code>linpred_draws()</code>, you may want the
<code>transform</code> argument. See <code><a href="https://mc-stan.org/rstantools/reference/posterior_linpred.html" class="external-link">rstanarm::posterior_linpred()</a></code> or <code><a href="https://mc-stan.org/rstantools/reference/posterior_linpred.html" class="external-link">brms::posterior_linpred()</a></code>.</p></dd>


<dt id="arg-prediction-residual">prediction, residual<a class="anchor" aria-label="anchor" href="#arg-prediction-residual"></a></dt>
<dd><p>(Deprecated). Use <code>value</code>.</p></dd>

</dl></div>
    <div id="value">
    <h2>Value</h2>
    <p>A data frame (actually, a <a href="https://tibble.tidyverse.org/reference/tibble.html" class="external-link">tibble</a>) with a <code>.row</code> column (a
factor grouping rows from the input <code>newdata</code>), <code>.chain</code> column (the chain
each draw came from, or <code>NA</code> if the model does not provide chain information),
<code>.iteration</code> column (the iteration the draw came from, or <code>NA</code> if the model does
not provide iteration information), and a <code>.draw</code> column (a unique index corresponding to each draw
from the distribution). In addition, <code>epred_draws</code> includes a column with its name specified by
the <code>epred</code> argument (default <code>".epred"</code>); <code>linpred_draws</code> includes a column with its name
specified by the <code>linpred</code> argument (default <code>".linpred"</code>), and
<code>predicted_draws</code> contains a column with its name specified by the <code>.prediction</code> argument (default
<code>".prediction"</code>). For convenience, the resulting data frame comes grouped by the original input rows.</p>
    </div>
    <div id="details">
    <h2>Details</h2>
    <p>Consider a model like:</p>
<p>$$\begin{array}{rcl}
y &amp;\sim&amp; \textrm{SomeDist}(\theta_1, \theta_2)\\
f_1(\theta_1) &amp;=&amp; \alpha_1 + \beta_1 x\\
f_2(\theta_2) &amp;=&amp; \alpha_2 + \beta_2 x
\end{array}$$</p>
<p>This model has:</p><ul><li><p>an outcome variable, \(y\)</p></li>
<li><p>a response distribution, \(\textrm{SomeDist}\), having parameters \(\theta_1\)
(with link function \(f_1\)) and \(\theta_2\) (with link function \(f_2\))</p></li>
<li><p>a single predictor, \(x\)</p></li>
<li><p>coefficients \(\alpha_1\), \(\beta_1\), \(\alpha_2\), and \(\beta_2\)</p></li>
</ul><p>We fit this model to some observed data, \(y_\textrm{obs}\), and predictors,
\(x_\textrm{obs}\). Given new values of predictors, \(x_\textrm{new}\),
supplied in the data frame <code>newdata</code>, the functions for posterior draws are
defined as follows:</p><ul><li><p><code>add_predicted_draws()</code> adds draws from the <strong>posterior predictive distribution</strong>,
\(p(y_\textrm{new} | x_\textrm{new}, y_\textrm{obs})\),
to the data.
It corresponds to <code><a href="https://mc-stan.org/rstanarm/reference/posterior_predict.stanreg.html" class="external-link">rstanarm::posterior_predict()</a></code> or <code><a href="https://paul-buerkner.github.io/brms/reference/posterior_predict.brmsfit.html" class="external-link">brms::posterior_predict()</a></code>.</p></li>
<li><p><code>add_epred_draws()</code> adds draws from the <strong>expectation of the posterior predictive
distribution</strong>, aka the conditional expectation,
\(E(y_\textrm{new} | x_\textrm{new}, y_\textrm{obs})\),
to the data.
It corresponds to <code><a href="https://mc-stan.org/rstanarm/reference/posterior_linpred.stanreg.html" class="external-link">rstanarm::posterior_epred()</a></code> or <code><a href="https://paul-buerkner.github.io/brms/reference/posterior_epred.brmsfit.html" class="external-link">brms::posterior_epred()</a></code>.
Not all models support this function.</p></li>
<li><p><code>add_linpred_draws()</code> adds draws from the <strong>posterior linear predictors</strong> to the data.
It corresponds to <code><a href="https://mc-stan.org/rstanarm/reference/posterior_linpred.stanreg.html" class="external-link">rstanarm::posterior_linpred()</a></code> or <code><a href="https://paul-buerkner.github.io/brms/reference/posterior_linpred.brmsfit.html" class="external-link">brms::posterior_linpred()</a></code>.
Depending on the model type and additional parameters passed, this may be:</p><ul><li><p>The untransformed linear predictor, e.g.
\(p(f_1(\theta_1) | x_\textrm{new}, y_\textrm{obs})\) =
\(p(\alpha_1 + \beta_1 x_\textrm{new} | x_\textrm{new}, y_\textrm{obs})\).
This is returned by <code>add_linpred_draws(transform = FALSE)</code> for <span class="pkg">brms</span> and <span class="pkg">rstanarm</span> models.
It is analogous to <code>type = "link"</code> in <code><a href="https://rdrr.io/r/stats/predict.glm.html" class="external-link">predict.glm()</a></code>.</p></li>
<li><p>The inverse-link transformed linear predictor, e.g.
\(p(\theta_1 | x_\textrm{new}, y_\textrm{obs})\) =
\(p(f_1^{-1}(\alpha_1 + \beta_1 x_\textrm{new}) | x_\textrm{new}, y_\textrm{obs})\).
This is returned by <code>add_linpred_draws(transform = TRUE)</code> for <span class="pkg">brms</span> and <span class="pkg">rstanarm</span> models.
It is analogous to <code>type = "response"</code> in <code><a href="https://rdrr.io/r/stats/predict.glm.html" class="external-link">predict.glm()</a></code>.</p></li>
</ul><p><strong>NOTE:</strong> <code>add_linpred_draws(transform = TRUE)</code> and <code>add_epred_draws()</code> may be equivalent but
are not guaranteed to be. They are equivalent when the expectation of the response
distribution is equal to its first parameter, i.e. when \(E(y) = \theta_1\). Many
distributions have this property (e.g. Normal distributions, Bernoulli distributions),
but not all. If you want the expectation of the posterior predictive, it is best to
use <code>add_epred_draws()</code> if available, and if not available, verify this property holds prior
to using <code>add_linpred_draws()</code>.</p></li>
<li><p><code>add_residual_draws()</code> adds draws from residuals,
\(p(y_\textrm{obs} - y_\textrm{new} | x_\textrm{new}, y_\textrm{obs})\),
to the data.
It corresponds to <code><a href="https://paul-buerkner.github.io/brms/reference/residuals.brmsfit.html" class="external-link">brms::residuals.brmsfit()</a></code>.</p></li>
</ul><p>The corresponding functions without <code>add_</code> as a prefix are alternate spellings
with the opposite order of the first two arguments: e.g. <code>add_predicted_draws(newdata, object)</code>
versus <code>predicted_draws(object, newdata)</code>. This facilitates use in data
processing pipelines that start either with a data frame or a model.</p>
<p>Given equal choice between the two, the spellings prefixed with <code>add_</code>
are preferred.</p>
    </div>
    <div id="see-also">
    <h2>See also</h2>
    <div class="dont-index"><p><code><a href="add_draws.html">add_draws()</a></code> for the variant of these functions for use with packages that do not have
explicit support for these functions yet. See <code><a href="spread_draws.html">spread_draws()</a></code> for manipulating posteriors directly.</p></div>
    </div>
    <div id="author">
    <h2>Author</h2>
    <p>Matthew Kay</p>
    </div>

    <div id="ref-examples">
    <h2>Examples</h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="co"># \dontrun{</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://ggplot2.tidyverse.org" class="external-link">ggplot2</a></span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/paul-buerkner/brms" class="external-link">brms</a></span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://modelr.tidyverse.org" class="external-link">modelr</a></span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/theme_get.html" class="external-link">theme_set</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html" class="external-link">theme_light</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">m_mpg</span> <span class="op">=</span> <span class="fu"><a href="https://paul-buerkner.github.io/brms/reference/brm.html" class="external-link">brm</a></span><span class="op">(</span><span class="va">mpg</span> <span class="op">~</span> <span class="va">hp</span> <span class="op">*</span> <span class="va">cyl</span>, data <span class="op">=</span> <span class="va">mtcars</span>,</span></span>
<span class="r-in"><span>  <span class="co"># 1 chain / few iterations just so example runs quickly</span></span></span>
<span class="r-in"><span>  <span class="co"># do not use in practice</span></span></span>
<span class="r-in"><span>  chains <span class="op">=</span> <span class="fl">1</span>, iter <span class="op">=</span> <span class="fl">500</span><span class="op">)</span></span></span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> Compiling Stan program...</span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> Start sampling</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Gradient evaluation took 4.3e-05 seconds</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.43 seconds.</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Adjust your expectations accordingly!</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration:   1 / 500 [  0%]  (Warmup)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration:  50 / 500 [ 10%]  (Warmup)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 100 / 500 [ 20%]  (Warmup)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 150 / 500 [ 30%]  (Warmup)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 200 / 500 [ 40%]  (Warmup)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 250 / 500 [ 50%]  (Warmup)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 251 / 500 [ 50%]  (Sampling)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 300 / 500 [ 60%]  (Sampling)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 350 / 500 [ 70%]  (Sampling)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 400 / 500 [ 80%]  (Sampling)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 450 / 500 [ 90%]  (Sampling)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: Iteration: 500 / 500 [100%]  (Sampling)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1:  Elapsed Time: 0.123 seconds (Warm-up)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1:                0.047 seconds (Sampling)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1:                0.17 seconds (Total)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Chain 1: </span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> Running the chains for more iterations may help. See</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> https://mc-stan.org/misc/warnings.html#bulk-ess</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> Running the chains for more iterations may help. See</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> https://mc-stan.org/misc/warnings.html#tail-ess</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># draw 100 lines from the posterior means and overplot them</span></span></span>
<span class="r-in"><span><span class="va">mtcars</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://modelr.tidyverse.org/reference/data_grid.html" class="external-link">data_grid</a></span><span class="op">(</span>hp <span class="op">=</span> <span class="fu"><a href="https://modelr.tidyverse.org/reference/seq_range.html" class="external-link">seq_range</a></span><span class="op">(</span><span class="va">hp</span>, n <span class="op">=</span> <span class="fl">101</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="co"># NOTE: only use ndraws here when making spaghetti plots; for</span></span></span>
<span class="r-in"><span>  <span class="co"># plotting intervals it is always best to use all draws (omit ndraws)</span></span></span>
<span class="r-in"><span>  <span class="fu">add_epred_draws</span><span class="op">(</span><span class="va">m_mpg</span>, ndraws <span class="op">=</span> <span class="fl">100</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">hp</span>, y <span class="op">=</span> <span class="va">mpg</span>, color <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html" class="external-link">ordered</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_path.html" class="external-link">geom_line</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>y <span class="op">=</span> <span class="va">.epred</span>, group <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html" class="external-link">paste</a></span><span class="op">(</span><span class="va">cyl</span>, <span class="va">.draw</span><span class="op">)</span><span class="op">)</span>, alpha <span class="op">=</span> <span class="fl">0.25</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_point.html" class="external-link">geom_point</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="add_predicted_draws-1.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># plot posterior predictive intervals</span></span></span>
<span class="r-in"><span><span class="va">mtcars</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://modelr.tidyverse.org/reference/data_grid.html" class="external-link">data_grid</a></span><span class="op">(</span>hp <span class="op">=</span> <span class="fu"><a href="https://modelr.tidyverse.org/reference/seq_range.html" class="external-link">seq_range</a></span><span class="op">(</span><span class="va">hp</span>, n <span class="op">=</span> <span class="fl">101</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu">add_predicted_draws</span><span class="op">(</span><span class="va">m_mpg</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">hp</span>, y <span class="op">=</span> <span class="va">mpg</span>, color <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html" class="external-link">ordered</a></span><span class="op">(</span><span class="va">cyl</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="http://mjskay.github.io/ggdist/reference/stat_lineribbon.html" class="external-link">stat_lineribbon</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>y <span class="op">=</span> <span class="va">.prediction</span><span class="op">)</span>, .width <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">.99</span>, <span class="fl">.95</span>, <span class="fl">.8</span>, <span class="fl">.5</span><span class="op">)</span>, alpha <span class="op">=</span> <span class="fl">0.25</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_point.html" class="external-link">geom_point</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">mtcars</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_brewer.html" class="external-link">scale_fill_brewer</a></span><span class="op">(</span>palette <span class="op">=</span> <span class="st">"Greys"</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="add_predicted_draws-2.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># }</span></span></span>
</code></pre></div>
    </div>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top"><h2 data-toc-skip>Contents</h2>
    </nav></div>
</div>


      <footer><div class="copyright">
  <p></p><p>Developed by <a href="https://www.mjskay.com" class="external-link">Matthew Kay</a>.</p>
</div>

<div class="pkgdown">
  <p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.0.</p>
</div>

      </footer></div>






  </body></html>

