#------------------------------------------------------------------------------------------------------------------------------ Version 2 MULTIVARIATE-conjugate (Zellner's g-prior, specify prior parameters in code) #------------------------------------------------------------------------------------------------------------------------------ model{ #--------------------------------------------------------------- # definition of prior parameters c2 <- 25 # prior means for (j in 1:P){ mu.beta[j] <- 0.0 } # calculation of xtx for (i in 1:P){ for (j in 1:P){ inverse.V[i,j] <- inprod( x[,i] , x[,j] ) }} # calculation of the elements of prior precision matrix for(i in 1:P){ for (j in 1:P){ prior.T[i,j] <- inverse.V[i,j] * tau /c2 }} #--------------------------------------------------------------- # model's likelihood # ------------------ for (i in 1:n){ x[i,1] <- 1.0 # specifying the constant term in the first column time[i] ~ dnorm( mu[i], tau ) # stochastic componenent # link and linear predictor mu[i] <- inprod( beta[], x[i,] ) } # prior distributions # ------------------ # calculation of the inverse matrix of V # prior parameters # multivariate prior for the beta vector beta[1:P] ~ dmnorm( mu.beta[], prior.T[,] ) # gamma prior for the precision tau ~ dgamma( 0.01, 0.01 ) # deterministic calculation of variance s2 <- 1/tau s <-sqrt(s2) # } INITS list( tau=1, beta=c(1, 0, 0) ) list( n=25, P=3, 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), x=structure(.Data=c(NA, 7, 560, NA, 3, 220, NA, 3, 340, NA, 4, 80, NA, 6, 150, NA, 7, 330, NA, 2, 110, NA, 7, 210, NA,30, 1460, NA, 5, 605, NA, 16, 688, NA,10, 215, NA, 4, 255, NA, 6, 462, NA, 9, 448, NA, 10, 776, NA, 6, 200, NA, 7, 132, NA, 3, 36, NA,17, 770, NA, 10, 140, NA,26, 810, NA, 9, 450, NA, 8, 635, NA, 4, 150), .Dim = c(25,3)) ) DATA (RECT.) list(n=25, P=3) time[] x[,2] x[,3] 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