# \#cmdstanpy

**URL:** https://discourse.mc-stan.org/tag/cmdstanpy/64.md?match_all_tags=true&page=2&tags%5B%5D=cmdstanpy

[Latest](https://discourse.mc-stan.org/latest.md) · [Categories](https://discourse.mc-stan.org/categories.md) · [Tags](https://discourse.mc-stan.org/tags.md)

**Page:** 3

---

## [Dumping data in json file by cmdstanpy does not see a variable to be declared](https://discourse.mc-stan.org/t/dumping-data-in-json-file-by-cmdstanpy-does-not-see-a-variable-to-be-declared/26668)

<div class="topic-metadata">

**Author:** [@aakhmetz](https://discourse.mc-stan.org/u/aakhmetz)\
**Replies:** 2\
**Last updated:** [March 10, 2022, 10:20am UTC](https://discourse.mc-stan.org/t/dumping-data-in-json-file-by-cmdstanpy-does-not-see-a-variable-to-be-declared/26668 "2022-03-10T10:20:21Z")

</div>

Dear all, When I dump the data to the file, it says that the variable N does not exist: stan\_data = dict({ 'N': df\_.shape\[0\], 'onset\_day': np.array(df\_.發病日期.values, dtype='int'), 'report\_day': np.array(df\_.…

---

## [Statistical Rethinking with CmdStanPy and plotnine](https://discourse.mc-stan.org/t/statistical-rethinking-with-cmdstanpy-and-plotnine/25840)

<div class="topic-metadata">

**Author:** [@asuagar](https://discourse.mc-stan.org/u/asuagar)\
**Replies:** 1\
**Last updated:** [January 1, 2022, 5:42pm UTC](https://discourse.mc-stan.org/t/statistical-rethinking-with-cmdstanpy-and-plotnine/25840 "2022-01-01T17:42:06Z")

</div>

Hi, I have been working on the Statistical Rethinking online lessons using CmdStanPy and plotnine. The link to the notebooks is at the end of the post. At the moment, there are eight weeks finished. The two last ones, c…

---

## [Cholesky Factorisation Error on Hierarcichal Regression Model (Reproduce PyMC Model in Stan)](https://discourse.mc-stan.org/t/cholesky-factorisation-error-on-hierarcichal-regression-model-reproduce-pymc-model-in-stan/25772)

<div class="topic-metadata">

**Author:** [@tommylees112](https://discourse.mc-stan.org/u/tommylees112)\
**Replies:** 1\
**Last updated:** [December 22, 2021, 12:50am UTC](https://discourse.mc-stan.org/t/cholesky-factorisation-error-on-hierarcichal-regression-model-reproduce-pymc-model-in-stan/25772 "2021-12-22T00:50:13Z")

</div>

I am trying to reproduce this model from PyMC into Stan (from this publication): with pm.Model(coords=coords) as new\_hbm: if sampler == 'MCMC': x\_input = pm.Data('x\_input1', X\_data) y…

---

## [Fitting parameters of a simple process model (optimisation & uncertainty)](https://discourse.mc-stan.org/t/fitting-parameters-of-a-simple-process-model-optimisation-uncertainty/16349)

<div class="topic-metadata">

**Author:** [@tommylees112](https://discourse.mc-stan.org/u/tommylees112)\
**Replies:** 13\
**Last updated:** [December 21, 2021, 8:35pm UTC](https://discourse.mc-stan.org/t/fitting-parameters-of-a-simple-process-model-optimisation-uncertainty/16349 "2021-12-21T20:35:42Z")

</div>

I have a very simple hydrological model. The model can be simply conceptualised as below: I am trying to learn the values of the parameters a, b and c. Where: P = Precipitation Inputs L = Losses S = Storage (ground…

---

## [Can I come back to analyzing posterior of a model after csv's have been dropped?](https://discourse.mc-stan.org/t/can-i-come-back-to-analyzing-posterior-of-a-model-after-csvs-have-been-dropped/25019)

<div class="topic-metadata">

**Author:** [@Jordan\_Howell](https://discourse.mc-stan.org/u/Jordan_Howell)\
**Replies:** 2\
**Last updated:** [November 10, 2021, 7:42pm UTC](https://discourse.mc-stan.org/t/can-i-come-back-to-analyzing-posterior-of-a-model-after-csvs-have-been-dropped/25019 "2021-11-10T19:42:01Z")

</div>

Hello. I have fit a model and generated posterior predictive samples using cmdstanpy. Now that it’s done and the four csvs with samples are dropped to my computer, is there a standard practice on coming back to them la…

---

## [Problems Compiling Model](https://discourse.mc-stan.org/t/problems-compiling-model/25170)

<div class="topic-metadata">

**Author:** [@Jordan\_Howell](https://discourse.mc-stan.org/u/Jordan_Howell)\
**Replies:** 3\
**Last updated:** [November 9, 2021, 7:19pm UTC](https://discourse.mc-stan.org/t/problems-compiling-model/25170 "2021-11-09T19:19:14Z")

</div>

Hello. I’m trying to compile my model after removing the ‘generate quantities’ block and it will not compile now. The code of the model is below. data { int\<lower=0\> N; // number policy term years int\<lowe…

---

## [Various observations on rstan, cmdstanr, pystan and cmdstanpy after teaching with all in parallel](https://discourse.mc-stan.org/t/various-observations-on-rstan-cmdstanr-pystan-and-cmdstanpy-after-teaching-with-all-in-parallel/23455)

<div class="topic-metadata">

**Author:** [@robertgrant](https://discourse.mc-stan.org/u/robertgrant)\
**Replies:** 26\
**Last updated:** [October 12, 2021, 4:21pm UTC](https://discourse.mc-stan.org/t/various-observations-on-rstan-cmdstanr-pystan-and-cmdstanpy-after-teaching-with-all-in-parallel/23455 "2021-10-12T16:21:17Z")

</div>

I recently ran an introductory course for the Royal Statistical Society, which I did the last couple of years with rstan only, but now for the first time I offered a choice of rstan, pystan, cmdstanr or cmdstanpy. This g…

---

## [EBFMI (very) low, looking for reparameterization advice](https://discourse.mc-stan.org/t/ebfmi-very-low-looking-for-reparameterization-advice/24412)

<div class="topic-metadata">

**Author:** [@BFiles](https://discourse.mc-stan.org/u/BFiles)\
**Replies:** 27\
**Last updated:** [October 1, 2021, 6:54pm UTC](https://discourse.mc-stan.org/t/ebfmi-very-low-looking-for-reparameterization-advice/24412 "2021-10-01T18:54:50Z")

</div>

Summary I have a model that is recovering parameters, has no divergences and good \\hat{R}, but very low (\<0.1) E-BFMI. Increasing warmup iterations moved E-BFMI up, but it is still \< 0.1. I am looking for suggestions to …

---

## [New paper on splines and data depth with cmdstanpy](https://discourse.mc-stan.org/t/new-paper-on-splines-and-data-depth-with-cmdstanpy/24482)

<div class="topic-metadata">

**Author:** [@jbaranowski](https://discourse.mc-stan.org/u/jbaranowski)\
**Replies:** 1\
**Last updated:** [September 20, 2021, 5:10pm UTC](https://discourse.mc-stan.org/t/new-paper-on-splines-and-data-depth-with-cmdstanpy/24482 "2021-09-20T17:10:28Z")

</div>

Together with my collegues Katarzyna Grobler-Dębska and Edyta Kucharska we have published a new paper titled " Recognizing VSC DC Cable Fault Types Using Bayesian Functional Data Depth" in the Energies journal. We use s…

---

## [How to change the number of draws I want in my generated quantity](https://discourse.mc-stan.org/t/how-to-change-the-number-of-draws-i-want-in-my-generated-quantity/24291)

<div class="topic-metadata">

**Author:** [@alexhallam](https://discourse.mc-stan.org/u/alexhallam)\
**Replies:** 1\
**Last updated:** [September 8, 2021, 2:23am UTC](https://discourse.mc-stan.org/t/how-to-change-the-number-of-draws-i-want-in-my-generated-quantity/24291 "2021-09-08T02:23:07Z")

</div>

I have a super simple model. How do I generate more draws in my new generated quantities. The results are shown at the bottom of this post. It seems like the draws are set at 1000 by default. How can I increase or decrea…

---

## [Running stan models in parallel in cmdstan py](https://discourse.mc-stan.org/t/running-stan-models-in-parallel-in-cmdstan-py/24170)

<div class="topic-metadata">

**Author:** [@jbaranowski](https://discourse.mc-stan.org/u/jbaranowski)\
**Replies:** 3\
**Last updated:** [August 31, 2021, 4:15pm UTC](https://discourse.mc-stan.org/t/running-stan-models-in-parallel-in-cmdstan-py/24170 "2021-08-31T16:15:13Z")

</div>

I’m wondering how to use parallelism when running stan models in cmdstanpy. I’m doing simulation-based calibration for my model so I need to run fits multiple times. When i tried using multiprocessing module I got s…

---

## [A way to create JSON file for cmdstanpy in python?](https://discourse.mc-stan.org/t/a-way-to-create-json-file-for-cmdstanpy-in-python/23843)

<div class="topic-metadata">

**Author:** [@kshvov](https://discourse.mc-stan.org/u/kshvov)\
**Replies:** 4\
**Last updated:** [August 12, 2021, 3:37am UTC](https://discourse.mc-stan.org/t/a-way-to-create-json-file-for-cmdstanpy-in-python/23843 "2021-08-12T03:37:27Z")

</div>

I’ve recently started learning cmdstanpy(or stan in general), and was wondering if there is a way to create a JSON data file other than manually converting data using json.dump in python. So for example, say I have six …

---

## [How to cite cmdstanpy?](https://discourse.mc-stan.org/t/how-to-cite-cmdstanpy/23538)

<div class="topic-metadata">

**Author:** [@Teddy\_Groves1](https://discourse.mc-stan.org/u/Teddy_Groves1)\
**Replies:** 4\
**Last updated:** [July 20, 2021, 7:18am UTC](https://discourse.mc-stan.org/t/how-to-cite-cmdstanpy/23538 "2021-07-20T07:18:25Z")

</div>

My colleagues and I would like to cite cmdstanpy in an academic paper - can anyone point me towards the best way to do this?

---

## [Adjoint ode: different behaviour in cmdstan-ode-adjoint-v2 vs cmdstan-2.27.0](https://discourse.mc-stan.org/t/adjoint-ode-different-behaviour-in-cmdstan-ode-adjoint-v2-vs-cmdstan-2-27-0/23388)

<div class="topic-metadata">

**Author:** [@Teddy\_Groves1](https://discourse.mc-stan.org/u/Teddy_Groves1)\
**Replies:** 3\
**Last updated:** [July 13, 2021, 11:39am UTC](https://discourse.mc-stan.org/t/adjoint-ode-different-behaviour-in-cmdstan-ode-adjoint-v2-vs-cmdstan-2-27-0/23388 "2021-07-13T11:39:55Z")

</div>

My colleagues and I have been having some trouble with a model that uses the recently-released adjoint ode solver and would really appreciate some help. The background is that we are making an application for fitting Ba…

---

## [Having trouble recovering known parameters from simulated data](https://discourse.mc-stan.org/t/having-trouble-recovering-known-parameters-from-simulated-data/22844)

<div class="topic-metadata">

**Author:** [@gibsramen](https://discourse.mc-stan.org/u/gibsramen)\
**Replies:** 2\
**Last updated:** [June 4, 2021, 1:40am UTC](https://discourse.mc-stan.org/t/having-trouble-recovering-known-parameters-from-simulated-data/22844 "2021-06-04T01:40:47Z")

</div>

Hello, all. I’m interested in using Stan for a project involving Poisson (and related distributions) regressions. I am simulating data to make sure I can properly retrieve parameters from a simple model but I’m having m…

---

## [PPCs in ArviZ?](https://discourse.mc-stan.org/t/ppcs-in-arviz/22176)

<div class="topic-metadata">

**Author:** [@shira](https://discourse.mc-stan.org/u/shira)\
**Replies:** 1\
**Last updated:** [April 28, 2021, 7:19pm UTC](https://discourse.mc-stan.org/t/ppcs-in-arviz/22176 "2021-04-28T19:19:12Z")

</div>

Hi ! We are using CmdStanPy and ArviZ and want to do posterior predictive checks (PPCs). I see plot\_ppc() in arviz, but does arviz also have something like ppc\_stat() in bayesplot ? Thanks so much !

---

## [Getting runtimeerror: ERROR when running cmdstanpy tutorial on google colab](https://discourse.mc-stan.org/t/getting-runtimeerror-error-when-running-cmdstanpy-tutorial-on-google-colab/22109)

<div class="topic-metadata">

**Author:** [@ek247375](https://discourse.mc-stan.org/u/ek247375)\
**Replies:** 1\
**Last updated:** [April 26, 2021, 12:54pm UTC](https://discourse.mc-stan.org/t/getting-runtimeerror-error-when-running-cmdstanpy-tutorial-on-google-colab/22109 "2021-04-26T12:54:26Z")

</div>

I am running the basic “hello world” tutorial for cmdstanpy found here. The problem I have is that I cannot access the sample summary. I get the following error. RuntimeError: ERROR The following argument was not expec…

---

## [How to get draws from cmdstanpy.stanfit.CmdStanMCMC?](https://discourse.mc-stan.org/t/how-to-get-draws-from-cmdstanpy-stanfit-cmdstanmcmc/21942)

<div class="topic-metadata">

**Author:** [@shira](https://discourse.mc-stan.org/u/shira)\
**Replies:** 5\
**Last updated:** [April 18, 2021, 6:52pm UTC](https://discourse.mc-stan.org/t/how-to-get-draws-from-cmdstanpy-stanfit-cmdstanmcmc/21942 "2021-04-18T18:52:28Z")

</div>

In colab I do: import cmdstanpy cmdstanpy.install\_cmdstan() print(cmdstanpy.\_\_version\_\_) gives: INFO:cmdstanpy:Install directory: /root/.cmdstanpy INFO:cmdstanpy:Downloading CmdStan version 2.26.1 INFO:cmdstanpy:Downl…

---

## [Fixed param, but for whole fit?](https://discourse.mc-stan.org/t/fixed-param-but-for-whole-fit/21384)

<div class="topic-metadata">

**Author:** [@Funko\_Unko](https://discourse.mc-stan.org/u/Funko_Unko)\
**Replies:** 13\
**Last updated:** [April 13, 2021, 1:01pm UTC](https://discourse.mc-stan.org/t/fixed-param-but-for-whole-fit/21384 "2021-04-13T13:01:03Z")

</div>

Is there a way (via cmdstan, preferrably via cmdstanpy) to do a fixed param run, but with many chains in parallel and with many different values for the parameters, coming from some fit object/csv? Something like generat…

---

## [Interpretation of relative weight in model comparison](https://discourse.mc-stan.org/t/interpretation-of-relative-weight-in-model-comparison/21390)

<div class="topic-metadata">

**Author:** [@gibsramen](https://discourse.mc-stan.org/u/gibsramen)\
**Replies:** 1\
**Last updated:** [March 20, 2021, 5:34pm UTC](https://discourse.mc-stan.org/t/interpretation-of-relative-weight-in-model-comparison/21390 "2021-03-20T17:34:11Z")

</div>

Hi, all. I have a question regarding model comparison and specifically some confusion regarding the relative weights from the compare function in arviz. I have a small subset of my data that I am using to learn more abo…

---

## [Subclassing Cmdstanpy](https://discourse.mc-stan.org/t/subclassing-cmdstanpy/21333)

<div class="topic-metadata">

**Author:** [@Funko\_Unko](https://discourse.mc-stan.org/u/Funko_Unko)\
**Replies:** 7\
**Last updated:** [March 18, 2021, 3:44pm UTC](https://discourse.mc-stan.org/t/subclassing-cmdstanpy/21333 "2021-03-18T15:44:42Z")

</div>

I don’t want to derail the other thread any further (https://discourse.mc-stan.org/t/cookiecutter-cmdstanpy-a-template-for-cmdstanpy-projects/21310?u=FunkoUnko sorry @Teddy\_Groves1). @ahartikainen yes, a lot of the func…

---

## [Arviz.reloo: am I doing it right?](https://discourse.mc-stan.org/t/arviz-reloo-am-i-doing-it-right/20988)

<div class="topic-metadata">

**Author:** [@Teddy\_Groves1](https://discourse.mc-stan.org/u/Teddy_Groves1)\
**Replies:** 2\
**Last updated:** [February 25, 2021, 8:19pm UTC](https://discourse.mc-stan.org/t/arviz-reloo-am-i-doing-it-right/20988 "2021-02-25T20:19:11Z")

</div>

I’m continuing a discussion from arviz github with @OriolAbril here for better exposure. I would like to compare the out-of-sample predictive performance of some statistical models that I’ve been fitting and analysing w…

---

## [Extracting a variable from a stanfit object fails when \`save\_warmup=True\`](https://discourse.mc-stan.org/t/extracting-a-variable-from-a-stanfit-object-fails-when-save-warmup-true/19559)

<div class="topic-metadata">

**Author:** [@cmo](https://discourse.mc-stan.org/u/cmo)\
**Replies:** 2\
**Last updated:** [November 30, 2020, 5:04pm UTC](https://discourse.mc-stan.org/t/extracting-a-variable-from-a-stanfit-object-fails-when-save-warmup-true/19559 "2020-11-30T17:04:08Z")

</div>

I’m asking this here instead of using the issue tracker since I’m not entirely sure whether this is a bug or a case of PEBCAK. I am fitting a model using cmdstanpy, using sample\_args = {'iter': 100, 'warmup': 10, 'chai…

---

## [Cmdstanpy, Prediction Workflow, and Generated Quantitites](https://discourse.mc-stan.org/t/cmdstanpy-prediction-workflow-and-generated-quantitites/18305)

<div class="topic-metadata">

**Author:** [@imadmali](https://discourse.mc-stan.org/u/imadmali)\
**Replies:** 6\
**Last updated:** [October 29, 2020, 6:39pm UTC](https://discourse.mc-stan.org/t/cmdstanpy-prediction-workflow-and-generated-quantitites/18305 "2020-10-29T18:39:10Z")

</div>

So this might not be just for cmdstanpy, but I’ve been using that a lot lately so that’s the interface I’ll use as an example. The question is about workflow and whether predictions should be done using generated quantit…

---

## [Specifying path to compiled Stan program with cmdstanpy](https://discourse.mc-stan.org/t/specifying-path-to-compiled-stan-program-with-cmdstanpy/17986)

<div class="topic-metadata">

**Author:** [@imadmali](https://discourse.mc-stan.org/u/imadmali)\
**Replies:** 2\
**Last updated:** [September 14, 2020, 7:09am UTC](https://discourse.mc-stan.org/t/specifying-path-to-compiled-stan-program-with-cmdstanpy/17986 "2020-09-14T07:09:49Z")

</div>

Hi - With cmdstanpy is it possible to specify the path in CmdStanModel to where compiled Stan program will be saved, similar to the way you can with the output\_dir argument in CmdStanModel.sample()? The following is sta…

---

## [Cleaning up files generated by cmdstanpy](https://discourse.mc-stan.org/t/cleaning-up-files-generated-by-cmdstanpy/17556)

<div class="topic-metadata">

**Author:** [@imadmali](https://discourse.mc-stan.org/u/imadmali)\
**Replies:** 7\
**Last updated:** [August 29, 2020, 7:52pm UTC](https://discourse.mc-stan.org/t/cleaning-up-files-generated-by-cmdstanpy/17556 "2020-08-29T19:52:36Z")

</div>

Hi - What is the suggested workflow to clear the working directory of files generated by CmdStanModel.sample when using cmdstanpy. Are people storing these in a temporary directory and then deleting that after sampling? …

---

## [Specifying output file names](https://discourse.mc-stan.org/t/specifying-output-file-names/16345)

<div class="topic-metadata">

**Author:** [@mtwest](https://discourse.mc-stan.org/u/mtwest)\
**Replies:** 32\
**Last updated:** [July 31, 2020, 7:34pm UTC](https://discourse.mc-stan.org/t/specifying-output-file-names/16345 "2020-07-31T19:34:10Z")

</div>

I am working on a distributed computing pool and wish to run many independent instances of an analysis. If these jobs are submitted at the same time, I will get file-name clashes and some results will be overwritten. Is …

---

## [Resume sampling after interuption](https://discourse.mc-stan.org/t/resume-sampling-after-interuption/15053)

<div class="topic-metadata">

**Author:** [@mcbricall](https://discourse.mc-stan.org/u/mcbricall)\
**Replies:** 5\
**Last updated:** [May 12, 2020, 11:48pm UTC](https://discourse.mc-stan.org/t/resume-sampling-after-interuption/15053 "2020-05-12T23:48:24Z")

</div>

I’m using cmdstanpy and would like to be able to resume sampling after losing my session. This could help save costs by allowing slower models to run on AWS spot instances. Since I can’t find any concrete examples out th…

---

## [CmdStanPy cpp\_options for multi-threading](https://discourse.mc-stan.org/t/cmdstanpy-cpp-options-for-multi-threading/14759)

<div class="topic-metadata">

**Author:** [@stantheman](https://discourse.mc-stan.org/u/stantheman)\
**Replies:** 1\
**Last updated:** [May 2, 2020, 10:56am UTC](https://discourse.mc-stan.org/t/cmdstanpy-cpp-options-for-multi-threading/14759 "2020-05-02T10:56:06Z")

</div>

I’m trying to use the latest version of CmdStanPy to run sampling on my stan model which uses map\_rect. However, it looks like CmdStanPy’s CmdStanModel cpp\_options doesn’t allow specifying compiler options like ‘-pthread…

[Previous page](https://discourse.mc-stan.org/tag/cmdstanpy/64.md?match_all_tags=true&page=1&tags%5B%5D=cmdstanpy)
