# \#initialization

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

---

## [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 …

---

## [Initial value different from specified initial value](https://discourse.mc-stan.org/t/initial-value-different-from-specified-initial-value/40279)

<div class="topic-metadata">

**Author:** [@buf](https://discourse.mc-stan.org/u/buf)\
**Replies:** 3\
**Last updated:** [August 25, 2025, 6:03pm UTC](https://discourse.mc-stan.org/t/initial-value-different-from-specified-initial-value/40279 "2025-08-25T18:03:03Z")

</div>

Hi everyone, I am trying to understand the ‘initial values’ in one of my models. I specify some initial values, and they are recognized by Stan, as can be seen in the first screenshot: Now, when I look into the samp…

---

## [Init not using my initial values and seems to be defaulting to 0](https://discourse.mc-stan.org/t/init-not-using-my-initial-values-and-seems-to-be-defaulting-to-0/39548)

<div class="topic-metadata">

**Author:** [@thomas\_null](https://discourse.mc-stan.org/u/thomas_null)\
**Replies:** 3\
**Last updated:** [May 22, 2025, 1:19am UTC](https://discourse.mc-stan.org/t/init-not-using-my-initial-values-and-seems-to-be-defaulting-to-0/39548 "2025-05-22T01:19:49Z")

</div>

I am having difficulties setting up init for fitting a nonlinear dataset. Here is a synthetic dataset. library(tidyverse) library(brms) library(ggmcmc) set.seed(1) # synthetic Roche data Time \<- c(0, 2.1, 4.5, 6.5) #…

---

## [Diffusion model initialization issue using brms](https://discourse.mc-stan.org/t/diffusion-model-initialization-issue-using-brms/33682)

<div class="topic-metadata">

**Author:** [@chenshuai](https://discourse.mc-stan.org/u/chenshuai)\
**Replies:** 6\
**Last updated:** [May 6, 2025, 4:48pm UTC](https://discourse.mc-stan.org/t/diffusion-model-initialization-issue-using-brms/33682 "2025-05-06T16:48:59Z")

</div>

Dear all, I am trying to estimate the drift rate in a task-switching paradigm. In my experiment, which is a two-by-two design, I am exploring two stimulus types(“congruent” vs “incongruent”) and two task types (“repeat…

---

## [Negative Binomial model won't optimize dispersion parameter](https://discourse.mc-stan.org/t/negative-binomial-model-wont-optimize-dispersion-parameter/39039)

<div class="topic-metadata">

**Author:** [@Benjamin\_Kambs](https://discourse.mc-stan.org/u/Benjamin_Kambs)\
**Replies:** 3\
**Last updated:** [March 13, 2025, 9:42am UTC](https://discourse.mc-stan.org/t/negative-binomial-model-wont-optimize-dispersion-parameter/39039 "2025-03-13T09:42:04Z")

</div>

Hi there! TL;DR I am using MLE to optimize the parameters of a Negative-binomial-2-log generalized linear model. It seems the optimizer is not able to optimize the dispersion parameter \\Phi. The result basically always…

---

## [Can I provide explicit init values for the optimize method?](https://discourse.mc-stan.org/t/can-i-provide-explicit-init-values-for-the-optimize-method/37706)

<div class="topic-metadata">

**Author:** [@jachymb](https://discourse.mc-stan.org/u/jachymb)\
**Replies:** 1\
**Last updated:** [December 20, 2024, 3:18pm UTC](https://discourse.mc-stan.org/t/can-i-provide-explicit-init-values-for-the-optimize-method/37706 "2024-12-20T15:18:56Z")

</div>

Can I (how?) provide initial values for STAN for the optimize methods? The init parameter of the optimize method can be set to a number x which is a range (-x, x). The init parameter of the sample method can be set to a …

---

## [Gompertz distribution cdf under-/overflow](https://discourse.mc-stan.org/t/gompertz-distribution-cdf-under-overflow/36686)

<div class="topic-metadata">

**Author:** [@fredh](https://discourse.mc-stan.org/u/fredh)\
**Replies:** 7\
**Last updated:** [October 11, 2024, 10:12pm UTC](https://discourse.mc-stan.org/t/gompertz-distribution-cdf-under-overflow/36686 "2024-10-11T22:12:55Z")

</div>

Hi, I am trying to write custom functions for the \_cdf/\_lcdf for the gompertz distribtion Wikipedia I have been successful with other standard parametric survival functions which are either implemented already or by cu…

---

## [Help with Bayesian Modelling](https://discourse.mc-stan.org/t/help-with-bayesian-modelling/35668)

<div class="topic-metadata">

**Author:** [@Patrick\_O\_Rourke](https://discourse.mc-stan.org/u/Patrick_O_Rourke)\
**Replies:** 6\
**Last updated:** [July 4, 2024, 9:26pm UTC](https://discourse.mc-stan.org/t/help-with-bayesian-modelling/35668 "2024-07-04T21:26:00Z")

</div>

I am currently working on my postgraduate dissertation in statistics and I am using STAN extensively for this. My dissertation involves simulating a latent position model of chess games which estimates the ratings of the…

---

## [Failed to Initialize Error (Log Probability Evaluates to Negative Infinity log(0))](https://discourse.mc-stan.org/t/failed-to-initialize-error-log-probability-evaluates-to-negative-infinity-log-0/34386)

<div class="topic-metadata">

**Author:** [@skylerjove20](https://discourse.mc-stan.org/u/skylerjove20)\
**Replies:** 7\
**Last updated:** [April 26, 2024, 9:05am UTC](https://discourse.mc-stan.org/t/failed-to-initialize-error-log-probability-evaluates-to-negative-infinity-log-0/34386 "2024-04-26T09:05:59Z")

</div>

Hoping to get some help understanding the source of this zero probability error. My model is relatively straightforward after understanding the purpose of my user-defined function. findx() takes two variable values (1)…

---

## [Multivariate ODE initialization issues](https://discourse.mc-stan.org/t/multivariate-ode-initialization-issues/34219)

<div class="topic-metadata">

**Author:** [@jimjunker1](https://discourse.mc-stan.org/u/jimjunker1)\
**Replies:** 5\
**Last updated:** [March 27, 2024, 8:00pm UTC](https://discourse.mc-stan.org/t/multivariate-ode-initialization-issues/34219 "2024-03-27T20:00:36Z")

</div>

I am new to coding models directly in STAN and this also happens to be my first attempt at fitting an ODE model using it. I am having a few issues with the model initialization and have not been able to gather from the f…

---

## [Brms initialization changing found vs declared dimension](https://discourse.mc-stan.org/t/brms-initialization-changing-found-vs-declared-dimension/32267)

<div class="topic-metadata">

**Author:** [@jsumner](https://discourse.mc-stan.org/u/jsumner)\
**Replies:** 4\
**Last updated:** [July 29, 2023, 7:07pm UTC](https://discourse.mc-stan.org/t/brms-initialization-changing-found-vs-declared-dimension/32267 "2023-07-29T19:07:06Z")

</div>

Hello, I had to reinstall ubuntu (22.04) yesterday and with it I installed R (4.1.2) , brms (2.19.0), and moved to the new cmdstanr (0.6.0). Since those updates I have been having trouble with models that were working …

---

## [Initial values for Weibull survival model with brms](https://discourse.mc-stan.org/t/initial-values-for-weibull-survival-model-with-brms/31183)

<div class="topic-metadata">

**Author:** [@Bjoern](https://discourse.mc-stan.org/u/Bjoern)\
**Replies:** 3\
**Last updated:** [May 8, 2023, 4:46am UTC](https://discourse.mc-stan.org/t/initial-values-for-weibull-survival-model-with-brms/31183 "2023-05-08T04:46:33Z")

</div>

When trying something out on the colon dataset from the R survival package, I ran into trouble with initialization for a simple Weibull model. A-priori I expect the intercept to be about 7.5 or so (\\approx log(5\*365.25 d…

---

## [Initialize MCMC with draws from variational inference in cmdstanr](https://discourse.mc-stan.org/t/initialize-mcmc-with-draws-from-variational-inference-in-cmdstanr/31075)

<div class="topic-metadata">

**Author:** [@afranks](https://discourse.mc-stan.org/u/afranks)\
**Replies:** 4\
**Last updated:** [April 17, 2023, 6:44pm UTC](https://discourse.mc-stan.org/t/initialize-mcmc-with-draws-from-variational-inference-in-cmdstanr/31075 "2023-04-17T18:44:18Z")

</div>

I’m using cmdstanr and I want to initialize 4 chains of my MCMC with draws (or maybe means) from my variational approximation. There is a nice page on how to do this with cmdstanPy, but I surprisingly can’t find anythin…

---

## [General Error (make cmd and error in compile code](https://discourse.mc-stan.org/t/general-error-make-cmd-and-error-in-compile-code/30634)

<div class="topic-metadata">

**Author:** [@Laura\_Garcia\_Diaz](https://discourse.mc-stan.org/u/Laura_Garcia_Diaz)\
**Replies:** 1\
**Last updated:** [March 6, 2023, 10:54am UTC](https://discourse.mc-stan.org/t/general-error-make-cmd-and-error-in-compile-code/30634 "2023-03-06T10:54:36Z")

</div>

Hi, I’m new at using Stan and R, I have tried several solutions pertaining the different parts of the error alert R tells me but none of them seem to work. I don’t understand what the problem is because it happens whethe…

---

## [Setting initial values does not seem to correspond with actually observed initial draws](https://discourse.mc-stan.org/t/setting-initial-values-does-not-seem-to-correspond-with-actually-observed-initial-draws/30618)

<div class="topic-metadata">

**Author:** [@bmfazio](https://discourse.mc-stan.org/u/bmfazio)\
**Replies:** 2\
**Last updated:** [March 5, 2023, 12:04pm UTC](https://discourse.mc-stan.org/t/setting-initial-values-does-not-seem-to-correspond-with-actually-observed-initial-draws/30618 "2023-03-05T12:04:09Z")

</div>

Hi all, I would like to set inits for some parameters, but when I look at the value of the very first draw, it does not seem to bear any relation to the value I set the inits to. Perhaps I’m missing something about the w…

---

## [Initial value error (log(0)) for user defined beta prior distribution in hierarchical generalized extreme value (GEV) distribution](https://discourse.mc-stan.org/t/initial-value-error-log-0-for-user-defined-beta-prior-distribution-in-hierarchical-generalized-extreme-value-gev-distribution/29976)

<div class="topic-metadata">

**Author:** [@Alex\_Lee](https://discourse.mc-stan.org/u/Alex_Lee)\
**Replies:** 1\
**Last updated:** [January 11, 2023, 8:42pm UTC](https://discourse.mc-stan.org/t/initial-value-error-log-0-for-user-defined-beta-prior-distribution-in-hierarchical-generalized-extreme-value-gev-distribution/29976 "2023-01-11T20:42:47Z")

</div>

\[edit: formatted Stan code\] I have a user defined Beta distribution. Beta(\\theta+0.5|p,q) = (0.5 + \\theta)^{p-1} (0.5 - \\theta)^{q-1} / B(p,q) between \[-0.5,0.5\] where B(p,q) = \\Gamma(p) \\Gamma(q) / \\Gamma(p+q) real …

---

## [Initial value error (log(0)) for user defined beta prior distribution in hierarchical generalized extreme value (GEV) distribution](https://discourse.mc-stan.org/t/initial-value-error-log-0-for-user-defined-beta-prior-distribution-in-hierarchical-generalized-extreme-value-gev-distribution/29967)

<div class="topic-metadata">

**Author:** [@Alex\_Lee](https://discourse.mc-stan.org/u/Alex_Lee)\
**Replies:** 6\
**Last updated:** [January 10, 2023, 1:06pm UTC](https://discourse.mc-stan.org/t/initial-value-error-log-0-for-user-defined-beta-prior-distribution-in-hierarchical-generalized-extreme-value-gev-distribution/29967 "2023-01-10T13:06:37Z")

</div>

I have a user defined Beta distribution. Beta(\\theta+0.5|p,q) = (0.5 + \\theta)^{p-1} (0.5 - \\theta)^{q-1} / B(p,q) between \[-0.5,0.5\] where B(p,q) = \\Gamma(p) \\Gamma(q) / \\Gamma(p+q) real mbeta\_lpdf(real theta, real p…

---

## [Initilization with dispersion around a good guess](https://discourse.mc-stan.org/t/initilization-with-dispersion-around-a-good-guess/29950)

<div class="topic-metadata">

**Author:** [@tomli](https://discourse.mc-stan.org/u/tomli)\
**Replies:** 1\
**Last updated:** [January 9, 2023, 7:26pm UTC](https://discourse.mc-stan.org/t/initilization-with-dispersion-around-a-good-guess/29950 "2023-01-09T19:26:08Z")

</div>

I am working on a model of high dimensionality (a hierarchical model with ~50000 parameters at the lowest level). Initializing with Stan’s default (uniform \[-2,2\]) causes numerical problems. Seeding with random draws fro…

---

## [Gamma model rejecting initial value](https://discourse.mc-stan.org/t/gamma-model-rejecting-initial-value/28176)

<div class="topic-metadata">

**Author:** [@tcerto](https://discourse.mc-stan.org/u/tcerto)\
**Replies:** 2\
**Last updated:** [July 14, 2022, 1:52am UTC](https://discourse.mc-stan.org/t/gamma-model-rejecting-initial-value/28176 "2022-07-14T01:52:58Z")

</div>

I am trying to fit models using the Gamma family in brms for the first time. My dv is greater than zero and very skewed. I am using the following code: b1 ← brm(total\_sec ~ mat + mcat, data = data2, chains=2, family =…

---

## [Discontinuous likelihood and initialization failure](https://discourse.mc-stan.org/t/discontinuous-likelihood-and-initialization-failure/28106)

<div class="topic-metadata">

**Author:** [@Daniel\_R](https://discourse.mc-stan.org/u/Daniel_R)\
**Replies:** 4\
**Last updated:** [July 7, 2022, 1:56pm UTC](https://discourse.mc-stan.org/t/discontinuous-likelihood-and-initialization-failure/28106 "2022-07-07T13:56:01Z")

</div>

Hello there. I am a Stan newbie. I am trying to run a model where my likelihood is discontinuous and the discontinuity is given by a regression curve so it does depend on my parameter of interest. Say that, Y=g(\\beta, …

---

## [Pystan runtime error: initialization failed](https://discourse.mc-stan.org/t/pystan-runtime-error-initialization-failed/27635)

<div class="topic-metadata">

**Author:** [@LongPham](https://discourse.mc-stan.org/u/LongPham)\
**Replies:** 2\
**Last updated:** [May 26, 2022, 8:12pm UTC](https://discourse.mc-stan.org/t/pystan-runtime-error-initialization-failed/27635 "2022-05-26T20:12:29Z")

</div>

The following Python+Stan code is analogous to Bayesian linear regression, except that the code infers a linear function that bounds ys. import stan stan\_code = """ data { int\<lower=0\> number\_inputs; matrix\[num…

---

## [Rejecting initial value:](https://discourse.mc-stan.org/t/rejecting-initial-value/27191)

<div class="topic-metadata">

**Author:** [@chI-No](https://discourse.mc-stan.org/u/chI-No)\
**Replies:** 5\
**Last updated:** [April 21, 2022, 1:58pm UTC](https://discourse.mc-stan.org/t/rejecting-initial-value/27191 "2022-04-21T13:58:50Z")

</div>

Im trying to estimate some parameters (rc and tB0) for this model, but i dont know why RStan says that logprob is Nan, i did the same problem in emcee with no issues. Could you help me to see the error? Thank you so muc…

---

## [Unable to Initialize Large Correlation Matrix In PyStan](https://discourse.mc-stan.org/t/unable-to-initialize-large-correlation-matrix-in-pystan/26622)

<div class="topic-metadata">

**Author:** [@bgb](https://discourse.mc-stan.org/u/bgb)\
**Replies:** 1\
**Last updated:** [March 1, 2022, 8:05pm UTC](https://discourse.mc-stan.org/t/unable-to-initialize-large-correlation-matrix-in-pystan/26622 "2022-03-01T20:05:54Z")

</div>

I’m running into an issue when I try to run the following Stan model (pystan 3.3.0, python 3.8.8) with a fairly large correlation matrix (J = 100); when I subset down my data such that the correlation matrix is smaller (…

---

## [Initialisation issues when using student-t for hierarchical priors](https://discourse.mc-stan.org/t/initialisation-issues-when-using-student-t-for-hierarchical-priors/24516)

<div class="topic-metadata">

**Author:** [@jobi](https://discourse.mc-stan.org/u/jobi)\
**Replies:** 4\
**Last updated:** [October 4, 2021, 5:10am UTC](https://discourse.mc-stan.org/t/initialisation-issues-when-using-student-t-for-hierarchical-priors/24516 "2021-10-04T05:10:13Z")

</div>

I am trying to set hierarchical priors in my brms model. I am following the approach described by @wpetry here and @paul.buerkner here. However, instead of a normal distribution, I want to use a student-t distribution. T…

---

## [Setting initial values causing segmentation fault](https://discourse.mc-stan.org/t/setting-initial-values-causing-segmentation-fault/23835)

<div class="topic-metadata">

**Author:** [@marcusdoowyah](https://discourse.mc-stan.org/u/marcusdoowyah)\
**Replies:** 5\
**Last updated:** [August 9, 2021, 4:16pm UTC](https://discourse.mc-stan.org/t/setting-initial-values-causing-segmentation-fault/23835 "2021-08-09T16:16:59Z")

</div>

I am running a HMC sampling model to sample over a number of parameters based on a normal distribution with a predicted mean. The main prediction is done using the disp\_eq\_root\_par function (which works fine and has been…

---

## [RuntimeError: Initialization failed](https://discourse.mc-stan.org/t/runtimeerror-initialization-failed/23819)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.mc-stan.org/u/Sebastian_Mena)\
**Replies:** 3\
**Last updated:** [August 5, 2021, 4:54pm UTC](https://discourse.mc-stan.org/t/runtimeerror-initialization-failed/23819 "2021-08-05T16:54:27Z")

</div>

Greetings, everybody. Trying to model a probability of goal from a shot using a bernoulli logit model. I have a working implementation in PyStan in Jupyter Notebook, but the sampling isn’t run. This code trhow me an init…

---

## [Initialization failed for gp() using brms on cluster](https://discourse.mc-stan.org/t/initialization-failed-for-gp-using-brms-on-cluster/23201)

<div class="topic-metadata">

**Author:** [@Linum\_grandiflorum](https://discourse.mc-stan.org/u/Linum_grandiflorum)\
**Replies:** 1\
**Last updated:** [July 2, 2021, 8:48am UTC](https://discourse.mc-stan.org/t/initialization-failed-for-gp-using-brms-on-cluster/23201 "2021-07-02T08:48:49Z")

</div>

Dear all, I’m trying to analyze spatially non-independent data using the gp() function in brms following chapter 13.4.1 of Statistical Rethinking Recoded. I’m using my university’s HPCC to fit the models because they ar…

---

## [Initialization failed with truncated normal distribution](https://discourse.mc-stan.org/t/initialization-failed-with-truncated-normal-distribution/20501)

<div class="topic-metadata">

**Author:** [@lisa1](https://discourse.mc-stan.org/u/lisa1)\
**Replies:** 6\
**Last updated:** [March 16, 2021, 6:42pm UTC](https://discourse.mc-stan.org/t/initialization-failed-with-truncated-normal-distribution/20501 "2021-03-16T18:42:53Z")

</div>

Dear all, I would like to fit a model with a truncated normal distribution to my data. The data is from 50 subjects who on each trial do two ratings which go from 0 to 100 (including those values). I would like to trunc…
