Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I have found some distributions for which BUGS and R have different parameterizations: Normal, log-Normal, and Weibull.

For each of these, I gather that the second parameter used by R needs to be inverse transformed (1/parameter) before being used in BUGS (or JAGS in my case).

Does anyone know of a comprehensive list of these transformations that currently exists?

The closest I can find would be comparing the distributions in table 7 of the JAGS 2.2.0 user manual with the results of ?rnorm etc. and perhaps a few probability texts. This approach appears to require that the transformations will need to be deduced from the pdfs separately.

I would prefer to avoid this task (and possible errors) if it has already been done, or else start the list here.

Update

Based on Ben's suggestions, I have written the following function to transform a dataframe of parameters from R to BUGS parameterizations.

##' convert R parameterizations to BUGS paramaterizations
##' 
##' R and BUGS have different parameterizations for some distributions. 
##' This function transforms the distributions from R defaults to BUGS 
##' defaults. BUGS is an implementation of the BUGS language, and these 
##' transformations are expected to work for bugs.
##' @param priors data.frame with colnames c('distn', 'parama', 'paramb')
##' @return priors with jags parameterizations
##' @author David LeBauer

r2bugs.distributions <- function(priors) {

  norm   <- priors$distn %in% 'norm'
  lnorm  <- priors$distn %in% 'lnorm'
  weib   <- priors$distn %in% 'weibull'
  bin    <- priors$distn %in% 'binom'

  ## Convert sd to precision for norm & lnorm
  priors$paramb[norm | lnorm] <-  1/priors$paramb[norm | lnorm]^2
  ## Convert R parameter b to JAGS parameter lambda by l = (1/b)^a
  priors$paramb[weib] <-   1 / priors$paramb[weib]^priors$parama[weib]
  ## Reverse parameter order for binomial
  priors[bin, c('parama', 'paramb')] <-  priors[bin, c('parama', 'paramb')]

  ## Translate distribution names
  priors$distn <- gsub('weibull', 'weib',
                       gsub('binom', 'bin',
                            gsub('chisq', 'chisqr',
                                 gsub('nbinom', 'negbin',
                                      as.vector(priors$distn)))))
  return(priors)
}

##' @examples
##' priors <- data.frame(distn = c('weibull', 'lnorm', 'norm', 'gamma'),
##'                     parama = c(1, 1, 1, 1),
##'                     paramb = c(2, 2, 2, 2))
##' r2bugs.distributions(priors)
share|improve this question
2  
Not really an anwer, but I found this cheat sheet useful, Some Useful Distributions in Bayesian Analysis with Models from Educational Measurement (R.J. Mislevy, 2001) -- it mainly covers BUGS distributions. – chl Dec 19 '10 at 21:21

1 Answer

up vote 22 down vote accepted

I don't know of a canned list. Here is my list (edits provided by original questioner):

Normal and log-normal are parameterized in terms of $\tau$ (precision) rather than $\sigma$ or $\sigma^2$ (std. dev. or variance); $\tau = 1/\sigma^2 = 1/\mbox{var}$

Beta, Poisson, Exponential, Uniform are all the same

Negative binomial in BUGS has only the discrete parameterization (size,prob), not the "ecological" (size,mu, where size can be non-integer) parameterization.

edit: Weibull in BUGS is ($\nu$=shape,$\lambda$=lambda), in R is ($a$=shape,$b$=scale) [the math notation is consistent with the notation used in the respective documentation] As pointed out at How do I parameterize a Weibull distribution in JAGS / BUGS? , $\lambda= (1/b)^a$

Gamma in BUGS is (shape,rate). This is the default in R, but R also allows (shape,scale) [if the scale argument is named]; rate = 1/scale

Order matters, especially in BUGS (which doesn't have named arguments), e.g. R dbinom(x,size,prob) vs BUGS dbin(p,n) [same parameters, opposite order].

Name differences:

  • Binomial: R=dbinom,BUGS=dbin
  • Chi-squared: R=dchisq,BUGS=dchisqr
  • Weibull: R=dweibull,BUGS=dweib
  • Negative binomial: R=dnbinom, BUGS=dnegbin

edit: for truncated distributions BUGS uses I(), JAGS uses dinterval() [it's worth looking in the JAGS documentation if you're going to use this, there may be other subtle differences]

share|improve this answer
Great answer - thanks. This will save me a lot of brain power, time, and - most importantly - from potential errors. – David Dec 16 '10 at 16:54
1  
Don't forget the differences in how BUGS and JAGS deal with truncation, censoring and prior ordering of those distributions (section 8 of the manual). In particular, JAGS has a dinterval distribution, where BUGS works with I(). – conjugateprior Jan 16 '11 at 17:01

Your Answer

 
discard

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

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