# \#rstan

**URL:** https://discourse.mc-stan.org/tag/rstan/8.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)

---

## [A "squashed" normal distribution](https://discourse.mc-stan.org/t/a-squashed-normal-distribution/41655)

<div class="topic-metadata">

**Author:** [@maxgotts](https://discourse.mc-stan.org/u/maxgotts)\
**Replies:** 10\
**Last updated:** [November 2, 2026, 6:44am UTC](https://discourse.mc-stan.org/t/a-squashed-normal-distribution/41655 "2026-11-02T06:44:11Z")

</div>

I often find myself trying to fit a normal distribution that is skewed. Not a “skewed normal distribution,” but a normal distribution with one side cut to nearly zero. I’ve even gone as far as trying to make a custom log…

---

## [How to handle divergent chains in Stan mixture models](https://discourse.mc-stan.org/t/how-to-handle-divergent-chains-in-stan-mixture-models/41598)

<div class="topic-metadata">

**Author:** [@digikar](https://discourse.mc-stan.org/u/digikar)\
**Replies:** 5\
**Last updated:** [October 12, 2026, 7:20pm UTC](https://discourse.mc-stan.org/t/how-to-handle-divergent-chains-in-stan-mixture-models/41598 "2026-10-12T19:20:05Z")

</div>

Hello, I want to use a mixture model to decide whether my data is better explained by two components or by a single component. For example, let me take (simulated) data to be the following. The model behaves well (Reff …

---

## [Keep getting infinite gradient although likelihood is differentiable](https://discourse.mc-stan.org/t/keep-getting-infinite-gradient-although-likelihood-is-differentiable/41541)

<div class="topic-metadata">

**Author:** [@SeHellmann](https://discourse.mc-stan.org/u/SeHellmann)\
**Replies:** 8\
**Last updated:** [September 8, 2026, 8:28pm UTC](https://discourse.mc-stan.org/t/keep-getting-infinite-gradient-although-likelihood-is-differentiable/41541 "2026-09-08T20:28:57Z")

</div>

I am trying to fit a model to a couple (19) datasets. For 16 datasets, the model runs smoothly (no divergences, reasonable Rhat, and very good ESSs). But it seems, three datasets are a bit hard to estimate. I determined …

---

## [Complex indexing for missing covariates](https://discourse.mc-stan.org/t/complex-indexing-for-missing-covariates/41527)

<div class="topic-metadata">

**Author:** [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Replies:** 1\
**Last updated:** [August 19, 2026, 4:01pm UTC](https://discourse.mc-stan.org/t/complex-indexing-for-missing-covariates/41527 "2026-08-19T16:01:41Z")

</div>

I think this is a common enough question, but I am still having issues with it. I have a matrix of covariates \\mathbf{X} (no intercept) where some some observations i=1,2,\\ldots,N (rows) are missing for some covariates j…

---

## [Using Laplace approximation for logistic normal multinomial model](https://discourse.mc-stan.org/t/using-laplace-approximation-for-logistic-normal-multinomial-model/41305)

<div class="topic-metadata">

**Author:** [@Yingnan\_Gao](https://discourse.mc-stan.org/u/Yingnan_Gao)\
**Replies:** 15\
**Last updated:** [July 14, 2026, 6:11pm UTC](https://discourse.mc-stan.org/t/using-laplace-approximation-for-logistic-normal-multinomial-model/41305 "2026-07-14T18:11:36Z")

</div>

Hello Stan community, I posted a thread regarding some difficult geometries I encountered for fitting logistic normal multinomial model with explicit latent residuals (so that the likelihood can be evaluated for observe…

---

## ["get\_prior() shows only one group random intercept prior when using gr(by = ...), shouldn't there be two as this model assumes groups being drawn from separate distributions?"](https://discourse.mc-stan.org/t/get-prior-shows-only-one-group-random-intercept-prior-when-using-gr-by-shouldnt-there-be-two-as-this-model-assumes-groups-being-drawn-from-separate-distributions/41428)

<div class="topic-metadata">

**Author:** [@hunter\_warick](https://discourse.mc-stan.org/u/hunter_warick)\
**Replies:** 0\
**Last updated:** [July 8, 2026, 7:53am UTC](https://discourse.mc-stan.org/t/get-prior-shows-only-one-group-random-intercept-prior-when-using-gr-by-shouldnt-there-be-two-as-this-model-assumes-groups-being-drawn-from-separate-distributions/41428 "2026-07-08T07:53:22Z")

</div>

Short summary of the problem brm.formula.1 \<- bf( y ~ 0 + group+ # Group-specific independent random intercepts (1 | gr(ID, by = group)), sigma ~ 0 + group ) prior\_1 \<- # coefficients prior(normal(l…

---

## [How to handle high Pareto k when observations are meaningful?](https://discourse.mc-stan.org/t/how-to-handle-high-pareto-k-when-observations-are-meaningful/41368)

<div class="topic-metadata">

**Author:** [@cMiIIer](https://discourse.mc-stan.org/u/cMiIIer)\
**Replies:** 8\
**Last updated:** [June 18, 2026, 8:49pm UTC](https://discourse.mc-stan.org/t/how-to-handle-high-pareto-k-when-observations-are-meaningful/41368 "2026-06-18T20:49:34Z")

</div>

Hello, I am attempting to fit discrete time event models to some frog tadpole metamorphosis data. I have been able to successfully fit the model, but LOO for model comparisons demonstrate high pareto K values for rough…

---

## [Resolving difficult geometry in logistic normal multinomial model](https://discourse.mc-stan.org/t/resolving-difficult-geometry-in-logistic-normal-multinomial-model/41296)

<div class="topic-metadata">

**Author:** [@Yingnan\_Gao](https://discourse.mc-stan.org/u/Yingnan_Gao)\
**Replies:** 2\
**Last updated:** [June 7, 2026, 2:02am UTC](https://discourse.mc-stan.org/t/resolving-difficult-geometry-in-logistic-normal-multinomial-model/41296 "2026-06-07T02:02:45Z")

</div>

Hello all, I have been benchmarking a logistic normal multinomial model with an arbitrary correlation matrix as a parameter. I simulated some data following the logistic normal multinomial model and I fitted the simulate…

---

## [A faster implementation of hierarchical models](https://discourse.mc-stan.org/t/a-faster-implementation-of-hierarchical-models/41120)

<div class="topic-metadata">

**Author:** [@Rick\_RS95](https://discourse.mc-stan.org/u/Rick_RS95)\
**Replies:** 22\
**Last updated:** [May 20, 2026, 11:34am UTC](https://discourse.mc-stan.org/t/a-faster-implementation-of-hierarchical-models/41120 "2026-05-20T11:34:22Z")

</div>

Hi all! I am sure many of you know useful tricks to make hierarchical models fit faster. I have been trying different things for a while, and I would like to share a specification that is very fast and that, as far as I…

---

## [Rstan process on remote desktop stops when I'm disconnected](https://discourse.mc-stan.org/t/rstan-process-on-remote-desktop-stops-when-im-disconnected/41215)

<div class="topic-metadata">

**Author:** [@bugay-yildirim](https://discourse.mc-stan.org/u/bugay-yildirim)\
**Replies:** 6\
**Last updated:** [May 20, 2026, 7:24am UTC](https://discourse.mc-stan.org/t/rstan-process-on-remote-desktop-stops-when-im-disconnected/41215 "2026-05-20T07:24:22Z")

</div>

Hello everyone, I am running a model using rstan in RStudio on a remote Windows laptop that is connected to my university’s server. I access it from my local computer using Windows Remote Desktop Connection (RDP) over m…

---

## [Bayesian Causal Networks in R – Online Course (Sept 2026)](https://discourse.mc-stan.org/t/bayesian-causal-networks-in-r-online-course-sept-2026/41091)

<div class="topic-metadata">

**Author:** [@Carlo\_Pecoraro](https://discourse.mc-stan.org/u/Carlo_Pecoraro)\
**Replies:** 0\
**Last updated:** [April 30, 2026, 4:57pm UTC](https://discourse.mc-stan.org/t/bayesian-causal-networks-in-r-online-course-sept-2026/41091 "2026-04-30T16:57:49Z")

</div>

Bayesian Causal Networks in R 7–11 September 2026 Online (live sessions + recordings for global participation) Bayesian causal networks (Bayesian belief networks) are probabilistic graphical models used to represent co…

---

## [Short Course: Introduction to Bayesian Inference and Modelling](https://discourse.mc-stan.org/t/short-course-introduction-to-bayesian-inference-and-modelling/41088)

<div class="topic-metadata">

**Author:** [@UCLPG-MSC-SGDS](https://discourse.mc-stan.org/u/UCLPG-MSC-SGDS)\
**Replies:** 0\
**Last updated:** [April 30, 2026, 11:57am UTC](https://discourse.mc-stan.org/t/short-course-introduction-to-bayesian-inference-and-modelling/41088 "2026-04-30T11:57:45Z")

</div>

Hi everyone, I hope this message finds you well. I want to share that I will be running an introductory course on Bayesian Inference and Modelling in Stan. It will be a 4-day in-person programme designed for academics …

---

## [Timeline for Rstan update on CRAN](https://discourse.mc-stan.org/t/timeline-for-rstan-update-on-cran/41038)

<div class="topic-metadata">

**Author:** [@novice](https://discourse.mc-stan.org/u/novice)\
**Replies:** 5\
**Last updated:** [April 28, 2026, 9:01am UTC](https://discourse.mc-stan.org/t/timeline-for-rstan-update-on-cran/41038 "2026-04-28T09:01:39Z")

</div>

I’m writing an R package that relies on Rstan and plan to put it on CRAN once an accompanying article has been published. I want use some functionality from Stan 2.36 (sum-to-zero-vectors), but CRAN is still at Rstan ver…

---

## [How many divergence can we tolerate?](https://discourse.mc-stan.org/t/how-many-divergence-can-we-tolerate/41026)

<div class="topic-metadata">

**Author:** [@qize\_li](https://discourse.mc-stan.org/u/qize_li)\
**Replies:** 5\
**Last updated:** [April 24, 2026, 8:04pm UTC](https://discourse.mc-stan.org/t/how-many-divergence-can-we-tolerate/41026 "2026-04-24T20:04:59Z")

</div>

When I built the model, I encountered one or two divergences after running it. I made modifications, but one or two divergences still occasionally appear, especially when I calculate the power multiple times. I want to k…

---

## [Log Likelihood for Structural Equation Modeles](https://discourse.mc-stan.org/t/log-likelihood-for-structural-equation-modeles/41050)

<div class="topic-metadata">

**Author:** [@cMiIIer](https://discourse.mc-stan.org/u/cMiIIer)\
**Replies:** 2\
**Last updated:** [April 21, 2026, 8:24pm UTC](https://discourse.mc-stan.org/t/log-likelihood-for-structural-equation-modeles/41050 "2026-04-21T20:24:26Z")

</div>

Hello! I am working on a Dynamic Structural Equation model and I am having trouble generating log likelihood values for model comparisons. I am new to SEM in Stan and I am lost about how to proceed, I tried doing multid…

---

## [Copula regression example (gaussian & poisson)](https://discourse.mc-stan.org/t/copula-regression-example-gaussian-poisson/35071)

<div class="topic-metadata">

**Author:** [@Greg94](https://discourse.mc-stan.org/u/Greg94)\
**Replies:** 20\
**Last updated:** [April 13, 2026, 9:48am UTC](https://discourse.mc-stan.org/t/copula-regression-example-gaussian-poisson/35071 "2026-04-13T09:48:32Z")

</div>

Hi This is a question about copulas in Stan. I am trying to estimate a copula model which introduces some correlation between a Gaussian and a Poisson regression. This is my data generating process: library(MASS) s\_siz…

---

## [Pkgbuild::compile\_dll() on previously working rstantools-based package fails with "file too big" error](https://discourse.mc-stan.org/t/pkgbuild-compile-dll-on-previously-working-rstantools-based-package-fails-with-file-too-big-error/21938)

<div class="topic-metadata">

**Author:** [@ebuhle](https://discourse.mc-stan.org/u/ebuhle)\
**Replies:** 27\
**Last updated:** [April 5, 2026, 11:00am UTC](https://discourse.mc-stan.org/t/pkgbuild-compile-dll-on-previously-working-rstantools-based-package-fails-with-file-too-big-error/21938 "2026-04-05T11:00:38Z")

</div>

I’m encountering a new (to me) problem when trying to compile my Stan-dependent packages built with rstantools in RStudio. My workflow, following the vignette, has been: pkgbuild::compile\_dll() roxygen2::roxygenize() de…

---

## [Using Hierarchical mean estimates as predictors](https://discourse.mc-stan.org/t/using-hierarchical-mean-estimates-as-predictors/40969)

<div class="topic-metadata">

**Author:** [@E\_michels](https://discourse.mc-stan.org/u/E_michels)\
**Replies:** 8\
**Last updated:** [March 25, 2026, 4:19am UTC](https://discourse.mc-stan.org/t/using-hierarchical-mean-estimates-as-predictors/40969 "2026-03-25T04:19:37Z")

</div>

Hi everyone, I’m trying to build a model that propagates uncertainty across several linked components (possibly something like a Bayesian path model / SEM). Below is a simplified version of the full model, which is beha…

---

## [Gaussian Process with measurement uncertainty and a large number of observations](https://discourse.mc-stan.org/t/gaussian-process-with-measurement-uncertainty-and-a-large-number-of-observations/40949)

<div class="topic-metadata">

**Author:** [@roberto\_r](https://discourse.mc-stan.org/u/roberto_r)\
**Replies:** 15\
**Last updated:** [March 16, 2026, 10:13am UTC](https://discourse.mc-stan.org/t/gaussian-process-with-measurement-uncertainty-and-a-large-number-of-observations/40949 "2026-03-16T10:13:07Z")

</div>

Hello all, I am trying to fit a GP model where I cannot observe time directly but I know the event happened at some point between a start date and an end date. At this stage there is no way to know the duration of the e…

---

## [Question: Diagnostic status used in both interaction and derived predictor — better to use split models?](https://discourse.mc-stan.org/t/question-diagnostic-status-used-in-both-interaction-and-derived-predictor-better-to-use-split-models/39831)

<div class="topic-metadata">

**Author:** [@Felix\_Requena](https://discourse.mc-stan.org/u/Felix_Requena)\
**Replies:** 2\
**Last updated:** [February 22, 2026, 12:34am UTC](https://discourse.mc-stan.org/t/question-diagnostic-status-used-in-both-interaction-and-derived-predictor-better-to-use-split-models/39831 "2026-02-22T00:34:46Z")

</div>

Hi all, I’m working on a brms model analyzing social behavior (Gregariousness, binary outcome) in a population of reptiles. Two key predictors of interest are: Disease status of the focal individual (Diagnostic: Healt…

---

## [Ornstein–Uhlenbeck correlation structure in brms](https://discourse.mc-stan.org/t/ornstein-uhlenbeck-correlation-structure-in-brms/40889)

<div class="topic-metadata">

**Author:** [@Hunter24](https://discourse.mc-stan.org/u/Hunter24)\
**Replies:** 6\
**Last updated:** [February 20, 2026, 10:09am UTC](https://discourse.mc-stan.org/t/ornstein-uhlenbeck-correlation-structure-in-brms/40889 "2026-02-20T10:09:09Z")

</div>

Hi, I am wondering how to implement Ornstein–Uhlenbeck correlation structure in brms. This is how I am doing it, but not entirely sure if accurate:(fit.ou.brms ← brm(y ~ X1 + X2 + X3 + gp(times, cov = “matern12”), dat…

---

## [How can I found the appropriate family to fit my data using brms?](https://discourse.mc-stan.org/t/how-can-i-found-the-appropriate-family-to-fit-my-data-using-brms/40919)

<div class="topic-metadata">

**Author:** [@dmaria](https://discourse.mc-stan.org/u/dmaria)\
**Replies:** 1\
**Last updated:** [February 11, 2026, 7:13pm UTC](https://discourse.mc-stan.org/t/how-can-i-found-the-appropriate-family-to-fit-my-data-using-brms/40919 "2026-02-11T19:13:13Z")

</div>

Hello, everyone. I have a set of data from dose-response effect (without saturation point), but I don’t know how to fit it with appropriate family. I have values that follows a log distribution, however, there are some …

---

## [Divergent transitions and low ESS in Bessel Regression using real data](https://discourse.mc-stan.org/t/divergent-transitions-and-low-ess-in-bessel-regression-using-real-data/40914)

<div class="topic-metadata">

**Author:** [@Joao\_Marcos](https://discourse.mc-stan.org/u/Joao_Marcos)\
**Replies:** 1\
**Last updated:** [February 10, 2026, 7:50pm UTC](https://discourse.mc-stan.org/t/divergent-transitions-and-low-ess-in-bessel-regression-using-real-data/40914 "2026-02-10T19:50:17Z")

</div>

Hello! I am utilizing Bessel Regression to model mean essay scores from a standardized exam across various Brazilian municipalities. The response variable is bounded between 0 and 1, and my covariates are municipal indic…

---

## [Is there a way to accelerate this BetaBinomial and DirichletMultinomial model?](https://discourse.mc-stan.org/t/is-there-a-way-to-accelerate-this-betabinomial-and-dirichletmultinomial-model/40755)

<div class="topic-metadata">

**Author:** [@Amns](https://discourse.mc-stan.org/u/Amns)\
**Replies:** 3\
**Last updated:** [February 6, 2026, 8:59pm UTC](https://discourse.mc-stan.org/t/is-there-a-way-to-accelerate-this-betabinomial-and-dirichletmultinomial-model/40755 "2026-02-06T20:59:22Z")

</div>

I created the following .stan file called model\_tree. In essense it fits a BetaBinomial distribution when there are two categories, and a DirichletMultinomial when there are four categories. All the data that I provide a…

---

## [Mechanistic model with stochastic forcing](https://discourse.mc-stan.org/t/mechanistic-model-with-stochastic-forcing/40869)

<div class="topic-metadata">

**Author:** [@Idowu](https://discourse.mc-stan.org/u/Idowu)\
**Replies:** 1\
**Last updated:** [February 4, 2026, 10:45pm UTC](https://discourse.mc-stan.org/t/mechanistic-model-with-stochastic-forcing/40869 "2026-02-04T22:45:22Z")

</div>

I am working on an ODE-based mechanistic model of malaria transmission dynamics. It is necessary for me to introduce a forcing function into the force of infection, which is the product of a sinusoidal function and a non…

---

## [Is it reasonable to model subject-level residual SD non-hierarchically in a hierarchical Stan model?](https://discourse.mc-stan.org/t/is-it-reasonable-to-model-subject-level-residual-sd-non-hierarchically-in-a-hierarchical-stan-model/40796)

<div class="topic-metadata">

**Author:** [@Fernando](https://discourse.mc-stan.org/u/Fernando)\
**Replies:** 4\
**Last updated:** [January 13, 2026, 6:29pm UTC](https://discourse.mc-stan.org/t/is-it-reasonable-to-model-subject-level-residual-sd-non-hierarchically-in-a-hierarchical-stan-model/40796 "2026-01-13T18:29:56Z")

</div>

Hello fellow stan users! I am doing a hierarchical analysis of behavioral data (mouse behavior) with 3 levels: individual, group and population. The model requires to estimate 2 parameters (U and S) modeled in log and l…

---

## [Error when converting cmdstanr output to stanfit with rstan::read\_stan\_csv and the latest versions of the packages](https://discourse.mc-stan.org/t/error-when-converting-cmdstanr-output-to-stanfit-with-rstan-read-stan-csv-and-the-latest-versions-of-the-packages/40613)

<div class="topic-metadata">

**Author:** [@GabrielR](https://discourse.mc-stan.org/u/GabrielR)\
**Replies:** 5\
**Last updated:** [December 28, 2025, 6:03pm UTC](https://discourse.mc-stan.org/t/error-when-converting-cmdstanr-output-to-stanfit-with-rstan-read-stan-csv-and-the-latest-versions-of-the-packages/40613 "2025-12-28T18:03:40Z")

</div>

Hi, When I try to convert my cmdstanr output to a stanfit object using the latest versions of cmdstanr and rstan, I get the following error: mod \<- cmdstan\_model("stancode\_longi\_gp\_v2.stan") fit \<- mod$sample( data …

---

## [Code optimization & reduce\_sum](https://discourse.mc-stan.org/t/code-optimization-reduce-sum/40752)

<div class="topic-metadata">

**Author:** [@Sheeta27](https://discourse.mc-stan.org/u/Sheeta27)\
**Replies:** 2\
**Last updated:** [December 18, 2025, 6:09pm UTC](https://discourse.mc-stan.org/t/code-optimization-reduce-sum/40752 "2025-12-18T18:09:05Z")

</div>

Hi Stan users! I’m modeling hierarchical tumor size measurements with the structure: measurement over time in tumor in organ in patient in study. I have about 150 000 measurements from 30,000 tumors across 22 studies. I…

---

## [RStan performance differences](https://discourse.mc-stan.org/t/rstan-performance-differences/40684)

<div class="topic-metadata">

**Author:** [@AEman](https://discourse.mc-stan.org/u/AEman)\
**Replies:** 1\
**Last updated:** [December 1, 2025, 11:34am UTC](https://discourse.mc-stan.org/t/rstan-performance-differences/40684 "2025-12-01T11:34:06Z")

</div>

I am switching from one linux HPC system to another. I have noticed a big difference in performance with similar hardware. I was wondering whether it has something to do with compiler flags, could you let me know if it s…

---

## [Taking the maximum of a vector (with uncertainty), or (equally) detecting locations of deviation from a normal distribution](https://discourse.mc-stan.org/t/taking-the-maximum-of-a-vector-with-uncertainty-or-equally-detecting-locations-of-deviation-from-a-normal-distribution/40665)

<div class="topic-metadata">

**Author:** [@maxgotts](https://discourse.mc-stan.org/u/maxgotts)\
**Replies:** 8\
**Last updated:** [November 24, 2025, 11:46am UTC](https://discourse.mc-stan.org/t/taking-the-maximum-of-a-vector-with-uncertainty-or-equally-detecting-locations-of-deviation-from-a-normal-distribution/40665 "2025-11-24T11:46:00Z")

</div>

Hi Stan folks, I have a model where I’m trying to do a regression on the maximum value of a set of vectors. That is, there are 36 birds, each with a set of song pitches, and I want to look at the maximum song pitch for …

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