Analysis of Prostate Data

This is a file for practicing the analysis of prostate data.

prostate %>% 
  mutate(aa = factor(aa, levels = c(0,1), 
                     labels = c("White", "African-American"))) %>% 
  mutate(fam_hx = factor(fam_hx, levels = c(0,1), 
      labels = c("No Family History", "FHx of Prostate Cancer"))) ->
prostate_factors
prostate %>% 
  select(age, p_vol, preop_psa, aa, fam_hx) %>% 
  group_by(aa, fam_hx) %>% 
  summarize(across(age:preop_psa, \(x) mean(x, na.rm=TRUE)))

Including Plots

ggplot(prostate_factors) + 
  aes(x = p_vol, y = preop_psa, col = aa) + 
  geom_point() +
  geom_smooth(method = "lm") +
  facet_grid(aa ~ fam_hx) +
  labs(x = 'Prostate Volume', y = "Preoperative PSA",
       title = 'Relationship Between Prostate Volume and Preop PSA,\nSubdivided by Family History and Race') +
  theme(legend.position = "bottom")

ggplot(prostate_factors, aes(x = p_vol, y = preop_psa, col = as.factor(aa))) + 
  geom_point(alpha = 0.7) +
  geom_smooth(method = "lm", se = FALSE) + 
  facet_grid(aa ~ fam_hx) +
  labs(x = "Prostate Volume", y = "Preoperative PSA",
       title = "Relationship Between Prostate Volume and Preop PSA,\nSubdivided by Family History and Race",
       color = "Race") + 
  theme_minimal() +
  theme(legend.position = "bottom", legend.direction = "horizontal")

Statistical testing

tetsting for differences in mean between african americn and white

prostate_factors %>% 
  t_test(formula = preop_psa ~ aa,
         detailed = TRUE)