Professor Andy Field
University of Sussex
|




Research Questions
id: the participant’s participant codepost_qol: This is the outcome variable and it measures quality of life after cosmetic surgery.base_qol: We need to adjust our outcome for quality of life before the surgery.days: The number of days after surgery that post-surgery quality of life was measured.clinic: This variable specifies which of 21 clinics the person attended to have their surgery.reason: This variable specifies whether the person had surgery purely to change their appearance or because of a physical reason.Let’s start with ….
\[ \begin{aligned} \text{QoL}_i &= \beta_0 + \beta_1\text{Days}_i + \varepsilon_i \\ \varepsilon_i &\sim N(0,\sigma^2) \end{aligned} \]

OLS model
\[ \begin{aligned} \text{QoL}_i &= \beta_0 + \beta_1\text{Days}_i + \varepsilon_i \\ \end{aligned} \]
Random intercept model (composite)
\[ \begin{aligned} \text{QoL}_{ij} &= (\beta_0 + u_{0j}) + \beta_1\text{Days}_{ij} + \varepsilon_{ij} \\ \text{QoL}_{ij} &= [\beta_0 + \beta_1\text{Days}_{ij}] + [u_{0j} + \varepsilon_{ij}] \\ \end{aligned} \]
Random intercept model (alternative)
\[ \begin{aligned} \text{QoL}_{ij} &= \beta_{0j} + \beta_1\text{Days}_{ij} + \varepsilon_{ij} \\ \beta_{0j} &= \beta_0 + u_{0j} \\ \end{aligned} \]
\[ \begin{aligned} \text{QoL}_{ij} &= [\beta_0 + \beta_1\text{Days}_{ij}] + [u_{0j} + \varepsilon_{ij}] \\ \end{aligned} \]
\[ \begin{aligned} u_0 \sim N(0, \sigma^2_{u_0}) \end{aligned} \]
Random intercept model (composite)
\[ \begin{aligned} \text{QoL}_{ij} &= (\beta_0 + u_{0j}) + \beta_1\text{Days}_{ij} + \varepsilon_{ij} \\ \text{QoL}_{ij} &= [\beta_0 + \beta_1\text{Days}_{ij}] + [u_{0j} + \varepsilon_{ij}] \\ \end{aligned} \]
Random slope model (composite)
\[ \begin{aligned} \text{QoL}_{ij} &= (\beta_0 + u_{0j}) + (\beta_1 + u_{1j})\text{Days}_{ij} + \varepsilon_{ij} \\ \text{QoL}_{ij} &= [\beta_0 + \beta_1\text{Days}_{ij}] + [u_{0j} + u_{1j}\text{Days}_{ij} + \varepsilon_{ij}] \\ \end{aligned} \]
Random slope model (alternative)
\[ \begin{aligned} \text{QoL}_{ij} &= \beta_{0j} + u_{0j} + \beta_1\text{Days}_{ij} + \varepsilon_{ij} \\ \beta_{0j} &= \beta_0 + u_{0j} \\ \beta_{1j} &= \beta_1 + u_{1j} \\ \end{aligned} \]
\[ \begin{aligned} \text{QoL}_{ij} &= [\beta_0 + \beta_1\text{Days}_{ij}] + [u_{0j} + u_{1j}\text{Days}_{ij} + \varepsilon_{ij}] \\ \end{aligned} \]
\[ \begin{aligned} u_1 \sim N(0, \sigma^2_{u_1}) \end{aligned} \]
Random intercept and slope for 1 predictor
\[ \begin{aligned} \begin{bmatrix} u_0 \\ u_1 \end{bmatrix} \sim N\Bigg( \begin{bmatrix} 0 \\ 0 \end{bmatrix}, \begin{bmatrix} \sigma^2_{u_0} & \sigma_{u_0, u_1}\\ \sigma_{u_0, u_1} & \sigma^2_{u_1} \end{bmatrix} \Bigg) \end{aligned} \]
Random intercept and slope for several predictor
\[ \begin{aligned} \begin{bmatrix} u_0 \\ u_1 \\ \vdots \\ u_n \end{bmatrix} \sim N\begin{pmatrix}\begin{bmatrix} 0 \\ 0 \\ \vdots \\ 0 \end{bmatrix}, \begin{bmatrix} \sigma^2_{u_0} & \sigma_{u_0, u_1} &\dots & \sigma_{u_0, u_n}\\ \sigma_{u_0, u_1} & \sigma^2_{u_1} & \dots & \sigma_{u_1, u_n}\\ \vdots & \vdots & \ddots & \vdots\\ \sigma_{u_0, u_n} & \sigma^2_{u_1} & \dots & \sigma^2_{u_n}\\ \end{bmatrix} \end{pmatrix} \end{aligned} \]
Convergence

