Supplementary Exercises#

Warning

This page contains solutions! We recommend attempting each problem before peeking.

1. IHGA Models: Which is the Best?#

The following example is built on an experiment conducted in the 1980s (Hendriksen et al. [1984]). In this study, 572 elderly people living in various villages in Denmark were randomized: 287 to a control group (who received standard care) and 285 to an experimental group (E) who received standard care plus IHGA—a kind of preventive assessment in which each person’s medical and social needs were assessed and acted upon individually. The important outcome was the number of hospitalizations during the three-year life of the study.

Data available as a csv here.

\[\begin{split} \begin{array}{|l|r|r|r|r|r|r|r|r|ccc|} \hline \text{Hospitalizations} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & \text{n} & \text{Mean} & \text{Variance} \\ \hline \text{Control} & 138 & 77 & 46 & 12 & 8 & 4 & 0 & 2 & 287 & 0.944 & 1.54 \\ \text{Treatment} & 147 & 83 & 37 & 13 & 3 & 1 & 1 & 0 & 285 & 0.768 & 1.02 \\ \hline \end{array} \end{split}\]

We will propose several models to assess the IHGA treatment using deviance measures. Implement them and decide which one is the best.

Treatment Effect Additive, Model Normal#

\[\begin{align*} y_i | \mu_i, \sigma_i^2 &\sim \text{Normal}(\mu_i, \sigma_i^2) \\ \mu_i &= \beta_0 + \beta_1 \cdot \text{Group}_i \\ \beta_0, \beta_1 &\sim \mathcal{N}(0, \sigma^2) \\ \sigma_i^2 &\sim \text{Inverse-Gamma}(\alpha, \beta) \end{align*}\]

Treatment Effect Additive; Model Poisson#

\[\begin{align*} y_i | \lambda_i &\sim \text{Poisson}(\lambda_i) \\ \log(\lambda_i) &= \beta_0 + \beta_1 \cdot \text{Group}_i \\ \beta_0, \beta_1 &\sim \mathcal{N}(0, \sigma^2) \end{align*}\]

Treatment Effect Multiplicative; Model Poisson#

\[\begin{align*} y_i | \lambda_i &\sim \text{Poisson}(\lambda_i) \\ \log(\lambda_i) &= \gamma_0 + \gamma_1 \cdot x_i \\ \gamma_0, \gamma_1 &\sim \mathcal{N}(0, \sigma^2) \end{align*}\]

Treatment Effect Multiplicative; Model Poisson with Random Effect#

\[\begin{align*} y_i | \lambda_i &\sim \text{Poisson}(\lambda_i) \\ \log(\lambda_i) &= \gamma_0 + \gamma_1 \cdot x_i + \epsilon_i \\ \epsilon_i &\sim \mathcal{N}(0, \tau_\epsilon) \\ \gamma_0, \gamma_1 &\sim \mathcal{N}(0, \sigma^2) \\ \tau_\epsilon &\sim \text{Gamma}(\alpha, \beta) \end{align*}\]

Treatment Effect Multiplicative; Model Zero-Inflated Poisson#

\[\begin{align*} y_i | \lambda_i, z_i &\sim \text{Poisson}(\lambda_i) \\ \log(\lambda_i) &= \gamma_0 + \gamma_1 \cdot x_i \\ z_i &\sim \text{Bernoulli}(\pi_i) \\ \log\left(\frac{\pi_i}{1 - \pi_i}\right) &= \alpha_0 + \alpha_1 \cdot x_i \\ \gamma_0, \gamma_1, \alpha_0, \alpha_1 &\sim \mathcal{N}(0, \sigma^2) \end{align*}\]

Treatment Effect Multiplicative; Model Zero-Inflated Negative Binomial with Random Effect#

\[\begin{align*} y_i | \lambda_i, \theta_i, z_i &\sim \text{Negative Binomial}(\lambda_i, \theta_i) \\ \log(\lambda_i) &= \gamma_0 + \gamma_1 \cdot x_i + \epsilon_i \\ \epsilon_i &\sim \mathcal{N}(0, \tau_\epsilon) \\ \log(\theta_i) &= \delta_0 + \delta_1 \cdot x_i \\ z_i &\sim \text{Bernoulli}(\pi_i) \\ \log\left(\frac{\pi_i}{1 - \pi_i}\right) &= \alpha_0 + \alpha_1 \cdot x_i \\ \gamma_0, \gamma_1, \delta_0, \delta_1, \alpha_0, \alpha_1 &\sim \mathcal{N}(0, \sigma^2) \\ \tau_\epsilon &\sim \text{Gamma}(\alpha, \beta) \end{align*}\]

