<!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 grouped data frame into a set of point and
interval summaries using a curve boxplot-inspired approach."><title>Curvewise point and interval summaries for tidy data frames of draws from distributions — curve_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="Curvewise point and interval summaries for tidy data frames of draws from distributions — curve_interval"><meta property="og:description" content="Translates draws from distributions in a grouped data frame into a set of point and
interval summaries using a curve boxplot-inspired approach."><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>Curvewise 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/curve_interval.R" class="external-link"><code>R/curve_interval.R</code></a></small>
      <div class="d-none name"><code>curve_interval.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Translates draws from distributions in a grouped data frame into a set of point and
interval summaries using a curve boxplot-inspired approach.</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">curve_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .along <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.5</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  .interval <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">"mhd"</span>, <span class="st">"mbd"</span>, <span class="st">"bd"</span>, <span class="st">"bd-mbd"</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for matrix</span></span>
<span><span class="fu">curve_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .along <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.5</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  .interval <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">"mhd"</span>, <span class="st">"mbd"</span>, <span class="st">"bd"</span>, <span class="st">"bd-mbd"</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for rvar</span></span>
<span><span class="fu">curve_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .along <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.5</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  .interval <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">"mhd"</span>, <span class="st">"mbd"</span>, <span class="st">"bd"</span>, <span class="st">"bd-mbd"</span><span class="op">)</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="co"># S3 method for data.frame</span></span>
<span><span class="fu">curve_interval</span><span class="op">(</span></span>
<span>  <span class="va">.data</span>,</span>
<span>  <span class="va">...</span>,</span>
<span>  .along <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  .width <span class="op">=</span> <span class="fl">0.5</span>,</span>
<span>  na.rm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  .interval <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">"mhd"</span>, <span class="st">"mbd"</span>, <span class="st">"bd"</span>, <span class="st">"bd-mbd"</span><span class="op">)</span>,</span>
<span>  .simple_names <span class="op">=</span> <span class="cn">TRUE</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="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>One of:</p><ul><li><p>A 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></li>
<li><p>A <a href="https://mc-stan.org/posterior/reference/rvar.html" class="external-link">posterior::rvar</a> vector.</p></li>
<li><p>A matrix; in which case the first dimension should be draws and the second
dimension values of the curve.</p></li>
</ul></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.
This can be numeric columns, list columns containing numeric vectors, or
<code><a href="https://mc-stan.org/posterior/reference/rvar.html" class="external-link">posterior::rvar()</a></code>s.</p></dd>


<dt>.along</dt>
<dd><p>Which columns are the input values to the function describing the curve (e.g., the "x"
values). Supports <a href="https://tidyselect.r-lib.org/reference/language.html" class="external-link">tidyselect</a> syntax. Intervals are calculated jointly with
respect to these variables, conditional on all other grouping variables in the data frame. The default
(<code>NULL</code>) causes <code>curve_interval()</code> to use all grouping variables in the input data frame as the value
for <code>.along</code>, which will generate the most conservative intervals. However, if you want to calculate
intervals for some function <code>y = f(x)</code> conditional on some other variable(s) (say, conditional on a
factor <code>g</code>), you would group by <code>g</code>, then use <code>.along = x</code> to calculate intervals jointly over <code>x</code>
conditional on <code>g</code>. To avoid selecting any variables as input values to the function describing the
curve, use <code><a href="https://rdrr.io/r/base/character.html" class="external-link">character()</a></code>; this will produce conditional intervals only (the result in this case should
be very similar to <code><a href="point_interval.html">median_qi()</a></code>). Currently only supported when <code>.data</code> is a data frame.</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>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), the presence of <code>NA</code> values in the columns to be summarized will generally
result in an error. If <code>TRUE</code>, <code>NA</code> values will be removed in the calculation of intervals so long
as <code>.interval</code> is <code>"mhd"</code>; other methods do not currently support <code>na.rm</code>. Be cautious in applying
this parameter: in general, it is unclear what a joint interval should be when any of the values
are missing!</p></dd>


<dt>.interval</dt>
<dd><p>The method used to calculate the intervals. Currently, all methods rank the curves
using some measure of <em>data depth</em>, then create envelopes containing the <code>.width</code>% "deepest" curves.
Available methods are:</p><ul><li><p><code>"mhd"</code>: mean halfspace depth (Fraiman and Muniz 2001).</p></li>
<li><p><code>"mbd"</code>: modified band depth (Sun and Genton 2011): calls <code><a href="https://rdrr.io/pkg/fda/man/fbplot.html" class="external-link">fda::fbplot()</a></code> with <code>method = "MBD"</code>.</p></li>
<li><p><code>"bd"</code>: band depth (Sun and Genton 2011): calls <code><a href="https://rdrr.io/pkg/fda/man/fbplot.html" class="external-link">fda::fbplot()</a></code> with <code>method = "BD2"</code>.</p></li>
<li><p><code>"bd-mbd"</code>: band depth, breaking ties with modified band depth (Sun and Genton 2011): calls
<code><a href="https://rdrr.io/pkg/fda/man/fbplot.html" class="external-link">fda::fbplot()</a></code> with <code>method = "Both"</code>.</p></li>
</ul></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. 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>.</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>