Normally distrubuted errors
\[ \begin{aligned} \varepsilon_{ij} &\sim N(0,\sigma^2) \end{aligned} \]
Spherical errors
\[ \begin{aligned} \Phi = \begin{bmatrix} \sigma^2_1 & 0 & 0 &\dots & 0\\ 0 & \sigma^2_2 & 0 & \dots & 0\\ 0 & 0 & \sigma^2_3 & \dots & 0\\ \vdots & \vdots & \ddots & \vdots\\ 0 & 0 & 0 & \dots & \sigma^2_n\\ \end{bmatrix} \end{aligned} \]
Composite form
\[ \begin{aligned} \text{QoL}_{ij} &= [\beta_0 + \beta_1\text{Days}_{ij} + \beta_2\text{Pre QoL}_{ij} + \beta_3\text{Reason}_{ij} + \beta_4\text{Days} \times \text{Reason}_{ij}] \\ &\quad + [u_{0j} + u_{1j}\text{Days}_{ij}+ \varepsilon_{ij}] \end{aligned} \]
Separate equations
\[ \begin{aligned} \text{QoL}_{ij} &= \beta_{0j} + \beta_{1j}\text{Days}_{ij} + \beta_2\text{Pre QoL}_{ij} + \beta_3\text{Reason}_{ij} + \beta_4\text{Days} \times \text{Reason}_{ij} + \varepsilon_{ij}\\ \beta_{0j} &= \beta_{0} + u_{0j} \\ \beta_{1j} &= \beta_{1} + u_{1j} \end{aligned} \]

