One-Way ANOVA for Clinical Data

ANOVA Output

One-Way Analysis of Variance

options(knitr.kable.NA = '')

fit1 <- aov(formula = FREEDIST ~ GPID, data = CLINICAL)

fit2 <- lm(formula = FREEDIST ~ GPID, data = CLINICAL)

fit1 %>% 
  tidy() %>% 
  kable(align = 'lcccc', col.names = c('','Degrees of Freedom','Sum of Squares','Mean Square','F','P Value'), digits = 3)
Degrees of Freedom Sum of Squares Mean Square F P Value
GPID 2 38.532 19.266 4.392 0.015
Residuals 108 473.716 4.386

Mean Plot with 90% Confidence Interval

CLINICAL %>% 
  group_by(GPID) %>% 
  summarize(n = n(), mean = mean(FREEDIST), sd = sd(FREEDIST),
            ci = qt(0.9, df = n-1)*sd /sqrt(n)) %>% 
  ggplot(aes(x = GPID, y = mean, group = 1))+
    geom_line(color = "black")+
    geom_errorbar(aes(ymin = mean - ci,
                      ymax = mean + ci), 
                  width = .1,
                  color = "black")+
    geom_point(size = 5, color = "deepskyblue4")+
  theme_minimal()+
  labs(y ="FREEDIST Mean", x = "Group ID")

Tukey multiple comparisons of means: 90% family-wise confidence level

TukeyHSD(fit1,conf.level = .9) %>% 
  tidy() %>% 
  select(-term,-null.value) %>% 
  kable(align = 'lcccc', digits = 3, col.names = c('Group Contrast','Mean Difference','Low CI','High CI','Adjusted P Value'), 
        caption = 'Tukey multiple comparisons of means: 90% family-wise confidence level')
Tukey multiple comparisons of means: 90% family-wise confidence level
Group Contrast Mean Difference Low CI High CI Adjusted P Value
2-1 0.792 -0.218 1.802 0.239
3-1 1.441 0.431 2.451 0.011
3-2 0.649 -0.361 1.659 0.381

90% family-wise confidence level

TukeyHSD(fit1,conf.level = .9) %>% 
  tidy() %>% 
  ggplot(aes(x = estimate, y = contrast))+
  geom_errorbar(aes(xmin = conf.low, xmax = conf.high), width = .2)+
  geom_point(size = 5, color = 'deepskyblue4')+
  geom_vline(xintercept = 0, color = 'red', alpha = .5, linetype = 'dashed')+
  theme_minimal()+
  labs(y = 'Group Contrast', x = 'Difference in mean levels', 
    caption = '*Difference in mean levels not crossing zero indicates a significant relationship.' )

Descriptives & Data

Data Table

CLINICAL %>% 
  select(GPID, FREEDIST) %>% 
  pivot_wider(names_from = GPID, values_from = FREEDIST, names_prefix = "Group ") %>% 
  kable()
Group 1 Group 2 Group 3
9.00, 9.67, 6.67, 9.00, 7.67, 10.33, 8.67, 9.67, 14.67, 6.33, 7.67, 7.00, 8.00, 7.33, 10.00, 12.67, 6.00, 8.67, 5.33, 8.67, 7.67, 5.67, 8.00, 12.00, 9.00, 5.00, 7.00, 5.33, 8.00, 6.33, 9.33, 5.00, 8.33, 9.00, 7.33, 8.00, 9.00 11.00, 11.33, 9.67, 7.67, 12.33, 12.00, 5.67, 7.00, 6.33, 9.00, 8.00, 11.67, 7.33, 8.00, 10.00, 7.33, 11.33, 8.67, 7.33, 8.33, 8.67, 7.33, 5.33, 11.00, 8.00, 8.33, 8.67, 7.67, 12.00, 8.33, 6.00, 11.33, 9.67, 11.00, 9.33, 10.00, 9.67 9.00, 6.67, 9.67, 5.33, 5.33, 14.00, 10.00, 7.00, 8.00, 8.67, 9.33, 8.33, 9.67, 9.00, 8.00, 9.00, 12.67, 14.00, 9.67, 10.33, 10.33, 10.33, 16.33, 7.67, 9.00, 8.00, 10.33, 9.67, 10.33, 8.33, 11.33, 8.00, 11.33, 9.33, 13.00, 9.67, 9.67

Descriptive Statistics

CLINICAL %>% 
  select(GPID, FREEDIST) %>% 
  group_by(GPID) %>% 
  summarize(n = n(), mean = mean(FREEDIST), sd = sd(FREEDIST), min = min(FREEDIST), max = max(FREEDIST)) %>% 
  kable(align = 'c', col.names = c('Group ID','Frequency', 'Mean', 'Standard Deviation','Minimum','Maximum'), digits = 2)
Group ID Frequency Mean Standard Deviation Minimum Maximum
1 37 8.19 2.08 5.00 14.67
2 37 8.98 1.91 5.33 12.33
3 37 9.63 2.27 5.33 16.33