title: How to calculate the predicted probability of negative binomial regression model?
body: <p>I use <code>glm.nb()</code> function in R <code>MASS</code> package to estimate the parameters of a negative binomial regression model. How could I calculate the predicted probability (probability mass function) given new data, which R function can I　use?</p>
  
  <p>My dataset is as follows. y follows negative binomial distribution and x is covariate. And I use <code>glm.nb(y ~ x, data=data)</code> to estimate model parameters. Given new <code>x</code> and <code>y</code>, how can I calculate the predicted probability.</p>
  
  <p>Is there a way to calculate it using Java?</p>
  
  <pre><code>y     x
  
  91    1.000000                                                                                       
  79    1.000000
  
  86    1.000000
  
  32    1.000000
  
  41    1.000000
  
  29    0.890609
  
  44    1.000000
  
  42    1.000000
  
  31    0.734058
  
  35    1.000000
  </code></pre>