Extracting parameters estimates for each iteration


Hi all,

Is it possible to save values of the estimated paramters for the last iteration such that I can use them as intitail values for the next sampling.

This is because, l’m fitting a complex IRT model with large sample size and test length, as well as large number of iterations before reaching convergence. However, the sampling is halted due to running out of memory. So, my idea is to run few number of iterations, then taking the last values of the estimates and use them as initial values for another sampling with few number of iteration.

Overall, it is possible to extract paprameter values for each iteration and save them as a matrix for example?




There are ways to save the posterior draws of the parameters in Stan. Could you share a few more details of the type of Stan you are using and the version of that tool? Are you using RStan, pystan, cmdstan etc? And kindly provide more details on the sample size you are working with so that the recommendation provided would hopefully work for you with fewer trials.

For example, if you are using RStan, you can use a method called extract on a stanfit object.
Refer to page 13 of this RStan document at CRAN repository



Dear sree_d,

Thank you very much for your reply.

I’m using RStan. The sample size is 1000 and the test length is 30 items.
Specifically, I’m trying to, simultaneously, fit: three-class mixture 2PL IRT model, two-class mixture 2PL IRT model, and one-class 2PL IRT model to data genertated from the conventional (one-class) 2PL IRT model. Till now, the number of warmup iteration is 3000 and the number of sampling iteration is 5000 with three chains. However, convergence can not be reached with these relatively few number of iterations, especially for the incorrect models. On the other hand, increasing number of iterations above 8000 in total causes memory issue (i.e., running out of memory) and consequenlty the estimation process is halted even though I’m using a computing cluster to run the code.

Ok, I’m going to try the ‘extract’ statement.

Thanks again,


Hi Rehab

You are welcome. I’m also learning Bayesian modeling so being able to read what others are doing is helping me learn a little. I have not done any work in IRT space but I did come across an article at Researchgate.net on Using Stan for Bayesian IRT. Hope this might be of help to you.

Also here is a suggestion you might try that had worked for me. Since you want to work with sensible priors why don’t you first test a model with a subset of your data randomly selected? Since your original data has 30,000 records (assuming all records are usable based on 1000 responders) use a sample size of 50 or 100 so your subset will have between 1,500 to 3,000 records.

I had to analyze a choice dataset that had 1200 responders each with 24 responses. I worked with a 100 (2,400 records) to start with to estimate parameters. I excluded these 100 from the next selection and chose a new 100 and repeated to check the range of my parameters and accordingly I set my priors on beta and variance parameters. You can even do this 50x30 to start with. Just my two cents.



Hi @Rehab

Here is the Bayesian IRT paper with Stan

UsingStanforBayesianIRT.pdf (2.9 MB)

Another introductory link on Bayesian IRT and Stan I had saved


Daniel Furr wrote a series of thorough case studies in IRT modeling in Stan, all of which can be found at https://mc-stan.org/users/documentation/case-studies.html (either search for “Daniel Furr” or scroll down to the “Volume 3” section).


It’s a good idea sree_d. I’ll give it a try.


betanalpha ans sree_d

I appreciate your help. The links you provided are very helpful indeed.