[R] Hlep in analysis in RWinBugs
Shubha Nath Pandit
snpandit at hotmail.com
Sun Jun 4 05:22:02 CEST 2017
Hi R User,
I was trying to use R for WINBUGS using following model and data (example), but I am new with WINBUGS and don't know how we perform the analysis. I wonder whether I can run the following the example data and Winbugs Model in R. Your help will be highly appreciated.
Sincerely,
SN PANDIT
===
library(R2WinBUGS)
#Model
model{
#likelihood
for(i in 1:N){
a1[i] ~ dnorm(a11[i],tau)
2[i] ~ dnorm(a21[i],tau1)
a3[i] ~ dnorm(a31[i],tau2)
a11[i]<-sm[i]*S1*m1
a21[i]<-sm[i]*S1*(1-m1)*S2*m2
a31[i]<-sm[i]*S1*(1-m1)*S2*(1-m2)*S3
sum[i]<-a11[i]+a21[i]+a31[i]
}
#priors
#priors are dbeta(0.5,0.5), uniform is dbeta(1,1)
S1~dbeta(1,1)#I(0,0.2) #
S2~dbeta(1,1)#I(0.15,0.5) #
S3~dbeta(1,1)#I(0.3,1)
m1~dbeta(1,1)#I(0.01,1)
m2~dbeta(1,1)#I(0,1)
sd ~ dunif(0,100)
sd1 ~ dunif(0,100)
sd2 ~ dunif(0,100)
tau <- 1/(sd*sd)
tau1 <- 1/(sd1*sd1)
tau2 <- 1/(sd2*sd2)
}
model.file <- Model
file.show(model.file)
#The Data
list(N = 4,
sm=c(9309,3253,5292,1361),
a1=c(16,3,4,2),
a2=c(96,31,42,3),
a3=c(47,5,18,1))
inits <- function(){
list(sd = 1000, sd1 = 1000, sd2 = 1000, S1 = 0.10, S2 = 0.25, S3 = 0.5, m1 = 0.25, m2 = 75)
}
[[alternative HTML version deleted]]
More information about the R-help
mailing list