title: How to simulate quantities of interest using arm or rstanarm packages in R?
body: <p>I would like to know how to simulate quantities of interest out of a regression model estimated using either the <code>arm</code> or the <code>rstanarm</code> packages in R. I am a newbie in Bayesian methods and R and have been using the <code>Zelig</code> package for some time. I asked a similar question <a href="https://stackoverflow.com/questions/21057548/how-can-one-simulate-quantities-of-interest-from-the-posterior-density-in-mcmcgl">before</a>, but I would like to know if it is possible to simulate those quantities using the posterior distribution estimated by those packages.</p>
  
  <p>In <code>Zelig</code> you can set the values you want for the independent values and it calculates the results for the outcome variable (expected value, probability, etc). An example:</p>
  
  <pre><code># Creating a dataset:
  set.seed(10)
  x &lt;- rnorm(100,20,10)
  z &lt;- rnorm(100,10,5)
  e &lt;- rnorm(100,0,1)
  y &lt;- 2*x+3*z+e
  df &lt;- data.frame(x,z,e,y)
  
  # Loading Zelig
  require(Zelig)
  
  # Model
  m1.zelig &lt;- zelig(y ~ x + z, model="ls", data=df)
  summary(m1.zelig)
  
  # Simulating z = 10
  s1 &lt;- setx(m1.zelig, z = 10)
  simulation &lt;- sim(m1.zelig, x = s1)
  summary(simulation)
  </code></pre>
  
  <p>So <code>Zelig</code> keeps x at its mean (20.56), and simulates the quantity of interest with z = 10. In this case, y is approximately 71.</p>
  
  <p>The same model using <code>arm</code>:</p>
  
  <pre><code># Model
  require(arm)
  m1.arm &lt;- bayesglm(y ~ x + z, data=df)
  summary(m1.arm)
  </code></pre>
  
  <p>And using <code>rstanarm</code>:</p>
  
  <pre><code># Model
  require(rstanarm)
  m1.stan &lt;- stanlm(y ~ x + z, data=df)
  print(m1.stan)
  </code></pre>
  
  <p>Is there any way to simulate z = 10 and x equals to its mean with the posterior distribution estimated by those two packages and get the expected value of y? Thank you very much!</p>