# Chain Finishing Unexpectedly in High Dimension Hierarchical Model

**URL:** <https://discourse.mc-stan.org/t/chain-finishing-unexpectedly-in-high-dimension-hierarchical-model/34355>\
**Category:** Modeling\
**Tags:** cmdstanr\
**Created:** [March 5, 2024, 9:54pm UTC](https://discourse.mc-stan.org/t/chain-finishing-unexpectedly-in-high-dimension-hierarchical-model/34355 "2024-03-05T21:54:30Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![andre.pfeuffer](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@andre.pfeuffer](https://discourse.mc-stan.org/u/andre.pfeuffer)\
**Post date:** [March 7, 2024, 4:28am UTC](https://discourse.mc-stan.org/t/chain-finishing-unexpectedly-in-high-dimension-hierarchical-model/34355/5 "2024-03-07T04:28:40Z")

</div>

You could simply define:

```no-highlight
vector<lower=0>[1:nX_direct] beta_con; // intercept and slope hyper-priors constrained
vector[nX_direct:K] beta_uncon; // intercept and slope hyper-priors constrained

```

adding the following after the parameter block

```no-highlight
transformed parameters {
   vector[K] beta = append_row(beta_con, beta_uncon);
}

```

Although you use a `array[] vector` structure too.  
This will, if you go this road, require assignments in loop for each `1,.., N_pts`.

` beta_p_con ~ multi_normal_cholesky(beta_constrained, quad_form_diag(L_con, sigma_p_con)); // new corr`

And this will require a truncated multivariate-normal distribution. See here:

> [@How to truncate a multivariate normal distribution? (sidebar, how to access old stan mailing lists posts?)](https://discourse.mc-stan.org/t/how-to-truncate-a-multivariate-normal-distribution-sidebar-how-to-access-old-stan-mailing-lists-posts/9280/2):
>

and here:  
[https://github.com/spinkney/helpful\_stan\_functions/blob/main/functions/distribution/multi\_normal\_cholesky\_truncated.stanfunctions](https://github.com/spinkney/helpful_stan_functions/blob/main/functions/distribution/multi_normal_cholesky_truncated.stanfunctions)

---

_[View the full topic](https://discourse.mc-stan.org/t/chain-finishing-unexpectedly-in-high-dimension-hierarchical-model/34355)._
