Dear bugs users,
Below you find the code for a mixed regression model (doodle in
attatchment). I have modelled measurement error as subject specific and
assume it to follow a gamma distribution. When I perform a posterior
predictive assesment of model fitness, the deviance (as defined in
winbugs) of the replicated dataset in always larger that the model
deviance, for large datasets that were sumulated under the assumed
distributional conditions. Can anyone suggest any alternatives or flaws
in this program?
thanks a lot
Stefan
model;
{
for( i in 1 : n ) {
for( j in 1 : m ) {
y[i , j] ~ dnorm(mu[i , j],tau[i])
}
}
for( i in 1 : n ) {
alfaind[i] ~ dnorm( 0.0,tau4)
}
for( i in 1 : n ) {
slopeind[i] ~ dnorm( 0.0,tau3)
}
for( i in 1 : n ) {
tau[i] <- 1 / sigma[i]
}
for( i in 1 : n ) {
sigma[i] ~ dgamma(a,b)
}
for( i in 1 : n ) {
for( j in 1 : m ) {
muind[i , j] <- alfaind[i] + slopeind[i] * kant[i , j]
}
}
alfa ~ dnorm( 0.0,1.0E-6)
slope ~ dnorm( 0.0,1.0E-6)
for( i in 1 : n ) {
for( j in 1 : m ) {
mu[i , j] <- muind[i , j] + alfa + slope * kant[i , j]
}
}
tau4 ~ dgamma(0.001,0.001)
sigma4 <- 1 / tau4
tau3 ~ dgamma(0.001,0.001)
sigma3 <- 1 / tau3
a ~ dnorm(10,1.0E-6)I(0,)
b ~ dnorm(10,1.0E-6)I(0,)
for( i in 1 : n ) {
for( j in 1 : m ) {
rep[i , j] ~ dnorm(mu[i , j],tau[i])
}
}
for( i in 1 : n ) {
for( j in 1 : m ) {
dev1[i , j] <- ( -2) * log(sqrt(tau[i] / (2 * 3.142)) * exp((((
- 0.5) * tau[i]) * (y[i , j] - mu[i , j])) * (y[i , j] - mu[i , j])))
}
}
for( i in 1 : n ) {
for( j in 1 : m ) {
dev2[i , j] <- ( -2) * log(sqrt(tau[i] / (2 * 3.142)) * exp((((
- 0.5) * tau[i]) * (rep[i , j] - mu[i , j])) * (rep[i , j] - mu[i ,
j])))
}
}
devi1 <- sum(dev1[ , ])
devi2 <- sum(dev2[ , ])
diff <- devi1 - devi2
}
--
Dr. Stefan Van Dongen
Group of Animal Ecology
Department of Biology
University of Antwerp
Universiteitsplein 1
B-2610 Wilrijk, Belgium
Tel: + 32 (0)3 820 22 61
Fax: + 32 (0)3 820 22 71
Email: [log in to unmask]
URL: http://bio-www.uia.ac.be/u/svdongen/index.html
|