Feature: as_cmdstan_mcmc doesn't seem to work

I’m trying to use the feature as_cmdstan_mcmc to recreate a fit object, for which I saved the csv files. (I tried saving it as an RDS file but R’s memory ran out.)

I would like to reconstruct the fit object, but as_cmdstan_mcmc() is not found as a function. Note that the same error appears in the example vignette: Read CmdStan CSV files into R — read_cmdstan_csv • cmdstanr

Does cmdstanr::as_cmdstan_fit() work?

Yeah, looks like the docs are just wrong; the _mcmc version must be an outdated name.

Made a PR: replace as_cmdstan_mcmc with as_cmdstan_fit in csv.R examples section by mike-lawrence · Pull Request #487 · stan-dev/cmdstanr · GitHub

Yes, this works. I did have to sort through some memory issues with Rstudio but this seems independent of cmdstanr.

I don’t understand why it takes so long (and also so much memory) to read the csv file into a fit file, with as_cmdstan_fit, when just reading the csv file doesn’t seem to cause any issue.

Can you make an issue for your RAM observations?

The issue comes from combining multiple chains in a R object. By default we combine them to R arrays which is a bit memory intensive (due to how R works mostly).

When dealing with large number of parameters use:

fit <- as_cmdstan_fit(files, format = "draws_list")
3 Likes

Yes, I’ll try and write something later today, though I think @rok_cesnovar 's comment is spot on.