<!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, shrink-to-fit=no"><meta name="description" content="Translates draws from distributions in a (possibly grouped) data frame into point and
interval summaries (or set of point and interval summaries, if there are
multiple groups in a grouped data frame)."><title>Point and interval summaries for tidy data frames of draws from distributions — point_interval • ggdist</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"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/Source_Sans_Pro-0.4.8/font.css" rel="stylesheet"><link href="../deps/Source_Code_Pro-0.4.8/font.css" rel="stylesheet"><!-- 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"><!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" 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><!-- 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><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Point and interval summaries for tidy data frames of draws from distributions — point_interval"><meta property="og:description" content="Translates draws from distributions in a (possibly grouped) data frame into point and
interval summaries (or set of point and interval summaries, if there are
multiple groups in a grouped data frame)."><meta property="og:image" content="http://mjskay.github.io/ggdist/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>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>
    

    <nav class="navbar fixed-top navbar-light navbar-expand-lg bg-light"><div class="container">
    
    <a class="navbar-brand me-2" href="../index.html">ggdist</a>

    <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.3.2</small>

    
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item">
  <a class="nav-link" href="../reference/index.html">Reference</a>
</li>
<li class="nav-item dropdown">
  <a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown-articles">Articles</a>
  <div class="dropdown-menu" aria-labelledby="dropdown-articles">
    <a class="dropdown-item" href="../articles/dotsinterval.html">Dots + interval stats and geoms</a>
    <a class="dropdown-item" href="../articles/freq-uncertainty-vis.html">Frequentist uncertainty visualization</a>
    <a class="dropdown-item" href="../articles/lineribbon.html">Lineribbon stats and geoms</a>
    <a class="dropdown-item" href="../articles/slabinterval.html">Slab + interval stats and geoms</a>
    <a class="dropdown-item" href="../articles/thickness.html">Thickness scale</a>
  </div>
</li>
<li class="nav-item">
  <a class="nav-link" href="../news/index.html">Changelog</a>
</li>
      </ul><form class="form-inline my-2 my-lg-0" role="search">
        <input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="../search.json" id="search-input" placeholder="Search for" autocomplete="off"></form>

      <ul class="navbar-nav"><li class="nav-item">
  <a class="external-link nav-link" href="https://github.com/mjskay/ggdist/" aria-label="github">
    <span class="fab fa fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul></div>

    
  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">
      <img src="../logo.svg" class="logo" alt=""><h1>Point and interval summaries for tidy data frames of draws from distributions</h1>
      <small class="dont-index">Source: <a href="https://github.com/mjskay/ggdist/blob/HEAD/R/point_interval.R" class="external-link"><code>R/point_interval.R</code></a></small>
      <div class="d-none name"><code>point_interval.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Translates draws from distributions in a (possibly grouped) data frame into point and
