<!-- 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>Predicted Probabilities for Randomized Response Regression — predict.rrreg • rr</title>

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

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

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


<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../jquery.sticky-kit.min.js"></script>
<script src="../pkgdown.js"></script>
  
  
<!-- mathjax -->
<script src='https://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>
      <a class="navbar-brand" href="../index.html">rr</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../reference/">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Packages
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
    <li>
      <a href="http://endorse.sensitivequestions.org">Endorsement experiments</a>
    </li>
    <li>
      <a href="http://list.sensitivequestions.org">List experiments</a>
    </li>
    <li>
      <a href="http://rr.sensitivequestions.org">Randomized response technique</a>
    </li>
  </ul>
</li>
<li>
  <a href="http://sensitivequestions.org">Sensitive Questions home</a>
</li>
      </ul>
      
      <ul class="nav navbar-nav navbar-right">
        
      </ul>
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      
      </header>

      <div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Predicted Probabilities for Randomized Response Regression</h1>
    </div>

    
    <p><code>predict.rrreg</code> is used to generate predicted probabilities from a
multivariate regression object of survey data using randomized response
methods.</p>
    

    <pre class="usage"><span class='co'># S3 method for rrreg</span>
<span class='fu'>predict</span>(<span class='no'>object</span>, <span class='kw'>given.y</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>.05</span>, <span class='kw'>n.sims</span> <span class='kw'>=</span>
<span class='fl'>1000</span>, <span class='kw'>avg</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>newdata</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>quasi.bayes</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>keep.draws</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='no'>...</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>object</th>
      <td><p>An object of class "rrreg" generated by the <code><a href='rrreg.html'>rrreg()</a></code>
function.</p></td>
    </tr>
    <tr>
      <th>given.y</th>
      <td><p>Indicator of whether to use "y" the response vector to
calculate the posterior prediction of latent responses. Default is
<code>FALSE</code>, which simply generates fitted values using the logistic
regression.</p></td>
    </tr>
    <tr>
      <th>alpha</th>
      <td><p>Confidence level for the hypothesis test to generate upper and
lower confidence intervals. Default is <code> .05</code>.</p></td>
    </tr>
    <tr>
      <th>n.sims</th>
      <td><p>Number of sampled draws for quasi-bayesian predicted
probability estimation. Default is <code>1000</code>.</p></td>
    </tr>
    <tr>
      <th>avg</th>
      <td><p>Whether to output the mean of the predicted probabilities and
uncertainty estimates. Default is <code>FALSE</code>.</p></td>
    </tr>
    <tr>
      <th>newdata</th>
      <td><p>Optional new data frame of covariates provided by the user.
Otherwise, the original data frame from the "rreg" object is used.</p></td>
    </tr>
    <tr>
      <th>quasi.bayes</th>
      <td><p>Option to use Monte Carlo simulations to generate
uncertainty estimates for predicted probabilities. Default is <code>FALSE</code>.</p></td>
    </tr>
    <tr>
      <th>keep.draws</th>
      <td><p>Option to return the Monte Carlos draws of the quantity of
interest, for use in calculating differences for example.</p></td>
    </tr>
    <tr>
      <th>...</th>
      <td><p>Further arguments to be passed to <code>predict.rrreg()</code> command.</p></td>
    </tr>
    </table>
    
    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p><code>predict.rrreg</code> returns predicted probabilities either for each
observation in the data frame or the average over all observations. The
output is a list that contains the following components:</p>
<dt>est</dt><dd><p>Predicted probabilities for the randomized response item
generated either using fitted values, posterior predictions, or
quasi-Bayesian simulations. If <code>avg</code> is set to <code>TRUE</code>, the output
will only include the mean estimate.</p></dd> <dt>se</dt><dd><p>Standard errors for the
predicted probabilities of the randomized response item generated using
Monte Carlo simulations. If <code>quasi.bayes</code> is set to <code>FALSE</code>, no
standard errors will be outputted.</p></dd> <dt>ci.lower</dt><dd><p>Estimates for the lower
confidence interval. If <code>quasi.bayes</code> is set to <code>FALSE</code>, no
confidence interval estimate will be outputted.</p></dd> <dt>ci.upper</dt><dd><p>Estimates
for the upper confidence interval. If <code>quasi.bayes</code> is set to
<code>FALSE</code>, no confidence interval estimate will be outputted.</p></dd>
<dt>qoi.draws</dt><dd><p>Monte Carlos draws of the quantity of interest, returned
only if <code>keep.draws</code> is set to <code>TRUE</code>.</p></dd>

    
    <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>

    <p>This function allows users to generate predicted probabilities for the
randomized response item given an object of class "rrreg" from the
<code><a href='rrreg.html'>rrreg()</a></code> function. Four standard designs are accepted by this
function: mirrored question, forced response, disguised response, and
unrelated question. The design, already specified in the "rrreg" object, is
then directly inputted into this function.</p>
    
    <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2>

    <p>Blair, Graeme, Kosuke Imai and Yang-Yang Zhou. (2014) "Design
and Analysis of the Randomized Response Technique."  <em>Working Paper.</em>
Available at <a href='http://imai.princeton.edu/research/randresp.html'>http://imai.princeton.edu/research/randresp.html</a>.</p>
    
    <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>

    <p><code><a href='rrreg.html'>rrreg</a></code> to conduct multivariate regression analyses in
order to generate predicted probabilities for the randomized response item.</p>
    

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'>
</div><span class='co'># NOT RUN {</span>
<span class='fu'>data</span>(<span class='no'>nigeria</span>)

<span class='fu'>set.seed</span>(<span class='fl'>1</span>)

<span class='co'>## Define design parameters</span>
<span class='no'>p</span> <span class='kw'>&lt;-</span> <span class='fl'>2</span>/<span class='fl'>3</span>  <span class='co'># probability of answering honestly in Forced Response Design</span>
<span class='no'>p1</span> <span class='kw'>&lt;-</span> <span class='fl'>1</span>/<span class='fl'>6</span> <span class='co'># probability of forced 'yes'</span>
<span class='no'>p0</span> <span class='kw'>&lt;-</span> <span class='fl'>1</span>/<span class='fl'>6</span> <span class='co'># probability of forced 'no'</span>

<span class='co'>## Fit linear regression on the randomized response item of </span>
<span class='co'>## whether citizen respondents had direct social contacts to armed groups</span>

<span class='no'>rr.q1.reg.obj</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='rrreg.html'>rrreg</a></span>(<span class='no'>rr.q1</span> ~ <span class='no'>cov.asset.index</span> + <span class='no'>cov.married</span> + <span class='fu'>I</span>(<span class='no'>cov.age</span>/<span class='fl'>10</span>) +
                      <span class='fu'>I</span>((<span class='no'>cov.age</span>/<span class='fl'>10</span>)^<span class='fl'>2</span>) + <span class='no'>cov.education</span> + <span class='no'>cov.female</span>,
                      <span class='kw'>data</span> <span class='kw'>=</span> <span class='no'>nigeria</span>, <span class='kw'>p</span> <span class='kw'>=</span> <span class='no'>p</span>, <span class='kw'>p1</span> <span class='kw'>=</span> <span class='no'>p1</span>, <span class='kw'>p0</span> <span class='kw'>=</span> <span class='no'>p0</span>,
                      <span class='kw'>design</span> <span class='kw'>=</span> <span class='st'>"forced-known"</span>)

<span class='co'>## Generate the mean predicted probability of having social contacts to </span>
<span class='co'>## armed groups across respondents using quasi-Bayesian simulations. </span>

<span class='no'>rr.q1.reg.pred</span> <span class='kw'>&lt;-</span> <span class='fu'>predict</span>(<span class='no'>rr.q1.reg.obj</span>, <span class='kw'>given.y</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
                                <span class='kw'>avg</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>quasi.bayes</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
                                <span class='kw'>n.sims</span> <span class='kw'>=</span> <span class='fl'>10000</span>)

<span class='co'>## Replicates Table 3 in Blair, Imai, and Zhou (2014)</span>
<span class='co'># }</span><div class='input'>
</div></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="#value">Value</a></li>

      <li><a href="#details">Details</a></li>

      <li><a href="#references">References</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 Graeme Blair, Yang-Yang Zhou, Kosuke Imai.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p>
</div>

      </footer>
   </div>

  </body>
</html>
