3
$\begingroup$

So I am having a problem specifying my model in OpenBUGS. A set of vectors in a linear regression model is given a multivariate normal prior with a constant mean vector and a constant precision matrix which is multiplied by a parameter with a hyperprior of a gamma distribution.

The code is as follows:

model{
#likelihood
for(i in 1:93){
    BegSal[i]~dnorm(mu[i],tau)
    mu[i]<-b[1]+b[2]*Sex[i]+b[3]*Educ[i]+b[4]*Exper[i]+b[5]*Time[i]
}
#priors
tau~dgamma(.00001,.00001)
covNew[1:5,1:5]<-tau*covPri[1:5,1:5]
b[1:5]~dmnorm(meanPri[1:5],covNew[1:5,1:5])
}

#data
list(meanPri= c(13625,4500,-14388.3333,55,308.3333),
     covPri = structure(.Data = c(362.5,362.5,452.5,452.5,362.5,
                                  362.5,365,452.5,452.5,362.5,
                                  452.5,452.5,565,565,452.5,
                                  452.5,452.5,565,25565,452.5,
                                  362.5,362.5,452.5,452.5,1802.5),
                                  .Dim = c(5, 5)) )

I'm receiving an error "Expected Multivariate Node," when I try and compile. If anyone has any suggestions I would greatly appreciate it. I left the rest of the data out as it is fairly long. Thanks for any help.

$\endgroup$

1 Answer 1

0
$\begingroup$

You need to construct covNew element by element

for(i in 1:5){
for(j in 1:5){
    covNew[i,j]<-tau*covPri[i,j]
}
}

BUGS acts a bit differently than R when it comes to constructing matrices/arrays. See the WINBUGS user manual for full details.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.