How do we find the different values for each iteration in rstanarm?

107 Views Asked by At

I did write a basic GLM code in rstanarm. When I execute the following code it is giving the mean of the predictor variables of all the iterations done:

  summary(TestGLM) 
  print(TestGLM)  

I wanted the value of the predictor variables at each and every iteration for my solution. Can anyone please help me solve this problem?

1

There are 1 best solutions below

0
On BEST ANSWER

You can extract the draws for each of the coefficients as follows:

require(rstanarm)

TestGLM <- stan_glm(mpg ~ wt, data = mtcars)
draws <- as.data.frame(TestGLM)
print(colnames(draws))
str(draws)

# See http://mc-stan.org/rstanarm/reference/as.matrix.stanreg.html