7
$\begingroup$

Based on the answer to a previous question, For which distributions are the parameterizations in BUGS and R different?

I have been transforming R parameterizations to JAGS parameterizations, but I have been getting errors so I am asking a separate question to clarify that the transformation is correct.

R's ?dweibull states the pdf (with $a = \text{shape}$ and $b = \text{scale}$):

$$(^a/_b)(^x/_b)^{a-1} \text{exp}(- (^x/_b)^a)$$

And the JAGS manual states the pdf as:

$$\nu \lambda x^{\nu-1}\text{exp}(-\lambda x^\nu)$$

I can see that the parameterization used by R has $f(b)^a$ but the JAGS parameterization does not have an equivalent $f(\lambda)^\nu$. But I can't bring myself to pull out a pencil when I have all of this computational power at my fingertips. So I did the following empirical demonstration that the JAGS parameterization is not to simply transform shape to rate as $\text{rate} =1/b$:

The following plot represents two samples (code below),

  • R (red) from $\small{Y\sim\text{Weibull}(a = 2, b = 50)}$
  • JAGS (blue) from $\small{Y\sim\text{Weibull}(\lambda = 2, \nu = 1/50)}$

enter image description here

library(rjags)
shape <- 2
rate  <- 50
set.seed(0)
model.string <- 
writeLines(paste("\nmodel{\nbeta ~ dweib (2,",1/rate,")\nY <- beta\n}"), con = 'weibulltest.bug')
j.model  <- jags.model(file = "weibulltest.bug", data = list(x=NA)) #hack
mcmc.object <- coda.samples(model = j.model, variable.names = c('Y'), n.iter = 10000)
Y.jags <- as.matrix(mcmc.object)
Y.r <- rweibull(10000, shape, rate)
plot(density(Y.r), col = 'red', ylim = c(0,0.15))
lines(density(Y.jags), col = 'blue')
$\endgroup$

1 Answer 1

8
$\begingroup$

Doing the algebra, we have $\lambda= (1/b)^a$ (by equating the constant term within the exponent): since $a=\nu$, this is consistent with $a (1/b)^{a} = \nu \lambda$. You're right that my answer elsewhere is wrong; feel free to edit it yourself if I don't get around to it sooner (at least the link is there to warn people) ...)

$\endgroup$
2
  • $\begingroup$ thanks for doing the math. It looks like you already edited your question. I'd delete this one except that it provides a nice example of when it is easier to use a pencil than a computer. $\endgroup$ Nov 17, 2011 at 21:56
  • $\begingroup$ Before working backward from your answer, I see I was stuck because I didn't think (long enough) to apply $\frac{1}{b^a}= \frac{1}{b}\frac{1}{b^{a-1}}$ $\endgroup$ Nov 18, 2011 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.