Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am an actuary working on a Bayesian loss reserve model using incremental average severity data. Exploratory analysis of the response seems to suggest a skew normal distribution of some sort would be appropriate, as there are some negative values in the left tail, and the log transformed positive values fit a normal distribution fairly well. I was inspired by this posting by Glenn Meyers and feel like the latter parameterization should be easy to implement in JAGS. However, since I am not used to JAGS, I am struggling to set the model up. Here is a example of what I am trying to do.

#Likelihood (training set)

for (i in 1:n){

  y[i] ~ dnorm(z[i], tau)

  z[i] ~ dlnorm(mu[i], tauln)

  mu[i] <- beta1*Dev[i] + ... 


I am not sure how to handle the negative $\mu_i$s in the absence of control structures (if, else, etc...) I am used to. I need to pass the zero valued or negative $\mu_i$s directly to the mean parameter for my response yi. Is there a clever way to do this with the step function? Should I consider specifying the normal-log-normal mixture another way? FYI – I also posted this question here.

share|improve this question
How about adding mu_y[i] <- ifelse(mu[i] <= 0, mu[i], z[i]) and changing the stochastic node for y to y[i] ~ dnorm(mu_y[i], tau)? – Nate Pope Jun 20 '14 at 1:44
Ah ok that makes sense. I wasn't aware there was a ifelse statement available in JAGS. Does this seem theoretically sound? I think originally I was confusing myself and assuming my mu[i] node was the expected value rather than the scale parameter. – Nathan Jun 20 '14 at 2:02
The mixture above will produce a skewed distribution with a long positive tail, and seems reasonable if the values of mu are not too extreme. I suggest you fit the model, simulate a new response, and check the simulations against your observed data to see if they match. You can implement this 'posterior predictive check' via JAGS by adding an 'unobserved' response node to your model with the same parameters as the observed response.. for example y_sim[i] ~ dnorm(mu_y[i], tau) – Nate Pope Jun 20 '14 at 2:20
And yes, your mu parameter is the log-scale and not the expected value. – Nate Pope Jun 20 '14 at 2:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.