0
votes

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
Took a quick look in the manual. Did you have any luck with prior_summary and summary.stanreg? If not I guess you can str(TestGLM) and poke around.Eric Fail
@EricFail Thanks for your response. I can get the values using str(TestGLM) and also found ggmcmc(TestGLM) for getting the values. I was wondering what does posterior_predict(TestGLM) does as it also giving me the values. Please let me know if you have any idea regarding posterior_predict()Alex_P
Have a look at page 23 in the rstanarm manual I linked above.Eric Fail
@EricFail Thanks!Alex_P

1 Answers

2
votes

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