# How to write this prior in Stan?

**URL:** <https://discourse.mc-stan.org/t/how-to-write-this-prior-in-stan/5776>\
**Category:** Modeling\
**Created:** [September 26, 2018, 6:25pm UTC](https://discourse.mc-stan.org/t/how-to-write-this-prior-in-stan/5776 "2018-09-26T18:25:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![serenejiang](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/serenejiang/32/3252_2.png) [@serenejiang](https://discourse.mc-stan.org/u/serenejiang)\
**Post date:** [September 26, 2018, 6:25pm UTC](https://discourse.mc-stan.org/t/how-to-write-this-prior-in-stan/5776/1 "2018-09-26T18:25:47Z")

</div>

I have a matrix Lambda and I want to specify its prior as log(sqrt(Lambda)) in proportion to 1.  
How can I specify this prior in stan? Thanks!

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [September 26, 2018, 7:14pm UTC](https://discourse.mc-stan.org/t/how-to-write-this-prior-in-stan/5776/2 "2018-09-26T19:14:54Z")

</div>

Declare

```
matrix[?, ?] log_sqrt_Lambda;

```

in the parameters block and

```
matrix[?, ?] Lambda = square(exp(log_sqrt_Lambda));

```

in the transformed parameters block. Then, an improper uniform prior on the elements of `log_sqrt_Lambda` is proportional to 1. However, this prior seems dubious and you should verify that the posterior distribution it implies is actually proper.

---

<div class="post-metadata">

**Author:** ![maxbiostat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/maxbiostat/32/1326_2.png) [@maxbiostat](https://discourse.mc-stan.org/u/maxbiostat)\
**Post date:** [September 26, 2018, 9:58pm UTC](https://discourse.mc-stan.org/t/how-to-write-this-prior-in-stan/5776/3 "2018-09-26T21:58:09Z")

</div>

> [@bgoodri](#):
>
> you should verify that the posterior distribution it implies is actually proper.

Yes, that.

---

<div class="post-metadata">

**Author:** ![serenejiang](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/serenejiang/32/3252_2.png) [@serenejiang](https://discourse.mc-stan.org/u/serenejiang)\
**Post date:** [September 27, 2018, 3:21am UTC](https://discourse.mc-stan.org/t/how-to-write-this-prior-in-stan/5776/4 "2018-09-27T03:21:26Z")

</div>

@bgoodri Thank you so much!
