You have to click twice when you load the data, onece for the list and one
for the
rectangular data table. The model runs fine.
Cheers,
Pablo
----- Original Message -----
From: "Fabrizio" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Monday, April 23, 2012 8:53 PM
Subject: [BUGS] help! variable NA is not defined
Dear all,
I have only ( I hope...) one question;: when i get run my program, see down,
when i try to compile the sentence: "variable na is not defined" appears
what do you think?
thansk a lot
# Model begins
model{
# *** PROGRAM STARTS
for(i in
1:ns){ # LOOP
THROUGH STUDIES
w[i,1] <- 0
# adjustment for multi-arm trials is zero for control arm
delta[i,1] <- 0
# treatment effect is zero for control arm
mu[i] ~ dnorm(0,.0001) #
vague priors for all trial baselines
for (k in 1:na[i])
{ # LOOP THROUGH ARMS
r[i,k] ~ dbin(p[i,k],n[i,k]) #
binomial likelihood
logit(p[i,k]) <- mu[i] + delta[i,k] #
model for linear predictor
rhat[i,k] <- p[i,k] * n[i,k]
# expected value of the numerators
dev[i,k] <- 2 * (r[i,k] * (log(r[i,k])-log(rhat[i,k]))
#Deviance contribution
+ (n[i,k]-r[i,k]) * (log(n[i,k]-r[i,k]) - log(n[i,k]-rhat[i,k])))
}
resdev[i] <- sum(dev[i,1:na[i]]) # summed residual
deviance contribution for this trial
for (k in 2:na[i]) { #
LOOP THROUGH ARMS
delta[i,k] ~ dnorm(md[i,k],taud[i,k]) #
trial-specific LOR distributions
md[i,k] <- d[t[i,k]] - d[t[i,1]] + sw[i,k] # mean of
LOR distributions (with multi-arm correction)
taud[i,k] <- tau *2*(k-1)/k #
precision of LOR distributions (with multi-arm correction)
w[i,k] <- (delta[i,k] - d[t[i,k]] + d[t[i,1]]) #
adjustment for multi-arm RCTs
sw[i,k] <- sum(w[i,1:k-1])/(k-1) #
cumulative adjustment for multi-arm trials
}
}
totresdev <- sum(resdev[]) #Total
Residual Deviance
d[1]<- 0
# treatment effect is zero for reference treatment
for (k in 2:nt) { d[k] ~ dnorm(0,.0001)} # vague
priors for treatment effects
sd ~ dunif(0,0.10)
tau <- pow(sd,-2)
# pairwise ORs and LORs for all possible pair-wise comparisons
for (c in 1:(nt-1)) { for (k in (c+1):nt) {
or[c,k] <- exp(d[k] - d[c])
lor[c,k] <- (d[k]-d[c])
}
}
# ranking
for (k in 1:nt) {
rk[k] <- nt+1-rank(d[],k) # assumes events are
“good”
# rk[k] <- rank(d[],k) # assumes events are
“bad”
best[k] <- equals(rk[k],1) #calculate probability that
treat k is best
}
# Absolute effects
A ~ dnorm(-2.6,precA)
precA <- pow(0.38,-2) # prior precision for
Treatment A, sd=0.38 on logit scale
for (k in 1:nt) { logit(T[k]) <- A + d[k] }
}
# *** PROGRAM ENDS
# Model ends
# Data begin
list(nt=5,ns=4)
r[,1] n[,1] r[,2] n[,2] r[,3] n[,3] t[,1] t[,2] t[,3] na[] # ID
59 1720 119 1380 NA 1 1 2 NA 2 #bos
15 700 78 2070 NA 1 1 3 NA 2 #sil
21 1300 26 1250 NA 1 1 4 NA 2 #ber
9 1220 49 2410 NA 1 1 5 NA 2 #sit
END
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at
www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
|