| term | estimate | std.error | statistic | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|
| (Intercept) | 24.75 | 2.06 | 12.03 | 0.00 | 20.72 | 28.79 |
| days | 0.01 | 0.00 | 2.07 | 0.04 | 0.00 | 0.02 |
| reasonPhysical reason | -2.48 | 1.62 | -1.53 | 0.13 | -5.65 | 0.69 |
| base_qol | 0.46 | 0.04 | 11.52 | 0.00 | 0.38 | 0.54 |
| days:reasonPhysical reason | 0.02 | 0.01 | 3.20 | 0.00 | 0.01 | 0.04 |
Convergence failure
cosmetic_mod |>
broom.mixed::tidy(conf.int = T) |>
dplyr::select(-c(effect, group)) |>
knitr::kable(digits = 3) |>
kableExtra::column_spec(4, background = "yellow")| term | estimate | std.error | statistic | df | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|---|
| (Intercept) | 25.081 | 3.599 | 6.969 | 33.008 | 0.000 | 17.759 | 32.404 |
| days | 0.016 | 0.012 | 1.283 | 23.452 | 0.212 | -0.010 | 0.041 |
| reasonPhysical reason | -1.799 | 0.979 | -1.838 | 1532.821 | 0.066 | -3.719 | 0.121 |
| base_qol | 0.470 | 0.024 | 19.523 | 1532.085 | 0.000 | 0.423 | 0.517 |
| days:reasonPhysical reason | 0.015 | 0.004 | 3.441 | 1532.380 | 0.001 | 0.006 | 0.023 |
| sd__(Intercept) | 15.069 | NA | NA | NA | NA | NA | NA |
| cor__(Intercept).days | -0.661 | NA | NA | NA | NA | NA | NA |
| sd__days | 0.054 | NA | NA | NA | NA | NA | NA |
| sd__Observation | 9.272 | NA | NA | NA | NA | NA | NA |
| Sum Sq | Mean Sq | NumDF | DenDF | F value | Pr(>F) | |
|---|---|---|---|---|---|---|
| months | 275.41 | 275.41 | 1 | 19.03 | 3.21 | 0.09 |
| reason | 288.06 | 288.06 | 1 | 1535.47 | 3.36 | 0.07 |
| base_qol | 32785.53 | 32785.53 | 1 | 1534.92 | 382.66 | 0.00 |
| months:reason | 1014.54 | 1014.54 | 1 | 1535.12 | 11.84 | 0.00 |
| term | estimate | std.error | statistic | df | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|---|
| (Intercept) | 25.069 | 4.015 | 6.243 | 22.484 | 0.000 | 16.752 | 33.386 |
| months | 0.482 | 0.397 | 1.215 | 19.617 | 0.239 | -0.346 | 1.311 |
| reasonPhysical reason | -1.792 | 0.977 | -1.834 | 1535.469 | 0.067 | -3.709 | 0.125 |
| base_qol | 0.470 | 0.024 | 19.562 | 1534.925 | 0.000 | 0.423 | 0.517 |
| months:reasonPhysical reason | 0.447 | 0.130 | 3.441 | 1535.124 | 0.001 | 0.192 | 0.703 |
| term | estimate | std.error | statistic | df | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|---|
| (Intercept) | 25.069 | 4.015 | 6.243 | 22.484 | 0.000 | 16.752 | 33.386 |
| months | 0.482 | 0.397 | 1.215 | 19.617 | 0.239 | -0.346 | 1.311 |
| reasonPhysical reason | -1.792 | 0.977 | -1.834 | 1535.469 | 0.067 | -3.709 | 0.125 |
| base_qol | 0.470 | 0.024 | 19.562 | 1534.925 | 0.000 | 0.423 | 0.517 |
| months:reasonPhysical reason | 0.447 | 0.130 | 3.441 | 1535.124 | 0.001 | 0.192 | 0.703 |
Write-up
| term | estimate | std.error | statistic | df | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|---|
| (Intercept) | 25.069 | 4.015 | 6.243 | 22.484 | 0.000 | 16.752 | 33.386 |
| months | 0.482 | 0.397 | 1.215 | 19.617 | 0.239 | -0.346 | 1.311 |
| reasonPhysical reason | -1.792 | 0.977 | -1.834 | 1535.469 | 0.067 | -3.709 | 0.125 |
| base_qol | 0.470 | 0.024 | 19.562 | 1534.925 | 0.000 | 0.423 | 0.517 |
| months:reasonPhysical reason | 0.447 | 0.130 | 3.441 | 1535.124 | 0.001 | 0.192 | 0.703 |
Write-up
| term | estimate | std.error | statistic | df | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|---|
| (Intercept) | 25.069 | 4.015 | 6.243 | 22.484 | 0.000 | 16.752 | 33.386 |
| months | 0.482 | 0.397 | 1.215 | 19.617 | 0.239 | -0.346 | 1.311 |
| reasonPhysical reason | -1.792 | 0.977 | -1.834 | 1535.469 | 0.067 | -3.709 | 0.125 |
| base_qol | 0.470 | 0.024 | 19.562 | 1534.925 | 0.000 | 0.423 | 0.517 |
| months:reasonPhysical reason | 0.447 | 0.130 | 3.441 | 1535.124 | 0.001 | 0.192 | 0.703 |
Write-up
| term | estimate | std.error | statistic | df | p.value | conf.low | conf.high |
|---|---|---|---|---|---|---|---|
| (Intercept) | 25.069 | 4.015 | 6.243 | 22.484 | 0.000 | 16.752 | 33.386 |
| months | 0.482 | 0.397 | 1.215 | 19.617 | 0.239 | -0.346 | 1.311 |
| reasonPhysical reason | -1.792 | 0.977 | -1.834 | 1535.469 | 0.067 | -3.709 | 0.125 |
| base_qol | 0.470 | 0.024 | 19.562 | 1534.925 | 0.000 | 0.423 | 0.517 |
| months:reasonPhysical reason | 0.447 | 0.130 | 3.441 | 1535.124 | 0.001 | 0.192 | 0.703 |
Write-up
| reason | Coefficient | SE | CI | CI_low | CI_high | t | df_error | p |
|---|---|---|---|---|---|---|---|---|
| Change appearance | 0.482 | 0.397 | 0.95 | -0.346 | 1.311 | 1.215 | 19.623 | 0.239 |
| Physical reason | 0.930 | 0.401 | 0.95 | 0.094 | 1.765 | 2.316 | 20.558 | 0.031 |
Write-up