winbugs

Writing conditional distribution in the WinBUGS using R2WinBUGS package in R

怎甘沉沦 提交于 2020-02-07 05:28:16
问题 For the following data, mydata ID Y x z 1 1 5.302956 1 1 2 1 3.358249 2 1 3 1 4.976734 3 1 4 1 4.290459 4 1 5 1 0.000000 5 0 6 2 5.975351 1 1 7 2 6.620773 2 1 8 2 8.045909 3 1 9 2 7.378384 4 1 10 2 6.908755 5 1 11 2 8.672657 6 1 12 2 8.284252 7 1 13 2 8.455531 8 1 14 2 7.415175 9 1 15 2 8.634265 10 1 16 3 7.356993 1 1 17 3 6.607598 2 1 18 3 0.000000 3 0 19 3 0.000000 4 0 20 3 0.000000 5 0 21 3 0.000000 6 0 22 3 0.000000 7 0 23 3 0.000000 8 0 24 3 6.398595 9 1 25 3 6.580639 10 1 26 4 5.525104

BUGS error messages

女生的网名这么多〃 提交于 2019-12-30 00:39:05
问题 I am new to WinBUGS/OpenBUGS and having difficulty debugging my code. Does anyone know of a list of potential error messages for BUGS models and their meanings in plain English? 回答1: The WinBUGS manual has a list of some common error. I have added some additional notes from my own experience: expected variable name indicates an inappropriate variable name. I occasionally get this error in providing the data, might have used 1.02e04 instead of 1.02E04 . undefined variable - variables in a data

the error when I use R2WinBUGS packages

大兔子大兔子 提交于 2019-12-27 03:32:51
问题 all, I employ the R packages R2WinBUGS to run Winbugs with R.However,the program is not able to work well.The following codes attached panel.bug: model{ for(i in 1:N){ for(t in 1:T){ y[i,t]~dnorm(mu[i,t],tau) mu[i,t]<-alpha+gamma1*a[i,t]+gamma2*b[i,t]+gamma3*c[i,t]+gamma4*d[i,t]+gamma5*e[i,t]+gamma6*f[i,t] } } gamma1~dnorm(1,25) gamma2~dnorm(1,25) gamma3~dnorm(1,25) gamma4~dnorm(1,25) gamma5~dnorm(1,25) gamma6~dnorm(1,25) alpha~dnorm(0,16) tau~dgamma(1,1.75) sigma.tau<-1/sqrt(tau) } and the R

WinBUGS Weibull Network Meta-Analysis

五迷三道 提交于 2019-12-22 04:15:08
问题 I am currently working on a meta-analysis of survival data across several clinical trials. To do this, I have code from a published analysis using the same methodology. However, when running this code using the data from the published analysis, I am unable to replicate their results. In fact, the results fail to converge to any kind of reasonable estimate. The code itself (not including the data) should be correct as it comes directly from the authors. I assume the problem has to do w/

Choosing Different Distributions based on if - else condition in WinBugs/JAGS

好久不见. 提交于 2019-12-19 17:32:16
问题 I am trying to write a Winbugs/Jags model for modeling multi grain topic models (exactly this paper -> http://www.ryanmcd.com/papers/mg_lda.pdf) Here I would like to choose a different distribution based on a particular value. For Eg: I would like to do something like `if ( X[i] > 0.5 ) { Z[i] ~ dcat(theta-gl[D[i], 1:K-gl]) W[i] ~ dcat(phi-gl[z[i], 1:V]) } else { Z[i] ~ dcat(theta-loc[D[i], 1:K-loc]) W[i] ~ dcat(phi-loc[z[i], 1:V]) } ` Is this possible to be done in Winbugs/JAGS? 回答1: Winbugs

How to code a matrix in WinBUGS?

a 夏天 提交于 2019-12-13 19:39:47
问题 I am trying to code the 2X2 matrix sigma with the 4 elements. Not sure how to code in WINBUGS. My goal is to get the posterior p's, their means and variances and create an ellipse region covered by the two posterior p's. Heres my code below: model{ #likelihood for(j in 1 : Nf){ p1[j, 1:2 ] ~ dmnorm(gamma[1:2], T[1:2 ,1:2]) for (i in 1:2){ logit(p[j,i]) <- p1[j,i] Y[j,i] ~ dbin(p[j,i],n) } X_mu[j,1]<-p[j,1]-mean(p[,1]) X_mu[j,2]<-p[j,2]-mean(p[,2]) v1<-sd(p[,1])*sd(p[,1]) v2<-sd(p[,2])*sd(p[,2

JAGS and WinBUGS giving differing DIC

孤人 提交于 2019-12-13 16:21:26
问题 I'm doing a network meta-analysis including several clinical trials. The response is binomial. Each trial contains several treatments. When I do a random effects model, the output from JAGS and WinBUGS is similar. When I do a fixed effects model, the DIC and pD components are way out, though the posteriors of the parameters I'm interested in are similar. I've got similar models that have Gaussian response, not binomial, and JAGS and WinBUGS are in agreement. The BUGS/JAGS code for the fixed

OpenBUGS error undefined variable

早过忘川 提交于 2019-12-13 13:20:31
问题 I'm working on a binomial mixture model using OpenBUGS and R package R2OpenBUGS . I've successfully built simpler models, but once I add another level for imperfect detection, I consistently receive the error variable X is not defined in model or in data set . I've tried a number of different things, including changing the structure of my data and entering my data directly into OpenBUGS. I'm posting this in the hope that someone else has experience with this error, and perhaps knows why

Bayesian interval of 5 fitted values

落花浮王杯 提交于 2019-12-12 22:04:00
问题 I conducted a Bayesian analysis by running Winbugs from R and derived the fitted values and their Bayesian intervals. Here is the related Winbugs output where mu[i] is the i-th fitted value. node mean 2.5% 97.5% mu[1] 0.7699 0.6661 0.94 mu[2] 0.8293 0.4727 1.022 mu[3] 0.7768 0.4252 0.9707 mu[4] 0.6369 0.4199 0.8254 mu[5] 0.7704 0.5054 1.023 What I want to do is to find the Bayesian interval for the mean of these 5 fitted values. Any idea how? 回答1: The answer of Chris Jackson is correct,

Estimating unknown response variable in JAGS - unsupervised learning

不问归期 提交于 2019-12-11 11:34:10
问题 I am attempting to estimate response values of percentage cover ( COV ) from known distribution parameters. I can do this by specifying the response data as NAs in OpenBUGS (e.g. the code below) but JAGS won't allow this. Does anyone know how I can achieve this in JAGS? I think this falls into the category of 'unsupervised statistical learning' model { for (i in 1:n.sites) { # loop around sites # specify prior distribution forms for effectively unknown percentage cover COV[i] ~ dbeta(a[i], b