</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>Intervals are calculated by ranking the curves using some measure of <em>data depth</em>, then
using binary search to find a cutoff <code>k</code> such that an envelope containing the <code>k</code>% "deepest"
curves also contains <code>.width</code>% of the curves, for each value of <code>.width</code> (note that <code>k</code>
and <code>.width</code> are not necessarily the same). This is in contrast to most functional boxplot
or curve boxplot approaches, which tend to simply take the <code>.width</code>% deepest curves, and
are generally quite conservative (i.e. they may contain more than <code>.width</code>% of the curves).</p>
<p>See Mirzargar <em>et al.</em> (2014) or Juul <em>et al.</em> (2020) for an accessible introduction
to data depth and curve boxplots / functional boxplots.</p>
    </div>
    <div class="section level2">
    <h2 id="references">References<a class="anchor" aria-label="anchor" href="#references"></a></h2>
    <p>Fraiman, Ricardo and Graciela Muniz. (2001).
"Trimmed means for functional data".
<em>Test</em> 10: 419–440.
<a href="https://doi.org/10.1007/BF02595706" class="external-link">doi:10.1007/BF02595706</a>
.</p>
<p>Sun, Ying and Marc G. Genton. (2011).
"Functional Boxplots".
<em>Journal of Computational and Graphical Statistics</em>, 20(2): 316-334.
<a href="https://doi.org/10.1198/jcgs.2011.09224" class="external-link">doi:10.1198/jcgs.2011.09224</a></p>
<p>Mirzargar, Mahsa, Ross T Whitaker, and Robert M Kirby. (2014).
"Curve Boxplot: Generalization of Boxplot for Ensembles of Curves".
<em>IEEE Transactions on Visualization and Computer Graphics</em>. 20(12): 2654-2663.
<a href="https://doi.org/10.1109/TVCG.2014.2346455" class="external-link">doi:10.1109/TVCG.2014.2346455</a></p>
<p>Juul Jonas, Kaare Græsbøll, Lasse Engbo Christiansen, and Sune Lehmann. (2020).
"Fixed-time descriptive statistics underestimate extremes of epidemic curve ensembles".
<em>arXiv e-print</em>.
<a href="https://arxiv.org/abs/2007.05035" class="external-link">arXiv:2007.05035</a></p>
    </div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p><code><a href="point_interval.html">point_interval()</a></code> for pointwise intervals. See <code><a href="../articles/lineribbon.html">vignette("lineribbon")</a></code> for more examples
and discussion of the differences between pointwise and curvewise intervals.</p></div>
    </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="co"># generate a set of curves</span></span></span>
<span class="r-in"><span><span class="va">k</span> <span class="op">=</span> <span class="fl">11</span> <span class="co"># number of curves</span></span></span>
<span class="r-in"><span><span class="va">n</span> <span class="op">=</span> <span class="fl">201</span></span></span>
<span class="r-in"><span><span class="va">df</span> <span class="op">=</span> <span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html" class="external-link">tibble</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>    .draw <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="va">k</span>, <span class="va">n</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>    mean <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/seq.html" class="external-link">seq</a></span><span class="op">(</span><span class="op">-</span><span class="fl">5</span>,<span class="fl">5</span>, length.out <span class="op">=</span> <span class="va">k</span><span class="op">)</span>, <span class="va">n</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/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/seq.html" class="external-link">seq</a></span><span class="op">(</span><span class="op">-</span><span class="fl">15</span>,<span class="fl">15</span>,length.out <span class="op">=</span> <span class="va">n</span><span class="op">)</span>, each <span class="op">=</span> <span class="va">k</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">dnorm</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">mean</span>, <span class="fl">3</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="co"># see pointwise intervals...</span></span></span>
<span class="r-in"><span><span class="va">df</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">x</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="point_interval.html">median_qi</a></span><span class="op">(</span><span class="va">y</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">.5</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"><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="va">y</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="geom_lineribbon.html">geom_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>ymin <span class="op">=</span> <span class="va">.lower</span>, ymax <span class="op">=</span> <span class="va">.upper</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>group <span class="op">=</span> <span class="va">.draw</span><span class="op">)</span>, alpha<span class="op">=</span><span class="fl">0.15</span>, data <span class="op">=</span> <span class="va">df</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><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/labs.html" class="external-link">ggtitle</a></span><span class="op">(</span><span class="st">"50% pointwise intervals with point_interval()"</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="theme_ggdist.html">theme_ggdist</a></span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="curve_interval-1.png" alt="" width="700" height="433"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># ... compare them to curvewise intervals</span></span></span>
<span class="r-in"><span><span class="va">df</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">x</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">curve_interval</span><span class="op">(</span><span class="va">y</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">.5</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"><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="va">y</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="geom_lineribbon.html">geom_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>ymin <span class="op">=</span> <span class="va">.lower</span>, ymax <span class="op">=</span> <span class="va">.upper</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>group <span class="op">=</span> <span class="va">.draw</span><span class="op">)</span>, alpha<span class="op">=</span><span class="fl">0.15</span>, data <span class="op">=</span> <span class="va">df</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><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/labs.html" class="external-link">ggtitle</a></span><span class="op">(</span><span class="st">"50% curvewise intervals with curve_interval()"</span><span class="op">)</span> <span class="op">+</span></span></span>
<span class="r-in"><span>  <span class="fu"><a href="theme_ggdist.html">theme_ggdist</a></span><span class="op">(</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="curve_interval-2.png" alt="" width="700" height="433"></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>

