# BUGS Tips and Links

• The BUGS Project
• rube: Really Useful Bugs (and jags) Enhancer   (Older: Getting R Data into BUGS )
• Getting Started (pdf)   (much better than BUGS documentation)
• Tutorial (pdf)
• OpenBugs
• R2WinBugs Paper (pdf)   Package   bugs() doc   Examples
• Tips and Troubleshooting (including "trap errors")
• Tricks
• Distributions
• Relationship between BUGS and R parameterizations of the Weibull distribution
• In R, rweibull(n, shape, scale=1) generates Weibull data with mean=scale*gamma(1+1/shape). The variance is scale^2*[gamma(1+2/shape)-gamma(1+1/shape)^2].
• In BUGS, dweib(v, lambda) is the density function. The v parameter corresponds directly to the shape parameter in R. The R scale parameter equals 1/(lambda^(1/v)). The BUGS lambda parameter equals 1/(scale^shape).
• To find the BUGS lambda parameter corresponding to a given v and mean, calculate lambda=[gamma(1+1/v)/mean]^v.
• In R, the median is scale*(ln(2))^(1/shape). In BUGS, the median is [ln(2)/lambda]^(1/v).
• In R, if "data" has one row per subject, the method-of-moments estimates of the shape (alpha) and scale (beta) can be obtained with this code:
Seq=seq(0.1,5,0.01) # assuming 0.1<=alpha<=5, e.g.
CVB=sqrt(gamma(1+2/Seq)-gamma(1+1/Seq)^2)/gamma(1+1/Seq)
mns=apply(data,1,mean)
cvs=apply(data,1,sd)/mns
alphahat=sapply(cvs, function(x){rev(Seq[x<=CVB])[1]})
betahat=mns/gamma(1+1/alphahat)

All links active 5/15/2014. Please report missing links to

Back to My Computers Page