Problem Loading cmdstan VB Draws into R for Analysis

I’m using rstan 2.21.2 and cmdstan 2.24. I run a Variational Bayes estimator in cmdstan and then proceed to load the posterior draws into R using

# R code
x = read_stan_csv("posterior.csv") 
show(x)

At load I get the error:

Warning message:
In parse_stancsv_comments(comments) : line with “Elapsed Time” not found

At show(x) I get the error:

Error in dim(s1) <- c(length(tidx), length(m) + 5L) : dims [product 2460] do not match the length of object [2214]

I’m not sure if read_stan_csv() ever worked with the results from variational inference. @bgoodri do you know if this was supposed to work? If it is I can investigate and debug, if it’s not then we should add an informative error message about that instead of having it just fail with this weird error.

Either way, @npretnar we have a new package CmdStanR for running CmdStan from R and that works with variational inference and shouldn’t have any trouble reading the CmdStan results back into R:

So you can run CmdStan from your R session that way, but if you’d rather run CmdStan from the command line directly you can still use CmdStanR’s read_cmdstan_csv() function after: