I can't get summary of my model

Hi, I recently changed my model from rstan to cmdstanr, and I’ve run my model and it was successful seemingly.
Before I run my model, I did run small size of my test model, and I could get the result of mcmc sampling

> well
   variable   mean median   sd  mad     q5    q95 rhat ess_bulk ess_tail
 lp__       -22.79 -22.47 2.20 1.99 -26.78 -19.88 1.02      344      407
 r1f          5.69   5.09 3.47 3.52   1.06  12.02 1.01      917      525
 r1r          4.46   3.81 3.31 3.24   0.30  10.89 1.01      627      451
 r2f          4.26   3.66 3.14 3.16   0.25   9.77 1.01      385      201
 r3f          4.97   4.41 3.02 3.12   0.93  10.55 1.01      810      423
 r4f          5.74   5.26 3.25 3.14   1.26  11.69 1.00      689      451
 r5f          6.94   6.61 3.24 3.18   2.20  12.78 1.01      697      396
 r6f          4.91   4.40 2.97 3.01   0.98  10.58 1.01      743      440

However, with my large size of test model, I can’t get summary of my result. I get error message below.

fit_cl
Error in read_cmdstan_csv(files = self$output_files(include_failed = FALSE),  : 
  Assertion on 'files' failed: File does not exist: '/tmp/RtmphBvYXd/test-202207270907-1-7904b7.csv'.

I doubt with my result that it didn’t save the csv file so I ran below code, and it seems it have right csv file but it can’t read this.

fit_cl$output_files()
[1] "/tmp/RtmphBvYXd/test-202207270907-1-7904b7.csv"
[2] "/tmp/RtmphBvYXd/test-202207270907-2-7904b7.csv"
[3] "/tmp/RtmphBvYXd/test-202207270907-3-7904b7.csv"
[4] "/tmp/RtmphBvYXd/test-202207270907-4-7904b7.csv"

What make this problem and how can I fix this??

The fit$output_files() gives the path of the CSV files, but doesn’t check that they exist. I’d bet you’ve started a new R session & the relevant /tmp directory has been cleaned up, or the model was fit on a different computer.

You can choose a different location by fitting the model using the output_dir & output_basename arguments for $sample(...) Saving them outside the /tmp directory would allow them to persist across sessions.

If you have already saved a .draws <- fit$draws() object anywhere, you could get the summary using posterior::summarise_draws(.draws) instead. This is what fit$summary() does under the hood.

2 Likes

Thanks Stuart! I guess my R session was once closed after sampling was done.
Now I re-run the model and save the object after the sampling.(And It works!)
Thanks a lot!

1 Like