CmdStan output file import error [Supplied CSV files were not generated with the same model!]

I ran a Stan model with 2 chains using CmdStan on a Linux machine and the estimations have completed successfully. The generated .csv output files are of equal size. When running the stansummary command on the Linux machine, the two output files (two chains) are processed correctly.

However, when trying to import the output files in R on a Windows computer, I get an error message:

files <- c("output_1.csv", "output_2.csv")
heckman = read_cmdstan_csv(files)
Error: Supplied CSV files were not generated with the same model!

The output files were definitely generated with the same model. However, in my workflow (since Iā€™m using dmtcp for a backup procedure) I am creating a separate model file for each chain. For instance:
Chain 1: 1_heckman_het.stan
Chain 2: 2_heckman_het.stan

So I guess the error is ocurring because the Stan model files have different names, and these names are written to the .csv output files.

Manually renaming the model file name in the .output csv is not a good idea as these files are very large and saving them in Excel changes the .csv structure.

Any ideas how to solve this issue?

Yeah, the model name is one of the fields we expect to be the same. This check is there to avoid any strange issues when trying to merge incompatible CSV files.

You can read them separately and bind draws afterwards:


fit <- cmdstanr_example()

file_1 <- fit$output_files()[1]
file_2 <- fit$output_files()[2]

draws_1 <- read_cmdstan_csv(file_1)
draws_2 <- read_cmdstan_csv(file_2)

draws <- posterior::bind_draws(draws_1$post_warmup_draws, draws_2$post_warmup_draws, along = "chain")
1 Like

That works great, thank you so much.

1 Like