interval summaries (or set of point and interval summaries, if there are
multiple groups in a grouped data frame).</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">point_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.95</span>,</span>
<span>  .point <span class="op">=</span> <span class="va">median</span>,</span>
<span>  .interval <span class="op">=</span> <span class="va">qi</span>,</span>
<span>  .simple_names <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  .exclude <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="st">".chain"</span>, <span class="st">".iteration"</span>, <span class="st">".draw"</span>, <span class="st">".row"</span><span class="op">)</span>,</span>
<span>  <span class="va">.prob</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for default</span></span>
<span><span class="fu">point_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.95</span>,</span>
<span>  .point <span class="op">=</span> <span class="va">median</span>,</span>
<span>  .interval <span class="op">=</span> <span class="va">qi</span>,</span>
<span>  .simple_names <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  .exclude <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="st">".chain"</span>, <span class="st">".iteration"</span>, <span class="st">".draw"</span>, <span class="st">".row"</span><span class="op">)</span>,</span>
<span>  <span class="va">.prob</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for numeric</span></span>
<span><span class="fu">point_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.95</span>,</span>
<span>  .point <span class="op">=</span> <span class="va">median</span>,</span>
<span>  .interval <span class="op">=</span> <span class="va">qi</span>,</span>
<span>  .simple_names <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  .exclude <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="st">".chain"</span>, <span class="st">".iteration"</span>, <span class="st">".draw"</span>, <span class="st">".row"</span><span class="op">)</span>,</span>
<span>  <span class="va">.prob</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for rvar</span></span>
<span><span class="fu">point_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.95</span>,</span>
<span>  .point <span class="op">=</span> <span class="va">median</span>,</span>
<span>  .interval <span class="op">=</span> <span class="va">qi</span>,</span>
<span>  .simple_names <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for distribution</span></span>
<span><span class="fu">point_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.95</span>,</span>
<span>  .point <span class="op">=</span> <span class="va">median</span>,</span>
<span>  .interval <span class="op">=</span> <span class="va">qi</span>,</span>
<span>  .simple_names <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">qi</span><span class="op">(</span><span class="va">x</span>, .width <span class="op">=</span> <span class="fl">0.95</span>, <span class="va">.prob</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">ll</span><span class="op">(</span><span class="va">x</span>, .width <span class="op">=</span> <span class="fl">0.95</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">ul</span><span class="op">(</span><span class="va">x</span>, .width <span class="op">=</span> <span class="fl">0.95</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">hdi</span><span class="op">(</span></span>
<span>  <span class="va">x</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.95</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  density <span class="op">=</span> <span class="fu"><a href="density_bounded.html">density_bounded</a></span><span class="op">(</span>trim <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span>
<span>  n <span class="op">=</span> <span class="fl">4096</span>,</span>
<span>  <span class="va">.prob</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">Mode</span><span class="op">(</span><span class="va">x</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for default</span></span>
<span><span class="fu">Mode</span><span class="op">(</span></span>
<span>  <span class="va">x</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  density <span class="op">=</span> <span class="fu"><a href="density_bounded.html">density_bounded</a></span><span class="op">(</span>trim <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span>
<span>  n <span class="op">=</span> <span class="fl">2001</span>,</span>
<span>  weights <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 rvar</span></span>
<span><span class="fu">Mode</span><span class="op">(</span><span class="va">x</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for distribution</span></span>
<span><span class="fu">Mode</span><span class="op">(</span><span class="va">x</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span>, <span class="va">...</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">hdci</span><span class="op">(</span><span class="va">x</span>, .width <span class="op">=</span> <span class="fl">0.95</span>, na.rm <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mean_qi</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">median_qi</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mode_qi</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mean_ll</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">median_ll</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mode_ll</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mean_ul</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">median_ul</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mode_ul</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mean_hdi</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">median_hdi</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mode_hdi</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mean_hdci</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">median_hdci</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">mode_hdci</span><span class="op">(</span><span class="va">.data</span>, <span class="va">...</span>, .width <span class="op">=</span> <span class="fl">0.95</span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>
    <dl><dt>.data</dt>
<dd><p>Data frame (or grouped data frame as returned by <code><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">dplyr::group_by()</a></code>)
that contains draws to summarize.</p></dd>


<dt>...</dt>
<dd><p>Bare column names or expressions that, when evaluated in the context of
<code>.data</code>, represent draws to summarize. If this is empty, then by default all
columns that are not group columns and which are not in <code>.exclude</code> (by default
<code>".chain"</code>, <code>".iteration"</code>, <code>".draw"</code>, and <code>".row"</code>) will be summarized.
These columns can be numeric, <span class="pkg">distributional</span> objects, <code><a href="https://mc-stan.org/posterior/reference/rvar.html" class="external-link">posterior::rvar</a></code>s,
or list columns of numeric values to summarise.</p></dd>


<dt>.width</dt>
<dd><p>vector of probabilities to use that determine the widths of the resulting intervals.
If multiple probabilities are provided, multiple rows per group are generated, each with
a different probability interval (and value of the corresponding <code>.width</code> column).</p></dd>


<dt>.point</dt>
<dd><p>Point summary function, which takes a vector and returns a single
value, e.g. <code><a href="https://rdrr.io/r/base/mean.html" class="external-link">mean()</a></code>, <code><a href="https://rdrr.io/r/stats/median.html" class="external-link">median()</a></code>, or <code>Mode()</code>.</p></dd>


<dt>.interval</dt>
<dd><p>Interval function, which takes a vector and a probability
(<code>.width</code>) and returns a two-element vector representing the lower and upper
bound of an interval; e.g. <code>qi()</code>, <code>hdi()</code></p></dd>


<dt>.simple_names</dt>
<dd><p>When <code>TRUE</code> and only a single column / vector is to be summarized, use the
name <code>.lower</code> for the lower end of the interval and <code>.upper</code> for the
upper end. If <code>.data</code> is a vector and this is <code>TRUE</code>, this will also set the column name
of the point summary to <code>.value</code>. When <code>FALSE</code> and <code>.data</code> is a data frame,
names the lower and upper intervals for each column <code>x</code> <code>x.lower</code> and <code>x.upper</code>.
When <code>FALSE</code> and <code>.data</code> is a vector, uses the naming scheme <code>y</code>, <code>ymin</code>
and <code>ymax</code> (for use with ggplot).</p></dd>


<dt>na.rm</dt>
<dd><p>logical value indicating whether <code>NA</code> values should be stripped before the computation proceeds.
If <code>FALSE</code> (the default), any vectors to be summarized that contain <code>NA</code> will result in
point and interval summaries equal to <code>NA</code>.</p></dd>


<dt>.exclude</dt>
<dd><p>A character vector of names of columns to be excluded from summarization
if no column names are specified to be summarized. Default ignores several meta-data column
names used in <span class="pkg">ggdist</span> and <span class="pkg">tidybayes</span>.</p></dd>


<dt>.prob</dt>
<dd><p>Deprecated. Use <code>.width</code> instead.</p></dd>


<dt>x</dt>
<dd><p>vector to summarize (for interval functions: <code>qi</code> and <code>hdi</code>)</p></dd>


<dt>density</dt>
<dd><p>For <code>hdi()</code> and <code>Mode()</code>, the kernel density estimator to use, either as
a function (e.g. <code><a href="density_bounded.html">density_bounded</a></code>, <code><a href="density_unbounded.html">density_unbounded</a></code>) or as a string giving the
suffix to a function that starts with <code>density_</code> (e.g. <code>"bounded"</code> or <code>"unbounded"</code>). The
default, <code>"bounded"</code>, uses the bounded density estimator of <code><a href="density_bounded.html">density_bounded()</a></code>, which
itself estimates the bounds of the distribution, and tends to work well on both bounded
and unbounded data.</p></dd>


<dt>n</dt>
<dd><p>For <code>hdi()</code> and <code>Mode()</code>, the number of points to use to estimate highest-density
intervals or modes.</p></dd>


<dt>weights</dt>
<dd><p>For <code>Mode()</code>, an optional vector, which (if not <code>NULL</code>) is of the same length
as <code>x</code> and provides weights for each element of <code>x</code>.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    

<p>A data frame containing point summaries and intervals, with at least one column corresponding
to the point summary, one to the lower end of the interval, one to the upper end of the interval, the
width of the interval (<code>.width</code>), the type of point summary (<code>.point</code>), and the type of interval (<code>.interval</code>).</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>If <code>.data</code> is a data frame, then <code>...</code> is a list of bare names of
columns (or expressions derived from columns) of <code>.data</code>, on which
the point and interval summaries are derived. Column expressions are processed
using the tidy evaluation framework (see <code><a href="https://rlang.r-lib.org/reference/eval_tidy.html" class="external-link">rlang::eval_tidy()</a></code>).</p>
<p>For a column named <code>x</code>, the resulting data frame will have a column
named <code>x</code> containing its point summary. If there is a single
column to be summarized and <code>.simple_names</code> is <code>TRUE</code>, the output will
also contain columns <code>.lower</code> (the lower end of the interval),
<code>.upper</code> (the upper end of the interval).
Otherwise, for every summarized column <code>x</code>, the output will contain
<code>x.lower</code> (the lower end of the interval) and <code>x.upper</code> (the upper
end of the interval). Finally, the output will have a <code>.width</code> column
containing the' probability for the interval on each output row.</p>
<p>If <code>.data</code> includes groups (see e.g. <code><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">dplyr::group_by()</a></code>),
the points and intervals are calculated within the groups.</p>
<p>If <code>.data</code> is a vector, <code>...</code> is ignored and the result is a
data frame with one row per value of <code>.width</code> and three columns:
<code>y</code> (the point summary), <code>ymin</code> (the lower end of the interval),
<code>ymax</code> (the upper end of the interval), and <code>.width</code>, the probability
corresponding to the interval. This behavior allows <code>point_interval</code>
and its derived functions (like <code>median_qi</code>, <code>mean_qi</code>, <code>mode_hdi</code>, etc)
to be easily used to plot intervals in ggplot stats using methods like
<code><a href="stat_eye.html">stat_eye()</a></code>, <code><a href="stat_halfeye.html">stat_halfeye()</a></code>, or <code><a href="https://ggplot2.tidyverse.org/reference/stat_summary.html" class="external-link">stat_summary()</a></code>.</p>
<p><code>median_qi</code>, <code>mode_hdi</code>, etc are short forms for
<code>point_interval(..., .point = median, .interval = qi)</code>, etc.</p>
<p><code>qi</code> yields the quantile interval (also known as the percentile interval or
equi-tailed interval) as a 1x2 matrix.</p>
<p><code>hdi</code> yields the highest-density interval(s) (also known as the highest posterior
density interval). <strong>Note:</strong> If the distribution is multimodal, <code>hdi</code> may return multiple
intervals for each probability level (these will be spread over rows). You may wish to use
<code>hdci</code> (below) instead if you want a single highest-density interval, with the caveat that when
the distribution is multimodal <code>hdci</code> is not a highest-density interval.</p>
<p><code>hdci</code> yields the highest-density <em>continuous</em> interval, also known as the shortest
probability interval. <strong>Note:</strong> If the distribution is multimodal, this may not actually
be the highest-density interval (there may be a higher-density
discontinuous interval, which can be found using <code>hdi</code>).</p>
<p><code>ll</code> and <code>ul</code> yield lower limits and upper limits, respectively (where the opposite
limit is set to either <code>Inf</code> or <code>-Inf</code>).</p>
    </div>
    <div class="section level2">
    <h2 id="author">Author<a class="anchor" aria-label="anchor" href="#author"></a></h2>
    <p>Matthew Kay</p>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><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://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://ggplot2.tidyverse.org" class="external-link">ggplot2</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://rdrr.io/r/base/Random.html" class="external-link">set.seed</a></span><span class="op">(</span><span class="fl">123</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://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">1000</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">median_qi</span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>             y      ymin     ymax .width .point .interval</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1 0.009209639 -1.941554 2.037887   0.95 median        qi</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span>x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">1000</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">median_qi</span><span class="op">(</span><span class="va">x</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">.50</span>, <span class="fl">.80</span>, <span class="fl">.95</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 3 × 6</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>        x .lower .upper .width .point .interval</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span>    </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> 0.054<span style="text-decoration: underline;">9</span> -<span style="color: #BB0000;">0.653</span>  0.753   0.5  median qi       </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> 0.054<span style="text-decoration: underline;">9</span> -<span style="color: #BB0000;">1.24</span>   1.34    0.8  median qi       </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">3</span> 0.054<span style="text-decoration: underline;">9</span> -<span style="color: #BB0000;">1.99</span>   1.91    0.95 median qi       </span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>    x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">1000</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>    y <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">1000</span>, mean <span class="op">=</span> <span class="fl">2</span>, sd <span class="op">=</span> <span class="fl">2</span><span class="op">)</span></span></span>
<span class="r-in"><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">median_qi</span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>             x   x.lower  x.upper        y   y.lower  y.upper .width .point</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1 -0.05057431 -2.012529 1.934141 1.983618 -1.946229 5.947635   0.95 median</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   .interval</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1        qi</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>    x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">1000</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>    group <span class="op">=</span> <span class="st">"a"</span></span></span>
<span class="r-in"><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://rdrr.io/r/base/cbind.html" class="external-link">rbind</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>    x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">1000</span>, mean <span class="op">=</span> <span class="fl">2</span>, sd <span class="op">=</span> <span class="fl">2</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>    group <span class="op">=</span> <span class="st">"b"</span><span class="op">)</span></span></span>
<span class="r-in"><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://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">group</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">median_qi</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">.50</span>, <span class="fl">.80</span>, <span class="fl">.95</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 6 × 7</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   group       x .lower .upper .width .point .interval</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span>   <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span>    </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> a     -<span style="color: #BB0000;">0.032</span><span style="color: #BB0000; text-decoration: underline;">8</span> -<span style="color: #BB0000;">0.707</span>  0.636   0.5  median qi       </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> b      2.06    0.759  3.44    0.5  median qi       </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">3</span> a     -<span style="color: #BB0000;">0.032</span><span style="color: #BB0000; text-decoration: underline;">8</span> -<span style="color: #BB0000;">1.27</span>   1.23    0.8  median qi       </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">4</span> b      2.06   -<span style="color: #BB0000;">0.559</span>  4.48    0.8  median qi       </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">5</span> a     -<span style="color: #BB0000;">0.032</span><span style="color: #BB0000; text-decoration: underline;">8</span> -<span style="color: #BB0000;">2.00</span>   1.84    0.95 median qi       </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">6</span> b      2.06   -<span style="color: #BB0000;">1.75</span>   5.91    0.95 median qi       </span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">multimodal_draws</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>    x <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="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">5000</span>, <span class="fl">0</span>, <span class="fl">1</span><span class="op">)</span>, <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">2500</span>, <span class="fl">4</span>, <span class="fl">1</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span>  <span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">multimodal_draws</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">mode_hdi</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">.66</span>, <span class="fl">.95</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #949494;"># A tibble: 3 × 6</span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>         x .lower .upper .width .point .interval</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>     <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span>  <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span>    </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">1</span> -<span style="color: #BB0000;">0.093</span><span style="color: #BB0000; text-decoration: underline;">8</span>  -<span style="color: #BB0000;">1.30</span>   1.30   0.66 mode   hdi      </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">2</span> -<span style="color: #BB0000;">0.093</span><span style="color: #BB0000; text-decoration: underline;">8</span>   3.50   4.44   0.66 mode   hdi      </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> <span style="color: #BCBCBC;">3</span> -<span style="color: #BB0000;">0.093</span><span style="color: #BB0000; text-decoration: underline;">8</span>  -<span style="color: #BB0000;">1.72</span>   5.50   0.95 mode   hdi      </span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">multimodal_draws</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">x</span>, y <span class="op">=</span> <span class="fl">0</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="stat_halfeye.html">stat_halfeye</a></span><span class="op">(</span>point_interval <span class="op">=</span> <span class="va">mode_hdi</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">.66</span>, <span class="fl">.95</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="point_interval-1.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
</code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
    </nav></aside></div>


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

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

    </footer></div>

  

  

  </body></html>

