a follow up on my previous post (thanks for the answer to that): I am struggling with the computation of the marginal likelihood of my BVAR (that I need to compare different specifications of the BVAR). In the course manual for the course on Bayesian Econometrics there is one example how to compute that for a univariate linear model (Example 3.2). My problems with transferring this example to the multivariate case start already with the calculation of the multivariate gamma-distribution term. How can that be done in RATS?
So, if I have OLS estimates for my VAR obtained by
Code: Select all
* Estimate VAR by OLS
system(model=olsmodel)
variables varlist
lags 1 to l
kfset xxx
det detlist
end(system)
estimate(noprint) start end
Code: Select all
dim olssee(nvar)
ewise olssee(i) = sqrt(%sigma(i,i))
comp sigma = %sigma
comp xx = inv(xxx)
comp bhat = %vec(%modelgetcoeffs(olsmodel))
*
*** Create the prior mean and (square root of) precision
if %defined(mvector) {
comp lmvector = mvector
}
else {
dim lmvector(nvar)
ewise lmvector(i) = 1.
}
dim minnmean(l*nvar+%rows(detlist),nvar) minnprec(l*nvar+%rows(detlist),nvar) bmean(nvar*(l*nvar+%rows(detlist))) bdiff(nvar*(l*nvar+%rows(detlist))) ux(nvar*(l*nvar+%rows(detlist)))
do i=1,nvar
do j=1,nvar
do k=1,l
comp minnmean((j-1)*l+k,i)= %if(i==j.and.k==1,lmvector(j),0)
comp minnprec((j-1)*l+k,i)= olssee(j)/olssee(i)*%if(i==j,1.0/tight,1.0/(other*tight))
end do k
end do j
do j=1,%rows(detlist)
comp minnmean(l*nvar+j,i)=0.0,minnprec(l*nvar+j,i)=0.0
end do j
end do i
*
ewise minnprec(i,j)=minnprec(i,j)^2
comp hprior = %diag(%vec(minnprec)); * Put everything in vec form
comp bprior = %vec(minnmean)