9.5 Exercises
Show that the posterior distribution of \boldsymbol{\beta} \mid \sigma^2, \boldsymbol{D} is N(\boldsymbol{\beta}_n, \boldsymbol{B}_n), where \boldsymbol{B}_n = (\boldsymbol{B}_0^{-1} + \sum_{i=1}^N \boldsymbol{X}_i^{\top} \boldsymbol{V}_i^{-1} \boldsymbol{X}_i)^{-1}, \boldsymbol{\beta}_n = \boldsymbol{B}_n (\boldsymbol{B}_0^{-1} \boldsymbol{\beta}_0 + \sum_{i=1}^N \boldsymbol{X}_i^{\top} \boldsymbol{V}_i^{-1} \boldsymbol{y}_i).
The relation between productivity and public investment example continues
- Perform inference of this example using our GUI.
- Program from scratch a Gibbs sampling algorithm to perform this application. Set \boldsymbol{\beta}_0 = \boldsymbol{0}_5, \boldsymbol{B}_0 = \boldsymbol{I}_5, \alpha_0 = \delta_0 = 0.001, d_0 = 5 and \boldsymbol{D}_0 = \boldsymbol{I}_1.
- Perform inference in this example assuming that \mu_{it} \mid \tau_{it} \sim N(0, \sigma^2 / \tau_{it}) and \tau_{it} \sim G(v/2, v/2) setting v = 5.
Simulation exercise of the longitudinal normal model continues
Assume that y_{it} = \beta_0 + \beta_1 x_{it1} + \beta_2 x_{it2} + \beta_3 x_{it3} + \beta_4 z_{i1} + b_i + w_{it1} b_{i1} + \mu_{it}, where x_{itk} \sim N(0, 1), k = 1, 2, 3, z_{i1} \sim B(0.5), w_{it1} \sim N(0, 1), b_i \sim N(0, 0.7^{1/2}), b_{i1} \sim N(0, 0.6^{1/2}), \mu_{it} \sim N(0, 0.1^{1/2}), \boldsymbol{\beta} = [0.5, 0.4, 0.6, -0.6, 0.7]^{\top}, i = 1, 2, \dots, 50, and the sample size is 2,000 in an unbalanced panel structure. In addition, we assume that \boldsymbol{b}_i depends on \boldsymbol{z}_i = [1, z_{i1}]^{\top} such that \boldsymbol{b}_i \sim N(\boldsymbol{Z}_i \boldsymbol{\gamma}, \boldsymbol{D}) where \boldsymbol{Z}_i = \boldsymbol{I}_{K_2} \otimes \boldsymbol{z}_i^{\top}, and \boldsymbol{\gamma} = [1, 1, 1, 1]. The prior for \boldsymbol{\gamma} is N(\boldsymbol{\gamma}_0, \boldsymbol{\Gamma}_0) where we set \boldsymbol{\gamma}_0 = \boldsymbol{0}_4 and \boldsymbol{\Gamma}_0 = \boldsymbol{I}_4.
- Perform inference in this model without taking into account the dependence between \boldsymbol{b}_i and z_{i1}, and compare the posterior estimates with the population parameters.
- Perform inference in this model taking into account the dependence between \boldsymbol{b}_i and z_{i1}, and compare the posterior estimates with the population parameters.
Doctor visits in Germany continues I
Replicate this example using our GUI, which by default does not fix the over-dispersion parameter (\sigma^2), and compare the results with the results of this example in Section 9.2.
Simulation exercise of the longitudinal logit model
Perform a simulation exercise to assess the performance of the hierarchical longitudinal logit model. The point of departure is to assume that y_{it}^* = \beta_0 + \beta_1 x_{it1} + \beta_2 x_{it2} + \beta_3 x_{it3} + b_i + w_{it1} b_{i1}, where x_{itk} \sim N(0, 1), k = 1, 2, 3, w_{it1} \sim N(0, 1), b_i \sim N(0, 0.7^{1/2}), b_{i1} \sim N(0, 0.6^{1/2}), \boldsymbol{\beta} = [0.5, 0.4, 0.6, -0.6]^{\top}, i = 1, 2, \dots, 50, and y_{it} \sim B(\pi_{it}), where \pi_{it} = \frac{1}{1 + \exp(y_{it}^*)}. The sample size is 1,000 in an unbalanced panel structure.
- Perform inference using the command MCMChlogit fixing the over-dispersion parameter, and using \boldsymbol{\beta}_0 = \boldsymbol{0}_4, \boldsymbol{B}_0 = \boldsymbol{I}_4, \alpha_0 = \delta_0 = 0.001, d_0 = 2, and \boldsymbol{D}_0 = \boldsymbol{I}_2.
- Program from scratch a Metropolis-within-Gibbs algorithm to perform inference in this simulation.
Doctor visits in Germany continues II
Take a sub-sample of the first 500 individuals of the dataset 9VisitDoc.csv to perform inference in the number of visits to doctors (DocNum) with the same specification of the example of Doctor visits in Germany in Section 9.2.