# Log Skew Normal (LSN)

**URL:** <https://discourse.mc-stan.org/t/log-skew-normal-lsn/12197>\
**Category:** General\
**Created:** [December 5, 2019, 5:13pm UTC](https://discourse.mc-stan.org/t/log-skew-normal-lsn/12197 "2019-12-05T17:13:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbautista](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/lbautista/32/6632_2.png) [@lbautista](https://discourse.mc-stan.org/u/lbautista)\
**Post date:** [December 5, 2019, 5:13pm UTC](https://discourse.mc-stan.org/t/log-skew-normal-lsn/12197/1 "2019-12-05T17:13:17Z")

</div>

Good afternoon, how can I define the Log Skew Normal (LSN) distribution?

---

<div class="post-metadata">

**Author:** ![Christopher-Peterson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/christopher-peterson/32/13_2.png) [@Christopher-Peterson](https://discourse.mc-stan.org/u/Christopher-Peterson)\
**Post date:** [December 5, 2019, 10:52pm UTC](https://discourse.mc-stan.org/t/log-skew-normal-lsn/12197/2 "2019-12-05T22:52:38Z")

</div>

What are you trying to use it for? In most cases, I’d imagine that modeling the log of a parameter/data with a regular skew normal would make things easier.

```stan
data {
   int N;
   vector[N] Y;
...
} 
transformed data {
    vector[N] log_Y = log(Y);
}
parameters {
   real log_theta;
...
}
transformed parameters {
   real theta = exp(log_theta);
}
model {
    log_theta ~ skew_normal(...);
    log_Y ~ skew_normal(...);
...
}

```

---

<div class="post-metadata">

**Author:** ![lbautista](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/lbautista/32/6632_2.png) [@lbautista](https://discourse.mc-stan.org/u/lbautista)\
**Post date:** [December 6, 2019, 2:07pm UTC](https://discourse.mc-stan.org/t/log-skew-normal-lsn/12197/3 "2019-12-06T14:07:26Z")

</div>

I want to implement a marginalized model using the Log-Skew-Normal (LSN) distribution, for semi-continuous longitudinal data

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [December 7, 2019, 2:46am UTC](https://discourse.mc-stan.org/t/log-skew-normal-lsn/12197/4 "2019-12-07T02:46:00Z")

</div>

You just need a definition of the density then you can define it as a function and use it like any other desnity.

You might want to start with [Aki’s tutorial on adding custom probability functions](https://mc-stan.org/users/documentation/case-studies/gpareto_functions.html). There are also examples in the chapter of the user’s guide on user-defined functions.
