# Bayesian estimation using Gibbs sampling for financial models

I am trying to do Gibbs sampling, from this paper.

This is a CIR financial model, I want to do Gibbs on its parameters:
$$y(t+{\Delta}^{+})=y(t)+(\alpha-\beta y(t)){\Delta}^{+}+\sigma \sqrt{y(t)}{\epsilon}_{t}$$

The conditionals are:

Step 1: ${y}_{t,j+1}^{*}|{y}_{t,j}^{*},\theta\ \tilde{\ }\ N({y}_{t,j}^{*}+(\alpha-\beta {y}_{t,j}^{*})\Delta, {\sigma}^{2}\Delta {y}_{t,j}^{*})$

Step 2: $\psi|Y,{Y}^{*},{\sigma}^{2}\ \tilde{}\ N(\mu, {\Lambda}^{-1})$

Step 3: $\sigma|Y,{Y}^{*}, \psi\ \tilde{}\ inverse-gamma(E, F)$
$E=(T-1)(M+1)/2$, and $F=\sum\limits_{t=1}^{T-1}{\sum\limits_{j=0}^{M}{\frac{{{\left( y_{t,j+1}^{*}-\left[ y_{t,j}^{*}+(\alpha -\beta y_{t,j}^{*})\Delta \right] \right)}^{2}}}{2y_{t,j}^{*}}}}$
Repeat Gibbs between step 2 and 3.

Notations: $\theta=(\psi,{\sigma}^{2})$ and $\psi=(\alpha, \beta)$

I get negative numbers when sampling from inverse-gamma, I use rinvgamma(). What am I doing wrong?

• The corresponding continuous model is guaranteed to remain positive, but the discrete model does not have that property: $y_t$ can end up negative, and the process is no longer defined after that point. Could this be the cause of your problem? – Vincent Zoonekynd Apr 27 '12 at 1:37
• Sorry, I don't know why I said negative, I didn't get negative numbers. I actually get this... – user1061210 Apr 27 '12 at 3:33
• @VincentZoonekynd rinvgamma(1, 5323, 32.724) spits out 0.005986. And this is my σ, which is unbelievably small! I tried different dataset, still same thing. I blame the algorithm. – user1061210 Apr 27 '12 at 3:44
• This may be $\sigma^2$, rather than $\sigma$. – Vincent Zoonekynd Apr 27 '12 at 4:36
• @VincentZoonekynd I see, maybe I am misreading the paper? But the author says $\sigma$~$IG(1,E,F)$, I did so. Am I making a mistake? The $\sigma$ is almost 0. – user1061210 Apr 27 '12 at 4:44