# Prior as a mixture of a Half-Normal and Uniform distribution

Hi there,

I want to construct a prior that is a mixture of a Half-Normal (if the parameter is negative) and a Uniform distribution [0,1] (if the parameter is positive. I see how I can go about creating my own prior distributions, e.g., as a mixture of normals. But I am struggling with constructing the Half-Normal in the mixture, i.e., setting an upper bound here at 0.

Here is where I am:

real mixtureHalfNormalUniform_lpdf(real param, real w, real sigma, real a, real b) {
return (log_sum_exp(log(w) + normal_lpdf(param|0,sigma), log1m(w) + uniform_lpdf(param|a,b)));
}


I thought adding T[,0] after normal_lpdf(…) would do the trick, but no.

I would be very happy if you could help me. Many thanks in advance!

Cheers,
Nic

Sounds like the distibution you’re going for is

real mixtureHalfNormalUniform_lpdf(real param, real w, real sigma, real a, real b) {
if ( param < 0 ) {
return log(w) + normal_lpdf(param|0, sigma);
} else {
return log1m(w) + uniform_lpdf(param|a, b);
}
}


but note that sampling will be very inefficient because this function is discontinuous. Can you tell more about the model? Why this particular prior?

Thank you very much for your help!

The model is such that the parameter can reduce the target between 0 and 100% or increase the target indefinitely. Thus, the parameter can take on values from -infinity to 1. Negative values are less likely (–> w ~ 0.1), especially high ones (–> Half-normal(0.1)). We want to be non-informative on the reduction (–> Uniform(0,1)).

Would you have alternative suggestions for a prior that is more efficient for sampling?

@nhuurre Indeed, sampling took too long. Would you have an elegant idea for a distribution where sampling is more efficient? My desired properties are the following:

• Support: -infinity to 1
• P(x<0) ~ 50%, but less than 50% is also fine
• P(x --> -infinity) --> 0, i.e., if negative then large values are not so likely
• P(0<x<1) ~ Uniform(0,1), but values close to 1 are not so likely, so it doesn’t have to be exactly uniform

Background: We are estimating the effect of various interventions I_k on a target y basically via
y = exposure * prod_k^K (1 - x_k*I_k). Individual interventions can both in- or decrease via. Decreases can be at max 100%, i.e., y dropping to zero.

Well, the uniform for x>0, half-normal for x<0 distribution is continuous if

w\times \frac{1}{\sqrt{2\pi}\sigma} = 1-w \\ \sigma = \frac{w}{\sqrt{2\pi}\left(1-w\right)}

For w=0.5 that gives \sigma\approx 0.4. Maybe that’s ok?
Depends on how large x is expected to be conditional on x<0.

1 Like

Of course, that makes lots of sense setting \sigma based on w. Concerning the expectations about x when x<0, they are quite low, so that I went for a lower w and \sigma.

Thank you so much!