#------------------------------------------------------------------------------------------------------------------------------ Version 1 #------------------------------------------------------------------------------------------------------------------------------ model{ # model's likelihood for (i in 1:n){ time[i] ~ dnorm( mu[i], tau ) # stochastic componenent # link and linear predictor mu[i] <- beta0 + beta1 * cases[i] + beta2 * distance[i] } # prior distributions tau ~ dgamma( 0.01, 0.01 ) beta0 ~ dnorm( 0.0, 1.0E-4) beta1 ~ dnorm( 0.0, 1.0E-4) beta2 ~ dnorm( 0.0, 1.0E-4) # definition of sigma s2<-1/tau s <-sqrt(s2) # calculation of the sample variance for (i in 1:n){ c.time[i]<-time[i]-mean(time[]) } sy2 <- inprod( c.time[], c.time[] )/(n-1) ## equivalently: sy2 <- pow(sd(time[]),2) # calculation of Bayesian version R squared R2B <- 1 - s2/sy2 # Expected y for a typical delivery time typical.y <- beta0 + beta1 * mean(cases[]) + beta2 * mean(distance[]) # # posterior probabilities of positive beta's p.beta0 <- step( beta0 ) p.beta1 <- step( beta1 ) p.beta2 <- step( beta2 ) } INITS list( tau=1, beta0=1, beta1=0, beta2=0 ) DATA (LIST) list( n=25, time = c(16.68, 11.5, 12.03, 14.88, 13.75, 18.11, 8, 17.83, 79.24, 21.5, 40.33, 21, 13.5, 19.75, 24, 29, 15.35, 19, 9.5, 35.1, 17.9, 52.32, 18.75, 19.83, 10.75), distance = c(560, 220, 340, 80, 150, 330, 110, 210, 1460, 605, 688, 215, 255, 462, 448, 776, 200, 132, 36, 770, 140, 810, 450, 635, 150), cases = c( 7, 3, 3, 4, 6, 7, 2, 7, 30, 5, 16, 10, 4, 6, 9, 10, 6, 7, 3, 17, 10, 26, 9, 8, 4) ) DATA (RECT.) list(n=25) time[] cases[] distance[] 16.68 7 560 11.5 3 220 12.03 3 340 14.88 4 80 13.75 6 150 18.11 7 330 8 2 110 17.83 7 210 79.24 30 1460 21.5 5 605 40.33 16 688 21 10 215 13.5 4 255 19.75 6 462 24 9 448 29 10 776 15.35 6 200 19 7 132 9.5 3 36 35.1 17 770 17.9 10 140 52.32 26 810 18.75 9 450 19.83 8 635 10.75 4 150 END