# \#cmdstanpy

**URL:** https://discourse.mc-stan.org/tag/cmdstanpy/64.md

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

---

## [Using the name 'Stan' for packages derived from Stan/CmdStan/CmdStanPy](https://discourse.mc-stan.org/t/using-the-name-stan-for-packages-derived-from-stan-cmdstan-cmdstanpy/40964)

<div class="topic-metadata">

**Author:** [@sppradhan](https://discourse.mc-stan.org/u/sppradhan)\
**Replies:** 9\
**Last updated:** [March 20, 2026, 4:27pm UTC](https://discourse.mc-stan.org/t/using-the-name-stan-for-packages-derived-from-stan-cmdstan-cmdstanpy/40964 "2026-03-20T16:27:34Z")

</div>

Hi! I am grad student currently working on a package that uses Stan under the hood (specifically, CmdStanPy) for modeling. Ofcourse the package does more things, but Stan and the Bayesian workflow are its core component…

---

## [CmdStan, CmdStanR, CmdStanPy workflow resulting in errors with \`as.shinystan\` function](https://discourse.mc-stan.org/t/cmdstan-cmdstanr-cmdstanpy-workflow-resulting-in-errors-with-as-shinystan-function/40672)

<div class="topic-metadata">

**Author:** [@danni\_storm](https://discourse.mc-stan.org/u/danni_storm)\
**Replies:** 6\
**Last updated:** [December 11, 2025, 2:43pm UTC](https://discourse.mc-stan.org/t/cmdstan-cmdstanr-cmdstanpy-workflow-resulting-in-errors-with-as-shinystan-function/40672 "2025-12-11T14:43:05Z")

</div>

My model successfully runs and produces CSV files. However, when trying to use R and ShinyStan, I am unable to get ShinyStan to accept my model files using CmdStanR. I have been digging into the documentation and it look…

---

## [Optimal compiler flags M4 Max](https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559)

<div class="topic-metadata">

**Author:** [@Sean\_Matthews](https://discourse.mc-stan.org/u/Sean_Matthews)\
**Replies:** 2\
**Last updated:** [October 27, 2025, 11:28pm UTC](https://discourse.mc-stan.org/t/optimal-compiler-flags-m4-max/40559 "2025-10-27T23:28:39Z")

</div>

Very simple question (I’ve searched, but I can’t find a matching answer). I have a Mac M4 Max. How should I set compiler flags (in cmdstanpy) for optimal performance? All advice appreciated.

---

## [Packaging python project with cmdstan as dependency](https://discourse.mc-stan.org/t/packaging-python-project-with-cmdstan-as-dependency/39599)

<div class="topic-metadata">

**Author:** [@Benjamin\_Kambs](https://discourse.mc-stan.org/u/Benjamin_Kambs)\
**Replies:** 1\
**Last updated:** [May 30, 2025, 1:20am UTC](https://discourse.mc-stan.org/t/packaging-python-project-with-cmdstan-as-dependency/39599 "2025-05-30T01:20:44Z")

</div>

Hi everyone, I am currently trying to figure out the dos and don’ts of building and publishing python packages. It’s all new and cryptic to me. My package uses cmdstanpy and therefore has cmdstan as dependency. I set u…

---

## [Hierarchical Logistic Regression failed (Runtime error 139)](https://discourse.mc-stan.org/t/hierarchical-logistic-regression-failed-runtime-error-139/39385)

<div class="topic-metadata">

**Author:** [@daniel-hartman](https://discourse.mc-stan.org/u/daniel-hartman)\
**Replies:** 6\
**Last updated:** [May 10, 2025, 6:21pm UTC](https://discourse.mc-stan.org/t/hierarchical-logistic-regression-failed-runtime-error-139/39385 "2025-05-10T18:21:46Z")

</div>

Hello all. I’m just getting started with Stan in python via cmdstanpy. I’m using the associated conda environment, and using the stock regression model in the stan manual (see Regression Models) to get something workin…

---

## [Slow running hierachical model](https://discourse.mc-stan.org/t/slow-running-hierachical-model/39461)

<div class="topic-metadata">

**Author:** [@niels\_aak](https://discourse.mc-stan.org/u/niels_aak)\
**Replies:** 0\
**Last updated:** [May 10, 2025, 1:08pm UTC](https://discourse.mc-stan.org/t/slow-running-hierachical-model/39461 "2025-05-10T13:08:55Z")

</div>

Hi everyone I have a hierarchical model specified in the following way. It does okay in fitting on low amounts of data, but when I scale it it takes a very long time to fit. I need to be able to fit 300,000 observations…

---

## [Fitting a Beta mixture model](https://discourse.mc-stan.org/t/fitting-a-beta-mixture-model/39394)

<div class="topic-metadata">

**Author:** [@foobar](https://discourse.mc-stan.org/u/foobar)\
**Replies:** 4\
**Last updated:** [May 7, 2025, 9:44pm UTC](https://discourse.mc-stan.org/t/fitting-a-beta-mixture-model/39394 "2025-05-07T21:44:23Z")

</div>

Hello, I am trying to fit a Beta mixture model as shown below. I reparameterized the beta distribution in terms of \\phi and \\lambda and ordered both \\phi and \\lambda to avoid label switching. In the diagnostics (beta\_m…

---

## [Is there a way to only write some results to disk in cmdstanpy / cmdstanr?](https://discourse.mc-stan.org/t/is-there-a-way-to-only-write-some-results-to-disk-in-cmdstanpy-cmdstanr/39279)

<div class="topic-metadata">

**Author:** [@markjrieke](https://discourse.mc-stan.org/u/markjrieke)\
**Replies:** 3\
**Last updated:** [April 16, 2025, 10:27pm UTC](https://discourse.mc-stan.org/t/is-there-a-way-to-only-write-some-results-to-disk-in-cmdstanpy-cmdstanr/39279 "2025-04-16T22:27:07Z")

</div>

Is there a way to save a subset of parameters using cmdstanpy / cmdstanr? Sometimes, it’s nice to not have something be locally scoped, but not necessarily need it in the output (i.e., a big matrix defined in the transfo…

---

## [Problem installing cmdstanpy on a Mac](https://discourse.mc-stan.org/t/problem-installing-cmdstanpy-on-a-mac/38537)

<div class="topic-metadata">

**Author:** [@Bryan\_Palmer](https://discourse.mc-stan.org/u/Bryan_Palmer)\
**Replies:** 1\
**Last updated:** [January 20, 2025, 6:13am UTC](https://discourse.mc-stan.org/t/problem-installing-cmdstanpy-on-a-mac/38537 "2025-01-20T06:13:29Z")

</div>

I am using cmdstanpy in a micromamba environment on a Mac running Sequoia 15.2 The core error message I get is: Chain \[1\] dyld\[973\]: Symbol not found: \_\_ZN3tbb4task13note\_affinityEt From scanning the web, it looks lik…

---

## [Multiprocessing and/or multithreading problem - CmdStanPy](https://discourse.mc-stan.org/t/multiprocessing-and-or-multithreading-problem-cmdstanpy/38308)

<div class="topic-metadata">

**Author:** [@pablogalazcares](https://discourse.mc-stan.org/u/pablogalazcares)\
**Replies:** 12\
**Last updated:** [January 2, 2025, 8:59pm UTC](https://discourse.mc-stan.org/t/multiprocessing-and-or-multithreading-problem-cmdstanpy/38308 "2025-01-02T20:59:19Z")

</div>

Hi Stan Community, I’m trying to use reduce\_sum in my Stan model to parallelize computations across multiple threads. While the model runs without errors, I noticed in the Mac Activity Monitor that each chain only uses 1…

---

## [Comparision: simple AR(1) model in stan vs. pymc](https://discourse.mc-stan.org/t/comparision-simple-ar-1-model-in-stan-vs-pymc/37529)

<div class="topic-metadata">

**Author:** [@teagum](https://discourse.mc-stan.org/u/teagum)\
**Replies:** 4\
**Last updated:** [December 10, 2024, 9:10pm UTC](https://discourse.mc-stan.org/t/comparision-simple-ar-1-model-in-stan-vs-pymc/37529 "2024-12-10T21:10:17Z")

</div>

I’am trying to replicate an AR model I once code in PyMC. Th Stan version gives yield some different results and would like to know why this is the case. This is the PyMC code: with pm.Model() as pm\_model: rho = pm…

---

## [Pathfinder failure without hint why it failed](https://discourse.mc-stan.org/t/pathfinder-failure-without-hint-why-it-failed/37248)

<div class="topic-metadata">

**Author:** [@Benjamin\_Kambs](https://discourse.mc-stan.org/u/Benjamin_Kambs)\
**Replies:** 12\
**Last updated:** [November 19, 2024, 8:35pm UTC](https://discourse.mc-stan.org/t/pathfinder-failure-without-hint-why-it-failed/37248 "2024-11-19T20:35:12Z")

</div>

Hello there! I am currently modifying Facebook’s Prophet to my needs. In contrast to Prophet I use the Pathfinder algorithm which works in most cases. However, I encounter an error on some occasions. The error doesn’t t…

---

## [CmdStanPy Variational - How to get density parameters?](https://discourse.mc-stan.org/t/cmdstanpy-variational-how-to-get-density-parameters/37280)

<div class="topic-metadata">

**Author:** [@madelynandersen](https://discourse.mc-stan.org/u/madelynandersen)\
**Replies:** 10\
**Last updated:** [November 19, 2024, 8:27pm UTC](https://discourse.mc-stan.org/t/cmdstanpy-variational-how-to-get-density-parameters/37280 "2024-11-19T20:27:22Z")

</div>

Hi! Here is the smallest reproducible code unit. I am working on the following fully conjugate normal model: Y \\sim \\mathcal{N}(\\mu, \\sigma^2)\\\\ \\mu \\sim \\mathcal{N}(\\mu\_0, \\sigma\_0^2) In my toy model, I am setting …

---

## [\[OLD\] Introducing Stan Playground - A Web-Based Platform for Stan Programming and Collaboration](https://discourse.mc-stan.org/t/old-introducing-stan-playground-a-web-based-platform-for-stan-programming-and-collaboration/31653)

<div class="topic-metadata">

**Author:** [@magland](https://discourse.mc-stan.org/u/magland)\
**Replies:** 3\
**Last updated:** [October 28, 2024, 2:48pm UTC](https://discourse.mc-stan.org/t/old-introducing-stan-playground-a-web-based-platform-for-stan-programming-and-collaboration/31653 "2024-10-28T14:48:40Z")

</div>

Note: For anyone finding this thread. This has been replaced by a brand new version: Original post: Hello everyone, I’m excited to share a new piece of open-source software called Stan Playground. This is a web-based…

---

## [Problem with generated quantities in cmdstanpy](https://discourse.mc-stan.org/t/problem-with-generated-quantities-in-cmdstanpy/28130)

<div class="topic-metadata">

**Author:** [@mingqian.guo](https://discourse.mc-stan.org/u/mingqian.guo)\
**Replies:** 6\
**Last updated:** [October 25, 2024, 1:38am UTC](https://discourse.mc-stan.org/t/problem-with-generated-quantities-in-cmdstanpy/28130 "2024-10-25T01:38:27Z")

</div>

Dear Stan experts, I am trying to fit a time-varying drift diffusion model(tDDM) adopted from Maier et al., 2020 NHB with cmdstanpy. However, there is a very weird thing. All parameters in generated quantities have no …

---

## [Parameter inequivalence in linear regression QR decomposition model](https://discourse.mc-stan.org/t/parameter-inequivalence-in-linear-regression-qr-decomposition-model/36147)

<div class="topic-metadata">

**Author:** [@Simon\_Smith](https://discourse.mc-stan.org/u/Simon_Smith)\
**Replies:** 2\
**Last updated:** [August 14, 2024, 11:24am UTC](https://discourse.mc-stan.org/t/parameter-inequivalence-in-linear-regression-qr-decomposition-model/36147 "2024-08-14T11:24:18Z")

</div>

I am having a problem with the equivalence of parameters learned with my Stan model. In the linear regression model shown below, I am using a bspline design matrix, along with the QR reparameterization for computational…

---

## [Marginal effects for nonlinear multilevel models](https://discourse.mc-stan.org/t/marginal-effects-for-nonlinear-multilevel-models/36050)

<div class="topic-metadata">

**Author:** [@amillb](https://discourse.mc-stan.org/u/amillb)\
**Replies:** 2\
**Last updated:** [August 5, 2024, 9:16pm UTC](https://discourse.mc-stan.org/t/marginal-effects-for-nonlinear-multilevel-models/36050 "2024-08-05T21:16:35Z")

</div>

I’m trying to calculate marginal effects for a multilevel nonlinear (beta) model using cmdstanpy. I have continuous predictors at both the top and lower levels of the model, roughly following this example. Marginal effe…

---

## [Cannot find -lOpenCL](https://discourse.mc-stan.org/t/cannot-find-lopencl/35667)

<div class="topic-metadata">

**Author:** [@tbrown122387](https://discourse.mc-stan.org/u/tbrown122387)\
**Replies:** 4\
**Last updated:** [June 28, 2024, 12:17pm UTC](https://discourse.mc-stan.org/t/cannot-find-lopencl/35667 "2024-06-28T12:17:29Z")

</div>

A model object in cmdstanpy can build just fine, until I try to bring in my GPU. The compiler error says it can’t detect c++17, but I do have it. Here’s the code that triggers the error: model\_code = os.path.join('.', …

---

## [Converting sccomp from rstan to Python - paid work + addendum authorsphip on the paper](https://discourse.mc-stan.org/t/converting-sccomp-from-rstan-to-python-paid-work-addendum-authorsphip-on-the-paper/33743)

<div class="topic-metadata">

**Author:** [@stemangiola](https://discourse.mc-stan.org/u/stemangiola)\
**Replies:** 12\
**Last updated:** [June 6, 2024, 8:05am UTC](https://discourse.mc-stan.org/t/converting-sccomp-from-rstan-to-python-paid-work-addendum-authorsphip-on-the-paper/33743 "2024-06-06T08:05:34Z")

</div>

Hello All, I would like to convert sccomp https://www.pnas.org/doi/10.1073/pnas.2203828120 GitHub - MangiolaLaboratory/sccomp: Testing differences in cell type proportions from single-cell data. from rstan to pystan,…

---

## [Cmdstan on Mac](https://discourse.mc-stan.org/t/cmdstan-on-mac/30550)

<div class="topic-metadata">

**Author:** [@Arianna\_Gambardella](https://discourse.mc-stan.org/u/Arianna_Gambardella)\
**Replies:** 7\
**Last updated:** [May 15, 2024, 9:35pm UTC](https://discourse.mc-stan.org/t/cmdstan-on-mac/30550 "2024-05-15T21:35:20Z")

</div>

I am trying to run a Stan model on python (using cmdstanpy) on a Mac computer. The error I get is the following: CmdStan’s precompiled header (PCH) files may need to be rebuilt.Please run cmdstanpy.rebuild\_cmdstan(). Wh…

---

## [Estimation of time-varying infection parameter for a simple SEIR model](https://discourse.mc-stan.org/t/estimation-of-time-varying-infection-parameter-for-a-simple-seir-model/35132)

<div class="topic-metadata">

**Author:** [@Akuno](https://discourse.mc-stan.org/u/Akuno)\
**Replies:** 0\
**Last updated:** [May 13, 2024, 6:30pm UTC](https://discourse.mc-stan.org/t/estimation-of-time-varying-infection-parameter-for-a-simple-seir-model/35132 "2024-05-13T18:30:10Z")

</div>

Dear all, I have been stuck on this topic for some time now. I am trying to estimate time-varying infection (with other time-independent epidemiological) parameters for a complex multi-patch SEIRS model. But I decided …

---

## [Cmdstanpy: Supplying multiple paths as inits writes to /tmp?](https://discourse.mc-stan.org/t/cmdstanpy-supplying-multiple-paths-as-inits-writes-to-tmp/34968)

<div class="topic-metadata">

**Author:** [@Garren\_Hermanus](https://discourse.mc-stan.org/u/Garren_Hermanus)\
**Replies:** 8\
**Last updated:** [May 1, 2024, 9:01pm UTC](https://discourse.mc-stan.org/t/cmdstanpy-supplying-multiple-paths-as-inits-writes-to-tmp/34968 "2024-05-01T21:01:44Z")

</div>

Hi all I just wanted to know how I can supply multiple inits, paths to json files, to the sampling method? I have tried supplying a list of paths as inits, however when inspecting the csv files there is a json file bein…

---

## [Reproducibility of a non-linear model](https://discourse.mc-stan.org/t/reproducibility-of-a-non-linear-model/34656)

<div class="topic-metadata">

**Author:** [@Garren\_Hermanus](https://discourse.mc-stan.org/u/Garren_Hermanus)\
**Replies:** 3\
**Last updated:** [April 23, 2024, 10:50pm UTC](https://discourse.mc-stan.org/t/reproducibility-of-a-non-linear-model/34656 "2024-04-23T22:50:49Z")

</div>

Hi all. I have been having some trouble with the reproducibility of my model. The problem is fairly ill behaved (several different modes some of which may be close to one another in terms of the log posterior value). I …

---

## [Continuing with optimization using lbfgs/bfgs when optimization is terminated](https://discourse.mc-stan.org/t/continuing-with-optimization-using-lbfgs-bfgs-when-optimization-is-terminated/34858)

<div class="topic-metadata">

**Author:** [@Garren\_Hermanus](https://discourse.mc-stan.org/u/Garren_Hermanus)\
**Replies:** 2\
**Last updated:** [April 23, 2024, 6:35pm UTC](https://discourse.mc-stan.org/t/continuing-with-optimization-using-lbfgs-bfgs-when-optimization-is-terminated/34858 "2024-04-23T18:35:53Z")

</div>

Hi all I just wanted to know if it possible to continue with an optimization when some stopping criteria is achieved (in this case the maximum number of iterations)? Practically speaking we should able to just use the f…

---

## [CMDSTAN not being set when running cmdstanpy on jupyter notebook in VS code](https://discourse.mc-stan.org/t/cmdstan-not-being-set-when-running-cmdstanpy-on-jupyter-notebook-in-vs-code/34740)

<div class="topic-metadata">

**Author:** [@Garren\_Hermanus](https://discourse.mc-stan.org/u/Garren_Hermanus)\
**Replies:** 3\
**Last updated:** [April 15, 2024, 3:39pm UTC](https://discourse.mc-stan.org/t/cmdstan-not-being-set-when-running-cmdstanpy-on-jupyter-notebook-in-vs-code/34740 "2024-04-15T15:39:16Z")

</div>

Hi all. I am experiencing some issues with using notebook to compile my stan models. It worked fine up until a minute ago and suddenly just broke (I did not install nor update any the packages.extensions). When running t…

---

## [Can't compile models with cmdstanpy in ipynb / vscode](https://discourse.mc-stan.org/t/cant-compile-models-with-cmdstanpy-in-ipynb-vscode/34749)

<div class="topic-metadata">

**Author:** [@rtdew1](https://discourse.mc-stan.org/u/rtdew1)\
**Replies:** 2\
**Last updated:** [April 10, 2024, 3:33am UTC](https://discourse.mc-stan.org/t/cant-compile-models-with-cmdstanpy-in-ipynb-vscode/34749 "2024-04-10T03:33:34Z")

</div>

I am suddenly unable to compile models using cmdstanpy in ipynb files. I usually use VS Code to work with them. As a simple example: import cmdstanpy model = cmdstanpy.CmdStanModel(stan\_file="model.stan") This script …

---

## [Pathfinder does not accept multiple inits?](https://discourse.mc-stan.org/t/pathfinder-does-not-accept-multiple-inits/34580)

<div class="topic-metadata">

**Author:** [@Garren\_Hermanus](https://discourse.mc-stan.org/u/Garren_Hermanus)\
**Replies:** 2\
**Last updated:** [March 25, 2024, 6:56pm UTC](https://discourse.mc-stan.org/t/pathfinder-does-not-accept-multiple-inits/34580 "2024-03-25T18:56:04Z")

</div>

Hi all I just wanted to know why pathfinder does not accept multiple inits as an argument? I would’ve expected this to be the case since we can set the num\_paths variable, thus similar to the sample method’s chains. I t…

---

## [Stochastic Volatility for Latent Factor Models](https://discourse.mc-stan.org/t/stochastic-volatility-for-latent-factor-models/34140)

<div class="topic-metadata">

**Author:** [@Adam\_Dieck](https://discourse.mc-stan.org/u/Adam_Dieck)\
**Replies:** 1\
**Last updated:** [February 21, 2024, 8:44pm UTC](https://discourse.mc-stan.org/t/stochastic-volatility-for-latent-factor-models/34140 "2024-02-21T20:44:16Z")

</div>

Hi all! I’m currently working on a STAN implementation of the Dynamic Nelson-Siegel model for my economics thesis and am hitting some roadblocks when it comes to including stochastic volatility on the latent factors. My…

---

## [Configuring complier flags in cmdstanpy](https://discourse.mc-stan.org/t/configuring-complier-flags-in-cmdstanpy/33960)

<div class="topic-metadata">

**Author:** [@akcchoi](https://discourse.mc-stan.org/u/akcchoi)\
**Replies:** 4\
**Last updated:** [February 14, 2024, 10:29am UTC](https://discourse.mc-stan.org/t/configuring-complier-flags-in-cmdstanpy/33960 "2024-02-14T10:29:44Z")

</div>

Hi all, I wonder if there is a documentation somewhere about how to turn on/off complier flags in cmdstanpy? At the stage, I want to explore if change turning on/off CXXFLGAS += -march=native -mtune=native or using ext…

---

## [Posterior distributions in hierarchical model problems](https://discourse.mc-stan.org/t/posterior-distributions-in-hierarchical-model-problems/34013)

<div class="topic-metadata">

**Author:** [@Simon\_Smith](https://discourse.mc-stan.org/u/Simon_Smith)\
**Replies:** 6\
**Last updated:** [February 5, 2024, 3:00pm UTC](https://discourse.mc-stan.org/t/posterior-distributions-in-hierarchical-model-problems/34013 "2024-02-05T15:00:19Z")

</div>

Hi community, I have created a hierarchical / multi-level model using cmdstanpy and Stan, but I am seeing some behaviours in my posterior chains which don’t seem quite right. In the attached plot, the E\_\\sigma and V$\_\\s…

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