I am completely new to stan and am working on learning the language while attempting to fit a model for a research project. One distribution I need is a shifted Gamma Distribution. I have attempted to implement it using the custom distributions feature. However I consistently get the following message.

There were “N” divergent transitions after warmup. Increasing adapt_delta above 0.8 may help

I have increased the adapt_delta up to .99 and still get the same warning.

I suspect this has something to do with my definition of the log probability function. My guess is that since the log probability uses the shift parameter in it’s evaluation, sometimes the subtraction of the shift will make the generated values too small.

**Hence my question is…**

**1) Whether or not there is a better way to define a shifted distribution (gamma or otherwise)?**

**2) How much I should be worried about this. The estimates are still accurate but I plan on using this inside a state space model and am unsure as to the possible effects.**

I have attached R code that illustrates the stated problem. Thanks in advance for your help.shifted_gamma.R (1.2 KB)