# Rebuild brmsfit from cmdstan CSV files

**URL:** <https://discourse.mc-stan.org/t/rebuild-brmsfit-from-cmdstan-csv-files/24922>\
**Category:** General\
**Tags:** brms\
**Created:** [October 20, 2021, 2:08pm UTC](https://discourse.mc-stan.org/t/rebuild-brmsfit-from-cmdstan-csv-files/24922 "2021-10-20T14:08:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsocolar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jsocolar/32/2486_2.png) [@jsocolar](https://discourse.mc-stan.org/u/jsocolar)\
**Post date:** [October 20, 2021, 2:08pm UTC](https://discourse.mc-stan.org/t/rebuild-brmsfit-from-cmdstan-csv-files/24922/1 "2021-10-20T14:08:47Z")

</div>

I fit a model using `brms` some time ago. Now on my computer I can find the CSV files containing the draws (using the `cmdstanr` backend) but not the associated `brmsfit` object. I still have the script that includes my call to `brms`. Is there a good way to rebuild the `brmsfit` object using the original call and the saved CSVs without refitting?

@paul.buerkner

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [October 20, 2021, 2:47pm UTC](https://discourse.mc-stan.org/t/rebuild-brmsfit-from-cmdstan-csv-files/24922/2 "2021-10-20T14:47:37Z")

</div>

You can try to load the CSV via cmdstanr, creat an empty brmsfit object and then combine the two by copying code over from `brms:::.fit_model_cmdstanr` (see [brms/backends.R at master · paul-buerkner/brms · GitHub](https://github.com/paul-buerkner/brms/blob/master/R/backends.R) for the code). Not the most elegant solution but I don’t have a move convenient idea right now.
