# Gibbs sampling for the latent variables in Sample Selected Probit

Consider the following model of data generation:

$\ y_1 = I(y_1^*>0) \ where\ y_1^* = \beta_1X_1+\epsilon_1$

$\ y_2 = I(y_2^*>0)*y_1 \ where\ y_2^* = \beta_2X_2+\epsilon_2$

$\ y_3 = k*y_2 \ if \ \gamma_{k-\ 1} \leq y_3^* \lt \gamma_k \ for \ k = 1,2,..K \ where\ y_3^* = \beta_3X_3+\epsilon_3$

Moreover,

$(\epsilon_1, \epsilon_2, \epsilon_3) \sim N(0,\Sigma)$

Where,

$\Sigma = $$\begin{pmatrix} 1 & \sigma_1 & \sigma_2\\ \sigma_1 & 1 & \sigma_3\\ \sigma_2 & \sigma_3 & 1\\\ \end{pmatrix}$$$

Can I sample the latent variables in the following sequential manner?

$\ y_1^*|y_2^*,y_3^*$

$\sim TN(\mu_1, \delta_1^2)|_{0,+\infty} \ when \ y_1 = 1$

$\sim TN(\mu_1, \delta_1^2)|_{-\infty, 0} \ when \ y_1 = 0$

$Where, \$

$\mu_1 = \beta_1X_1'+ $$\begin{pmatrix} \sigma_1\\ \sigma_2 \\ \end{pmatrix}'$$ $$\begin{pmatrix} \ 1 & \sigma_3\\ \sigma_3 & 1\\\ \end{pmatrix}^{-1}$$ $$\begin{pmatrix} \ y_2^* - \beta_2X_2'\\ \ y_3^* - \beta_3X_3'\\ \end{pmatrix}$$$ $\delta_1^2 = 1- $$\begin{pmatrix} \sigma_1\\ \sigma_2 \\ \end{pmatrix}'$$ $$\begin{pmatrix} \ 1 & \sigma_3\\ \sigma_3 & 1\\\ \end{pmatrix}^{-1}$$ $$\begin{pmatrix} \sigma_1\\ \sigma_2 \\ \end{pmatrix}$$$

$\ y_2^*|y_1^*,y_3^*$

$\sim TN(\mu_2, \delta_2^2)|_{0,+\infty} \ when \ y_1 = 1 \ and \ y_2 = 1$

$\sim TN(\mu_2, \delta_2^2)|_{-\infty, 0}\ when \ y_1 = 1 \ and \ y_2 = 0$

$\sim N(\mu_2, \delta_2^2) \ when \ y_1 = 0$

$Where, \$

$\mu_2 = \beta_2X_2'+ $$\begin{pmatrix} \sigma_1\\ \sigma_3 \\ \end{pmatrix}'$$ $$\begin{pmatrix} \ 1 & \sigma_2\\ \sigma_2 & 1\\\ \end{pmatrix}^{-1}$$ $$\begin{pmatrix} \ y_1^* - \beta_1X_1'\\ \ y_3^* - \beta_3X_3'\\ \end{pmatrix}$$$ $\delta_2^2 = 1- $$\begin{pmatrix} \sigma_1\\ \sigma_3 \\ \end{pmatrix}'$$ $$\begin{pmatrix} \ 1 & \sigma_2\\ \sigma_2 & 1\\\ \end{pmatrix}^{-1}$$ $$\begin{pmatrix} \sigma_1\\ \sigma_3 \\ \end{pmatrix}$$$

$\ y_3^*|y_1^*,y_2^*$

$\sim TN(\mu_3, \delta_3^2)|_{\gamma_k,\gamma_{k+\ 1}} \ when \ y_3 = k$

$\sim N(\mu_3, \delta_3^2) \ when \ y_3 = 0$

$Where, \$

$\mu_3 = \beta_3X_3'+ $$\begin{pmatrix} \sigma_2\\ \sigma_3 \\ \end{pmatrix}'$$ $$\begin{pmatrix} \ 1 & \sigma_1\\ \sigma_1 & 1\\\ \end{pmatrix}^{-1}$$ $$\begin{pmatrix} \ y_1^* - \beta_1X_1'\\ \ y_2^* - \beta_2X_2'\\ \end{pmatrix}$$$ $\delta_3^2 = 1- $$\begin{pmatrix} \sigma_2\\ \sigma_3 \\ \end{pmatrix}'$$ $$\begin{pmatrix} \ 1 & \sigma_1\\ \sigma_1 & 1\\\ \end{pmatrix}^{-1}$$ $$\begin{pmatrix} \sigma_2\\ \sigma_3 \\ \end{pmatrix}$$$

-