# Is there a difference between skew\_normal & brms::rskew\_normal?

**URL:** <https://discourse.mc-stan.org/t/is-there-a-difference-between-skew-normal-brms-rskew-normal/30651>\
**Category:** General\
**Tags:** specification, brms\
**Created:** [March 7, 2023, 9:30am UTC](https://discourse.mc-stan.org/t/is-there-a-difference-between-skew-normal-brms-rskew-normal/30651 "2023-03-07T09:30:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JAQuent](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jaquent/32/5763_2.png) [@JAQuent](https://discourse.mc-stan.org/u/JAQuent)\
**Post date:** [March 7, 2023, 9:30am UTC](https://discourse.mc-stan.org/t/is-there-a-difference-between-skew-normal-brms-rskew-normal/30651/1 "2023-03-07T09:30:10Z")

</div>

When trying to find the suitable priors for my models, I’d like to quickly check how the prior would look like by plotting it e.g. `hist(rskew_normal(n = n, mu = 4, sigma = 0.5, alpha = -10))` but I found that the distribution that I create like this and the distribution that I get when running a `brms` model with `sample_prior = "only"` are not the same when I want a skew normal distribution. Am I setting the paramters wrong? Are they different? Do they priors influence each other some how?

Here is an example:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/3X/9/8/986ad91f9008e4064cd2f0c72df6bc877236d506.png)

and the reproducible code:

```plaintext
# Library
library(brms)
library(ggplot2)

# Seed
set.seed(20230307)

# Generate data with rskew_normal
n <- 4000
dists <- data.frame(Value = rskew_normal(n = n, mu = 4, sigma = 0.5, alpha = -10), 
                    Method = rep("rskew_normal", n))

# Create a random data set to fit a model
fake_data <- data.frame(x = rnorm(100), y = rnorm(100))

# Set brms priors
test_prior <- c(prior(skew_normal(4, 0.5, -10), class = "b"))

# Fit brms model
currentModel <- brm(y ~ x, 
                    data = fake_data, 
                    prior = test_prior, 
                    sample_prior = "only", 
                    seed = 1234,
                    backend = "cmdstanr",
                    silent = 2,
                    refresh = 0)

# Extract the prior from the fit
dists <- rbind(dists, data.frame(Value = as_draws_df(currentModel)$b_x, Method = rep('brms_fit', ndraws(currentModel))))

# Visualise the difference
ggplot(dists, aes(x = Value, fill = Method)) + 
  geom_density(alpha = 0.5) +
  labs(title = "Difference between rskew_normal & skew_normal")

```

For comparison, I also did the same for the normal distribution, which looks like expected.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/3X/2/6/26f349cc93f28ffe6c6edbc200c0bae89d7804a2.png)

---

<div class="post-metadata">

**Author:** ![JAQuent](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jaquent/32/5763_2.png) [@JAQuent](https://discourse.mc-stan.org/u/JAQuent)\
**Post date:** [March 7, 2023, 9:43am UTC](https://discourse.mc-stan.org/t/is-there-a-difference-between-skew-normal-brms-rskew-normal/30651/2 "2023-03-07T09:43:04Z")

</div>

Okay, I found out myself that stan uses SkewNormal(y \mid \xi, \omega, \alpha) whileI used \mu, \sigma, \alpha in `rskew_normal` after using \xi, \omega, \alpha instead it works as intended.

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/3X/6/f/6f3c1dabd8315b0b3f8f206a024043c6a6453696.png)
