Synopsis

We are interested in an association between response y and a predictor x. To this end a regression model (y ~ x) is fitted to the data.

Adding another predictor z into the regression model (y ~ x + z) may have a dramatic impact on the association between the response y and the predictor x.

1) A study

An immunological variable y was measured on healthy controls (K) and on patients with a certain diagnosis (D).

We are interested in differences of the immunological variable y among healthy controls and patients.

We also have data on age of the participants of the study.

2) EDA

2.1) Descriptive stat

Characteristic K, N = 191 D, N = 1781
y 10.6 (2.2) 6.2 (2.4)
Age 35 (9) 74 (10)

1 Mean (SD)

2.2) Boxplot, QQplot, Crossplot

3) Regression model M1: y ~ Group

3.1) Based on the regression model, test of hypothesis that the population mean of y is the same for subpopulation K and D

contrast estimate SE df t.ratio p.value
K - D 4.4 0.6 195 7.5 0

3.2) Plot for Group

Digression: T test

estimate estimate1 estimate2 statistic p.value parameter conf.low conf.high method alternative
4.4 10.6 6.2 8.3 0 23.1 3.3 5.5 Student Two Sample t-test two.sided

NOTE: the linear hypothesis test based on the regression model,

and t test (w equal variance) give the same results.

4) Regression model M2: y ~ Group + Age

4.1) Based on the regression model, test of hypothesis that the population mean of y is the same for subpopulation K and D

contrast estimate SE df t.ratio p.value
K - D -4.8 0.3 194 -17.3 0

4.2) Marginal means at a specified age (Age = 50)

Group emmean SE df lower.CL upper.CL
K 7.0 0.2 194 6.7 7.4
D 11.8 0.1 194 11.5 12.1

4.2.1) Plot for Group at Age = 50

4.3) Plot for Age

Group Age.trend SE df lower.CL upper.CL
K -0.24 0.01 194 -0.25 -0.23
D -0.24 0.01 194 -0.25 -0.23

5) Summary

From the regression model M1 (y ~ Group), we have drawn the conclusion that the population mean of y in control group K (estimated to be 10.6) is statistically significantly higher (pval < 0.001) than the mean in patients subpopulation D (estimated to be 6.2). In other words, the difference of means, K minus D, was 4.4, and it was statistically significant.

When the new information on age of the subjects was added into regression, then the M2-based test of equality of the subpopulation means of y was the opposite: the mean difference between K and D is -4.8, and it is statistically significant. Hence, after taking into account the age of subjects, the mean of y in K turns out to be significantly lower than in D.

Session info

─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.0.5 (2021-03-31)
 os       CentOS Stream 8
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Bratislava
 date     2024-02-23
 pandoc   3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)

─ Packages ───────────────────────────────────────────────────────────────────
 package    * version   date (UTC) lib source
 broom      * 1.0.5     2023-06-09 [1] CRAN (R 4.0.5)
 emmeans    * 1.7.5     2022-06-22 [1] CRAN (R 4.0.5)
 ggplot2    * 3.4.4     2023-10-12 [1] CRAN (R 4.0.5)
 ggpubr     * 0.4.0.999 2021-07-17 [1] Github (kassambara/ggpubr@ac5a01f)
 gtsummary  * 1.5.0     2021-10-16 [1] CRAN (R 4.0.5)
 kableExtra * 1.3.4     2021-02-20 [1] CRAN (R 4.0.5)
 MASS       * 7.3-57    2022-04-22 [1] CRAN (R 4.0.5)
 multcomp   * 1.4-17    2021-04-29 [1] CRAN (R 4.0.5)
 mvtnorm    * 1.1-1     2020-06-09 [1] CRAN (R 4.0.5)
 patchwork  * 1.1.3     2023-08-14 [1] CRAN (R 4.0.5)
 sjPlot     * 2.8.12    2022-12-13 [1] Github (strengejacke/sjPlot@4058580)
 survival   * 3.5-7     2023-08-14 [1] CRAN (R 4.0.5)
 TH.data    * 1.0-10    2019-01-21 [1] CRAN (R 4.0.5)

 [1] /home/mg/R/x86_64-pc-linux-gnu-library/4.0
 [2] /opt/R/4.0.5/lib/R/library

──────────────────────────────────────────────────────────────────────────────