Print

Print


I think you might have to "cheat", with something like this:


sd.rel <- sd(rel.star[,1])

for(i in i:N) {
	rel.star[i,] ~ dmnorm(0, prec[,])
	rel.star[]
	for(k in 1:2) {
		rel[i,k] <- mu[k] + (rel.star[i,k] - mean(rel.star[,k]))/sd.rel
	}
}

(BUGS may run more quickly if you swap the i and k indices, i.e. have 
rel[k,i] not rel[i,k])
I haven't checked the code, but I hope you get the idea. You might have 
to be a bit careful with the priors, as the prior for rel.star[,1] will 
affect the prior for rel[,2].

Bob

On 10/20/2017 10:57 PM, Ashley Lee wrote:
> Hello. All,
>
> I'm struggling with how to write a multivariate normal distribution. The mean of the multivariate normal distribution is fixed as 0 for both variables. But, the variance of one variable should be fixed to 1, while other should be free to estimate (for the model identification purpose). If both variables are free to estimate, I can simply use wishart prior to estimate variance-covariance matrix of the multivariate normal distribution. But, I MUST fix one of the variances.
>
> What I thought as a possible solution was
>
> rel ~ dmnorm(mu[], prec[,])
>
> mu[1]<-0
> mu[2]<-0
>
> prec[,] ~ dwish(s.prec[,],2)
>
> s.prec[1,1]<-1
> s.prec[2,2]<-1
> s.prec[1,2] <-0
> s.prec[2,1] <-0
>
> prec[1,1] <-1 # to fix the variance after variance-covarince matrix was sampled from the wishart distribution.
>
> But, because Openbugs does not care of which argument comes first, this did not work.
>
> Please share your idea to solve this problem with me if any.
>
> Thanks much all!
>
> Ashley
>
> -------------------------------------------------------------------
> This list is for BUGS users to support each other, ask questions or share ideas.
> 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

-- 
Bob O'Hara
Institutt for matematiske fag
NTNU
7491 Trondheim
Norway

Mobile: +49 1515 888 5440
Journal of Negative Results - EEB: www.jnr-eeb.org

-------------------------------------------------------------------
This list is for BUGS users to support each other, ask questions or share ideas.
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