<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <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>Estimate a Wordfish Model — wordfish • austin</title>


<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!-- Bootstrap -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>

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

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

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

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

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




<meta property="og:title" content="Estimate a Wordfish Model — wordfish" />
<meta property="og:description" content="Estimates a Wordfish model using Conditional Maximum Likelihood." />




<!-- 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]-->



  </head>

  <body data-spy="scroll" data-target="#toc">
    <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" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <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">austin</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">
    <span class="fas fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../articles/austin.html">Get started</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li>
  <a href="../news/index.html">Changelog</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/conjugateprior/austin/">
    <span class="fab 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>Estimate a Wordfish Model</h1>
    <small class="dont-index">Source: <a href='https://github.com/conjugateprior/austin/blob/master/R/wordfish.R'><code>R/wordfish.R</code></a></small>
    <div class="hidden name"><code>wordfish.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Estimates a Wordfish model using Conditional Maximum Likelihood.</p>
    </div>

    <pre class="usage"><span class='fu'>wordfish</span><span class='op'>(</span>
  <span class='va'>wfm</span>,
  dir <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fl'>1</span>, <span class='fu'><a href='https://rdrr.io/r/base/length.html'>length</a></span><span class='op'>(</span><span class='fu'><a href='docs.html'>docs</a></span><span class='op'>(</span><span class='va'>wfm</span><span class='op'>)</span><span class='op'>)</span><span class='op'>)</span>,
  control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>tol <span class='op'>=</span> <span class='fl'>1e-06</span>, sigma <span class='op'>=</span> <span class='fl'>3</span>, startparams <span class='op'>=</span> <span class='cn'>NULL</span>, conv.check <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"ll"</span>,
    <span class='st'>"cor"</span><span class='op'>)</span><span class='op'>)</span>,
  verbose <span class='op'>=</span> <span class='cn'>FALSE</span>
<span class='op'>)</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>wfm</th>
      <td><p>a word frequency matrix</p></td>
    </tr>
    <tr>
      <th>dir</th>
      <td><p>set global identification by forcing <code>theta[dir[1]]</code> &lt;
<code>theta[dir[2]]</code> (defaults to first and last document)</p></td>
    </tr>
    <tr>
      <th>control</th>
      <td><p>list of estimation options</p></td>
    </tr>
    <tr>
      <th>verbose</th>
      <td><p>produce a running commentary</p></td>
    </tr>
    </table>

    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>An object of class wordfish.  This is a list containing:</p>
<dt>dir</dt><dd><p>global identification of the dimension</p></dd> 
<dt>theta</dt><dd><p>document
positions</p></dd> 
<dt>alpha</dt><dd><p>document fixed effects</p></dd> 
<dt>beta</dt><dd><p>word slope
parameters</p></dd> 
<dt>psi</dt><dd><p>word fixed effects</p></dd> 
<dt>docs</dt><dd><p>names of the documents</p></dd> 
<dt>words</dt><dd><p>names of words</p></dd> 
<dt>sigma</dt><dd><p>regularization parameter for betas in poisson form</p></dd>
<dt>ll</dt><dd><p>final log likelihood</p></dd> 
<dt>se.theta</dt><dd><p>standard errors for document position</p></dd> 
<dt>data</dt><dd><p>the original data</p></dd>

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

    <p>Fits a Wordfish model with document ideal points constrained to mean zero
and unit standard deviation.</p>
<p>The <code>control</code> list specifies options for the estimation process.
<code>conv.check</code> is either 'll' which stops when the difference
in log likelihood between iterations is less than <code>tol</code>, or 'cor'
which stops when one minus the correlation between the <code>theta</code>s
from the current and the previous iterations is less  
than <code>tol</code>. <code>sigma</code> is the standard deviation for the beta 
prior in poisson form. <code>startparams</code> is a list of starting values
(<code>theta</code>, <code>beta</code>, <code>psi</code> and <code>alpha</code>) or a 
previously fitted Wordfish model for the same data.
<code>verbose</code> generates a running commentary during estimation</p>
<p>The model has two equivalent forms: a poisson model with two sets of
document and two sets of word parameters, and a multinomial with two sets of
word parameters and document ideal points.  The first form is used for
estimation, the second is available for alternative summaries, prediction, 
and profile standard error calculations.</p>
<p>The model is regularized by assuming a prior on beta with mean zero and
standard deviation sigma (in poisson form).  If you don't want to
regularize, set beta to a large number.</p>
    <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2>

    <p>Slapin and Proksch (2008) 'A Scaling Model for Estimating
Time-Series Party Positions from Texts.' American Journal of Political
Science 52(3):705-772.</p>
    <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>

    <div class='dont-index'><p><code><a href='plot.wordfish.html'>plot.wordfish</a></code>, <code><a href='summary.wordfish.html'>summary.wordfish</a></code>,
<code><a href='coef.wordfish.html'>coef.wordfish</a></code>, <code><a href='fitted.wordfish.html'>fitted.wordfish</a></code>,
<code><a href='predict.wordfish.html'>predict.wordfish</a></code>, <code><a href='sim.wordfish.html'>sim.wordfish</a></code></p></div>
    <h2 class="hasAnchor" id="author"><a class="anchor" href="#author"></a>Author</h2>

    <p>Will Lowe</p>

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'>
<span class='va'>dd</span> <span class='op'>&lt;-</span> <span class='fu'><a href='sim.wordfish.html'>sim.wordfish</a></span><span class='op'>(</span><span class='op'>)</span>
<span class='va'>wf</span> <span class='op'>&lt;-</span> <span class='fu'>wordfish</span><span class='op'>(</span><span class='va'>dd</span><span class='op'>$</span><span class='va'>Y</span><span class='op'>)</span>
<span class='fu'><a href='https://rdrr.io/r/base/summary.html'>summary</a></span><span class='op'>(</span><span class='va'>wf</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Call:
#&gt; 	wordfish(wfm = dd$Y)
#&gt; 
#&gt; Document Positions:
#&gt;     Estimate Std. Error    Lower    Upper
#&gt; D01 -1.48306    0.11325 -1.70504 -1.26109
#&gt; D02 -1.14317    0.10357 -1.34617 -0.94017
#&gt; D03 -0.85510    0.09751 -1.04621 -0.66399
#&gt; D04 -0.49365    0.09253 -0.67501 -0.31229
#&gt; D05 -0.11242    0.09036 -0.28952  0.06468
#&gt; D06  0.09868    0.09049 -0.07868  0.27604
#&gt; D07  0.49124    0.09328  0.30841  0.67406
#&gt; D08  0.87199    0.09923  0.67750  1.06648
#&gt; D09  1.10840    0.10462  0.90336  1.31345
#&gt; D10  1.51574    0.11714  1.28614  1.74533</div><div class='input'>
</div></pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top">
      <h2 data-toc-skip>Contents</h2>
    </nav>
  </div>
</div>


      <footer>
      <div class="copyright">
  <p>Developed by Will Lowe.</p>
</div>

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

      </footer>
   </div>

  


  </body>
</html>


