<!-- 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>Randomized Response Regression — 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>Randomized Response Regression</h1>
    </div>

    
    <p><code>rrreg</code> is used to conduct multivariate regression analyses of survey
data using randomized response methods.</p>
    

    <pre class="usage"><span class='fu'>rrreg</span>(<span class='no'>formula</span>, <span class='no'>p</span>, <span class='no'>p0</span>, <span class='no'>p1</span>, <span class='no'>q</span>, <span class='no'>design</span>, <span class='no'>data</span>, <span class='kw'>start</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>h</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>group</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>matrixMethod</span> <span class='kw'>=</span> <span class='st'>"efficient"</span>,
<span class='kw'>maxIter</span> <span class='kw'>=</span> <span class='fl'>10000</span>, <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>optim</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>em.converge</span> <span class='kw'>=</span> <span class='fl'>10</span>^(-<span class='fl'>8</span>),
<span class='kw'>glmMaxIter</span> <span class='kw'>=</span> <span class='fl'>10000</span>, <span class='kw'>solve.tolerance</span> <span class='kw'>=</span> <span class='no'>.Machine</span>$<span class='no'>double.eps</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>formula</th>
      <td><p>An object of class "formula": a symbolic description of the
model to be fitted.</p></td>
    </tr>
    <tr>
      <th>p</th>
      <td><p>The probability of receiving the sensitive question (Mirrored
Question Design, Unrelated Question Design); the probability of answering
truthfully (Forced Response Design); the probability of selecting a red card
from the 'yes' stack (Disguised Response Design). For "mirrored" and
"disguised" designs, p cannot equal .5.</p></td>
    </tr>
    <tr>
      <th>p0</th>
      <td><p>The probability of forced 'no' (Forced Response Design).</p></td>
    </tr>
    <tr>
      <th>p1</th>
      <td><p>The probability of forced 'yes' (Forced Response Design).</p></td>
    </tr>
    <tr>
      <th>q</th>
      <td><p>The probability of answering 'yes' to the unrelated question, which
is assumed to be independent of covariates (Unrelated Question Design).</p></td>
    </tr>
    <tr>
      <th>design</th>
      <td><p>One of the four standard designs: "forced-known", "mirrored",
"disguised", or "unrelated-known".</p></td>
    </tr>
    <tr>
      <th>data</th>
      <td><p>A data frame containing the variables in the model.</p></td>
    </tr>
    <tr>
      <th>start</th>
      <td><p>Optional starting values of coefficient estimates for the
Expectation-Maximization (EM) algorithm.</p></td>
    </tr>
    <tr>
      <th>h</th>
      <td><p>Auxiliary data functionality. Optional named numeric vector with 
length equal to number of groups. Names correspond to group labels and 
values correspond to auxiliary moments.</p></td>
    </tr>
    <tr>
      <th>group</th>
      <td><p>Auxiliary data functionality. Optional character vector of 
group labels with length equal to number of observations.</p></td>
    </tr>
    <tr>
      <th>matrixMethod</th>
      <td><p>Auxiliary data functionality. Procedure for estimating 
optimal weighting matrix for generalized method of moments. One of 
"efficient" for two-step feasible and "cue" for continuously updating. 
Default is "efficient". Only relevant if <code>h</code> and <code>group</code> are 
specified.</p></td>
    </tr>
    <tr>
      <th>maxIter</th>
      <td><p>Maximum number of iterations for the Expectation-Maximization
algorithm. The default is <code>10000</code>.</p></td>
    </tr>
    <tr>
      <th>verbose</th>
      <td><p>A logical value indicating whether model diagnostics counting
the number of EM iterations are printed out.  The default is <code>FALSE</code>.</p></td>
    </tr>
    <tr>
      <th>optim</th>
      <td><p>A logical value indicating whether to use the quasi-Newton
"BFGS" method to calculate the variance-covariance matrix and standard
errors. The default is <code>FALSE</code>.</p></td>
    </tr>
    <tr>
      <th>em.converge</th>
      <td><p>A value specifying the satisfactory degree of convergence
under the EM algorithm. The default is <code>10^(-8)</code>.</p></td>
    </tr>
    <tr>
      <th>glmMaxIter</th>
      <td><p>A value specifying the maximum number of iterations to run
the EM algorithm. The default is <code>10000</code>.</p></td>
    </tr>
    <tr>
      <th>solve.tolerance</th>
      <td><p>When standard errors are calculated, this option
specifies the tolerance of the matrix inversion operation solve.</p></td>
    </tr>
    </table>
    
    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p><code>rrreg</code> returns an object of class "rrreg".  The function
<code>summary</code> is used to obtain a table of the results.  The object
<code>rrreg</code> is a list that contains the following components (the inclusion
of some components such as the design parameters are dependent upon the
design used):</p>
<dt>est</dt><dd><p>Point estimates for the effects of covariates on the randomized
response item.</p></dd> <dt>vcov</dt><dd><p>Variance-covariance matrix for the effects of
covariates on the randomized response item.</p></dd> <dt>se</dt><dd><p>Standard errors for
estimates of the effects of covariates on the randomized response item.</p></dd>
<dt>data</dt><dd><p>The <code>data</code> argument.</p></dd> <dt>coef.names</dt><dd><p>Variable names as
defined in the data frame.</p></dd> <dt>x</dt><dd><p>The model matrix of covariates.</p></dd>
<dt>y</dt><dd><p>The randomized response vector.</p></dd> <dt>design</dt><dd><p>Call of standard
design used: "forced-known", "mirrored", "disguised", or "unrelated-known".</p></dd>
<dt>p</dt><dd><p>The <code>p</code> argument.</p></dd> <dt>p0</dt><dd><p>The <code>p0</code> argument.</p></dd>
<dt>p1</dt><dd><p>The <code>p1</code> argument.</p></dd> <dt>q</dt><dd><p>The <code>q</code> argument.</p></dd>
<dt>call</dt><dd><p>The matched call.</p></dd>

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

    <p>This function allows users to perform multivariate regression analysis on
data from the randomized response technique.  Four standard designs are
accepted by this function: mirrored question, forced response, disguised
response, and unrelated question. The method implemented by this function is
the Maximum Likelihood (ML) estimation for the Expectation-Maximization (EM)
algorithm.</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." Working Paper. 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='predict.rrreg.html'>predict.rrreg</a></code> for predicted probabilities.</p>
    

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'>
<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 whether </span>
<span class='co'>## 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'>rrreg</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='fu'>summary</span>(<span class='no'>rr.q1.reg.obj</span>)</div><div class='output co'>#&gt; 
#&gt; Randomized Response Technique Regression 
#&gt; 
#&gt; Call: rrreg(formula = rr.q1 ~ cov.asset.index + cov.married + I(cov.age/10) + 
#&gt;     I((cov.age/10)^2) + cov.education + cov.female, p = p, p0 = p0, 
#&gt;     p1 = p1, design = "forced-known", data = nigeria)
#&gt; 
#&gt;                       Est.    S.E.
#&gt; (Intercept)       -0.34017 0.50856
#&gt; cov.asset.index    0.07896 0.04136
#&gt; cov.married       -0.26743 0.25451
#&gt; I(cov.age/10)     -0.35283 0.26423
#&gt; I((cov.age/10)^2)  0.04099 0.02603
#&gt; cov.education     -0.00691 0.04558
#&gt; cov.female        -0.55439 0.16244
#&gt; 
#&gt; Randomized response forced design with p = 0.67, p0 = 0.17, and p1 = 0.17.</div><div class='input'>
## Replicates Table 3 in Blair, Imai, and Zhou (2014)

</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>
