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

<title>Plot samples drawn from the posterior predictive density. — plot_ppredictive • BayesHMM</title>

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

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

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

<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha384-cV+rhyOuRHc9Ub/91rihWcGmMmCXDeksTtCihMupQHSsi8GIIRDG0ThDc3HGQFJ3" crossorigin="anonymous"></script>

<!-- sticky kit -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>

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



<meta property="og:title" content="Plot samples drawn from the posterior predictive density. — plot_ppredictive" />

<meta property="og:description" content="When the observed random variable is multivariate, one individual plot per dimension will be drawn (i.e. the analysis will be carried out marginally). As with all visualizations from this package, colors are fully customizable via a theme. Note that this method is only available for full Bayesian estimation run via Markov-chain Monte Carlo." />
<meta name="twitter:card" content="summary" />



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

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


  </head>

  <body>
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">BayesHMM</a>
        <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.0.1</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">
    <span class="fa fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
    <li>
      <a href="../articles/introduction.html">An Introduction to BayesHMM</a>
    </li>
    <li>
      <a href="../articles/introduction2.html">An Introduction to BayesHMM</a>
    </li>
  </ul>
</li>
      </ul>
      
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/luisdamiano/BayesHMM/">
    <span class="fa fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      
      </header>

<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Plot samples drawn from the posterior predictive density.</h1>
    <small class="dont-index">Source: <a href='https://github.com/luisdamiano/BayesHMM//blob/master/R/plotPredictive.R'><code>R/plotPredictive.R</code></a></small>
    <div class="hidden name"><code>plot_ppredictive.Rd</code></div>
    </div>

    <div class="ref-description">
    
    <p>When the observed random variable is multivariate, one individual plot per dimension will be drawn (i.e. the analysis will be carried out marginally). As with all visualizations from this package, colors are fully customizable via a <code><a href='theme.html'>theme</a></code>. Note that this method is only available for full Bayesian estimation run via Markov-chain Monte Carlo.</p>
    
    </div>

    <pre class="usage"><span class='fu'>plot_ppredictive</span>(<span class='no'>stanfit</span>, <span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>""</span>, <span class='kw'>r</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>subset</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  <span class='kw'>chain</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>fun</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>fun1</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>fun2</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  <span class='kw'>boxplotControl</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>cumulativeControl</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  <span class='kw'>densityControl</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>funControl</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>fun1Control</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  <span class='kw'>fun2Control</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>ksControl</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>klControl</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  <span class='kw'>main</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
    
    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>stanfit</th>
      <td><p>An object returned by either <code><a href='fit.html'>fit</a></code> or <code><a href='draw_samples.html'>draw_samples</a></code>.</p></td>
    </tr>
    <tr>
      <th>type</th>
      <td><p>An optional vector of character strings with the names of the analysis to include in the plot. These may be <em>density</em> (kernel density curves of the observation variable), <em>cumulative</em> (kernel cumulative density curves of the observation variable), <em>boxplot</em> (boxplots of the observation variable), <em>histogram</em> (histogram of the values returned by <em>fun</em>), <em>scatterplot</em> (scatterplot of the values returned by <em>fun1</em> and <em>fun2</em>), <em>kl</em> (histogram of the empirical Kullback-Leibler divergence), <em>ks</em> (histogram of the Kolmogorov-Smirnov statistic). All plots show the actual sample and many draws from the posterior predictive density. Note that more than one type may be plotted at the same time. It allows for partial matching. It defaults to none.</p></td>
    </tr>
    <tr>
      <th>r</th>
      <td><p>An optional numeric vector with the numbers of the dimensions of the observation vector to be plotted. It defaults to plotting all variables.</p></td>
    </tr>
    <tr>
      <th>subset</th>
      <td><p>An optional boolean vector indicating with TRUE which elements of the observation vector should be included in the analysis (some plots may become slow with large datasets). It defaults to NULL, meaning all the sample units.</p></td>
    </tr>
    <tr>
      <th>chain</th>
      <td><p>An optional integer number between 1 and the number of chains M. Only the samples generated by the selected chain are considered. It defaults to the first chain.</p></td>
    </tr>
    <tr>
      <th>fun</th>
      <td><p>An optional function summarizing the whole sample into a single value (e.g. <code>median</code>). This function is applied ot each sample (actual and generated) and the values returned are plotted in the histogram.</p></td>
    </tr>
    <tr>
      <th>fun1</th>
      <td><p>An optional function summarizing the whole sample into a single value (e.g. <code>mean</code>). This function is applied ot each sample (actual and generated) and the values returned are plotted in the horizontal axis of the scatterplot.</p></td>
    </tr>
    <tr>
      <th>fun2</th>
      <td><p>An optional function summarizing the whole sample into a single value (e.g. <code>sd</code>). This function is applied ot each sample (actual and generated) and the values returned are plotted in the vertical axis of the scatterplot.</p></td>
    </tr>
    <tr>
      <th>boxplotControl</th>
      <td><p>Arguments to be passed to <code>boxplot</code> if the argument <em>type</em> includes "boxplot".</p></td>
    </tr>
    <tr>
      <th>cumulativeControl</th>
      <td><p>Arguments to be passed to <code>quantile</code> if the argument <em>type</em> includes "cumulative" (e.g. use `probs` to set a range if the default is innapropiate).</p></td>
    </tr>
    <tr>
      <th>densityControl</th>
      <td><p>Arguments to be passed to <code>density</code> if the argument <em>type</em> includes "density".</p></td>
    </tr>
    <tr>
      <th>funControl</th>
      <td><p>Arguments to be passed to `fun` if the argument <em>type</em> includes "histogram".</p></td>
    </tr>
    <tr>
      <th>fun1Control</th>
      <td><p>Arguments to be passed to `fun1` if the argument <em>type</em> includes "scatterplot".</p></td>
    </tr>
    <tr>
      <th>fun2Control</th>
      <td><p>Arguments to be passed to `fun2` if the argument <em>type</em> includes "scatterplot".</p></td>
    </tr>
    <tr>
      <th>ksControl</th>
      <td><p>Arguments to be passed to <code>ks.test</code> if the argument <em>type</em> includes "ks".</p></td>
    </tr>
    <tr>
      <th>klControl</th>
      <td><p>Arguments to compute the empirical Kullback-Leibler divergence if the argument <em>type</em> includes "kl". It may include two-sized vectors with the lower and upper bounds of the discretization range (`yRange` and `yPredRange`) and the number of bins (`yNBins` and `yPredNBins`).</p></td>
    </tr>
    <tr>
      <th>main</th>
      <td><p>An optional character string with the overall title for the plot.</p></td>
    </tr>
    </table>
    
    <h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>Note</h2>

    <p>If the user was surprised to find the Kolmogorov-Smirnov statistic in a Bayesian software, simply note that we use it as a measure of similarity between two samples from continuous distributions. Data analysis and modeling decissions do not rely on hypothesis testing.</p>
    
    <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>

    <div class='dont-index'><p>Other visualization functions: <code><a href='get_current_theme.html'>get_current_theme</a></code>,
  <code><a href='get_default_theme.html'>get_default_theme</a></code>,
  <code><a href='modify_theme_entry.html'>modify_theme_entry</a></code>,
  <code><a href='plot_series.html'>plot_series</a></code>,
  <code><a href='plot_state_probability.html'>plot_state_probability</a></code>, <code><a href='theme.html'>theme</a></code></p></div>
    

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><span class='co'># NOT RUN {</span>
<span class='fu'>plot_ppredictive</span>(
  <span class='no'>myFit</span>,
  <span class='kw'>type</span> <span class='kw'>=</span> <span class='fu'>c</span>(<span class='st'>"density"</span>, <span class='st'>"cumulative"</span>, <span class='st'>"boxplot"</span>,
           <span class='st'>"histogram"</span>, <span class='st'>"scatterplot"</span>, <span class='st'>"ks"</span>),
  <span class='kw'>fun</span> <span class='kw'>=</span> <span class='no'>mean</span>, <span class='kw'>fun1</span> <span class='kw'>=</span> <span class='no'>mean</span>, <span class='kw'>fun2</span> <span class='kw'>=</span> <span class='no'>sd</span>
)

<span class='fu'>plot_ppredictive</span>(
  <span class='no'>myFit</span>,
  <span class='kw'>type</span> <span class='kw'>=</span> <span class='fu'>c</span>(<span class='st'>"density"</span>, <span class='st'>"cumulative"</span>, <span class='st'>"ks"</span>, <span class='st'>"kl"</span>),
  <span class='kw'>klControl</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>yNBins</span> <span class='kw'>=</span> <span class='fl'>20</span>, <span class='kw'>yPredNBins</span> <span class='kw'>=</span> <span class='fl'>20</span>)
)
<span class='co'># }</span></pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
    <h2>Contents</h2>
    <ul class="nav nav-pills nav-stacked">
      <li><a href="#arguments">Arguments</a></li>
      
      <li><a href="#note">Note</a></li>

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

  </div>
</div>

      <footer>
      <div class="copyright">
  <p>Developed by Luis Damiano, Michael Weylandt, Brian Peterson.</p>
</div>

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

      </footer>
   </div>

  

  </body>
</html>