Zero-Truncated Poisson Regression#

Implement for zero-truncated Poisson regression for the number of visits for patients who checked in to the hospital at least once.

Hint: Zero truncated Poisson has the same log-likelihood (up to additive constant) as the standard Poisson. In data, ignore 0’s and adjust for the sample size.

2. Sleep Disturbances and Acute Coronary Syndrome#

Acute Coronary Syndrome (ACS) is an umbrella term describing medical conditions related to a sudden drop in blood flow to the heart, with heart attacks being the most well-known example. A longitudinal study (Känel et al. [2022]) measured the Jenkins Sleep Scale (Jenkins et al. [1988] ) for patients three times after they experienced ACS.

The JSS is an abstracted count ranging from 0 to 20 based on how many sleep issues of different types the patient has had over the last month.

In sleep_data.csv, you’ll find the following data:

\[\begin{split} \begin{array}{|l|l|} \hline \textbf{Column name} & \textbf{Description} \\ \hline \text{id} & \text{participant id} \\ \text{time} & \text{time; 1=baseline, 2=3 months, 3=12 months} \\ \text{dcv\_ct} & \text{number of diseased coronary vessels} \\ \text{age} & \text{years} \\ \text{sex} & \text{0=male, 1=female} \\ \text{living\_status} & \text{0=with someone, 1=alone} \\ \text{mi\_type} & \text{index event type; 0=non-STEMI, 1=STEMI} \\ \text{fod} & \text{patient’s self-reported fear of dying, 0–10} \\ \text{helplessness} & \text{patient’s self-reported feelings of helplessness, 0–10} \\ \text{depression} & \text{history of depression; 0=no, 1=yes} \\ \text{apnea} & \text{history of sleep apnea; 0=no, 1=yes} \\ \text{education} & \text{level of education; 1=low, 2=medium, 3=high} \\ \text{ccm} & \text{Charlson comorbidity category; 1=low risk, 2=medium, 3=high} \\ \text{JSS} & \text{JSS-4 total score, 0–20. has missing values!} \\ \hline \end{array} \end{split}\]
  1. Create a Poisson regression model of the JSS, using time, age, and sex as predictors. Perform a posterior predictive check and plot the posterior predictive mean against the observed values.

    The model can be specified as:

    \[\begin{align*} y_{ij} | e_{ij}, \beta_1, \beta_2, \beta_3 &\sim \text{Poisson}(\lambda) \\ \lambda &= \exp(e_{ij} + \beta_1 \text{time}_{ij} + \beta_2 \text{age}_i + \beta_3 \text{sex}_i) \\ e_{ij} | \sigma^2_e &\sim \mathcal{N}(0, \sigma^2_e) \end{align*}\]

    With prior distributions:

    \[\begin{align*} \beta_k &\sim \mathcal{N}(0, \sigma^2 = 25), \quad k = 1, 2, 3 \\ e &\sim \mathcal{N}(0, \sigma^2_e) \\ \tau_e &\sim \text{Gamma}(0.01, 0.01) \end{align*}\]
  2. Use Poisson regression again, but this time add a per-subject random effect (\(u_i\)). Does the posterior predictive better fit the observed values? Why or why not?

    The model can be specified as:

    \[\begin{align*} y_{ij} | e_{ij}, \beta_1, \beta_2, \beta_3, u_i &\sim \text{Poisson}(\lambda) \\ \lambda &= \exp(e_{ij} + \beta_1 \text{time}_{ij} + \beta_2 \text{age}_i + \beta_3 \text{sex}_i + u_i) \\ e_{ij} | \sigma^2_e &\sim \mathcal{N}(0, \sigma^2_e) \\ u_i | \sigma^2_u &\sim \mathcal{N}(0, \sigma^2_u) \end{align*}\]

    With prior for the additional random effect:

    \[ \tau_u \sim \text{Gamma}(0.01, 0.01) \]
  3. With the model from part 2, use Stochastic Search Variable Selection (SSVS) to check out the other predictors. Report the predictors for the top 5 models from the SSVS results. Refit the best model and report the posterior parameters of \(\beta\), \(\tau_e\), and \(\tau_u\).