# Sampled parameter dropping at the last iteration

**URL:** <https://discourse.mc-stan.org/t/sampled-parameter-dropping-at-the-last-iteration/5883>\
**Category:** Modeling\
**Created:** [October 5, 2018, 2:48am UTC](https://discourse.mc-stan.org/t/sampled-parameter-dropping-at-the-last-iteration/5883 "2018-10-05T02:48:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stemangiola](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stemangiola/32/260_2.png) [@stemangiola](https://discourse.mc-stan.org/u/stemangiola)\
**Post date:** [October 5, 2018, 2:48am UTC](https://discourse.mc-stan.org/t/sampled-parameter-dropping-at-the-last-iteration/5883/1 "2018-10-05T02:48:30Z")

</div>

I am wondering if there could be a generic cause of this sampling behaviour (that I have encountered in the past but I never wondered too much on) and/or could be indicative of some common pathology .

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/0/01a2c118a29bbbc9da2023433e4ca44a71c66d85.png)

Warning message

```R
Warning messages:
1: There were 3 chains where the estimated Bayesian Fraction of Missing Information was low. See
http://mc-stan.org/misc/warnings.html#bfmi-low 
2: Examine the pairs() plot to diagnose sampling problems

```

My model

```stan
data {
  int<lower=0> N;
  int<lower=0> G;
  int<lower=0> counts[N,G];
  real my_prior[2];
  int<lower=0, upper=1> omit_data;
}

parameters {

  // Overall properties of the data
  real lambda_mu;
  real<lower=0> lambda_sigma;
  real<lower=1> sigma;

  // Gene-wise properties of the data
  vector[G] lambda;

}
model {

  // Overall properties of the data
  lambda_mu ~ normal(0,1);
  lambda_sigma ~ cauchy(0,2);
  sigma ~ gamma(3,2);

  // Gene-wise properties of the data
  lambda ~ normal(lambda_mu, lambda_sigma);

  // Sample from data
  for(n in 1:N) counts[n,] ~ neg_binomial_2_log(lambda, sigma);

}
generated quantities{
  int<lower=0> counts_gen[N,G];
  vector[G] lambda_gen;

  // Sample gene wise rates
  for(g in 1:G) lambda_gen[g] = normal_rng(lambda_mu, lambda_sigma);

  // Sample gene wise sample wise abundances
  for(n in 1:N) for(g in 1:G) {
    counts_gen[n,g] = neg_binomial_2_log_rng(lambda_gen[g], sigma);
  }

}

```

---

<div class="post-metadata">

**Author:** ![stemangiola](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stemangiola/32/260_2.png) [@stemangiola](https://discourse.mc-stan.org/u/stemangiola)\
**Post date:** [October 5, 2018, 3:10am UTC](https://discourse.mc-stan.org/t/sampled-parameter-dropping-at-the-last-iteration/5883/2 "2018-10-05T03:10:01Z")

</div>

Using `1/sqrt(phi)` as the precision prior with negative binomial, as suggested in [https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations](https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations) I overcome such strange behaviour.

However the curiosity remains: how come sigma that is constrained \> 1 drops below 1 at the final stage of sampling.
