This is prostate data from 316 indviduals with 20 variables recorded for each indvidual. Recorded data includes prostate size, size of tumour, family history, chemotherapy and radiotherapy reception, adjuvant chemotherapy and multiple other parameters.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
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", "Hx 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, mean, na.rm=TRUE))
## Warning: There was 1 warning in `summarize()`.
## ℹ In argument: `across(age:preop_psa, mean, na.rm = TRUE)`.
## ℹ In group 1: `aa = 0` and `fam_hx = 0`.
## Caused by warning:
## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
## Supply arguments directly to `.fns` through an anonymous function instead.
##
## # Previously
## across(a:b, mean, na.rm = TRUE)
##
## # Now
## across(a:b, \(x) mean(x, na.rm = TRUE))
## `summarise()` has grouped output by 'aa'. You can override using the `.groups`
## argument.
## # A tibble: 4 × 5
## # Groups: aa [2]
## aa fam_hx age p_vol preop_psa
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0 0 61.8 56.9 8.06
## 2 0 1 59.5 57.3 7.22
## 3 1 0 60.7 54.3 9.90
## 4 1 1 60.1 51.4 8.71
Analysing mean data on age, prostate volume and preop psa of white and african american people shows taht those african americans who do not have a family history of prostate cancer have a larger prostate size prior to surgery. African Americans also seem to have a larger prostate size at time of presentation for sugery. This may relate to later presentation or diagnosis in African americans. Underlying cause of this may be related to health care inequalities. It may also be that African Americans on average have a larger prostate size.
You can also embed plots, for example:
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 Vol', y = "Preoperative PSA",
title = 'Relationship between prostate volume and PSA\n Subdivided by Family History and Race') +
theme(legend.position = "bottom")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 11 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 11 rows containing missing values or values outside the scale range
## (`geom_point()`).
Now that the data is visualised, it appears that the slope of psa is steeper in white population without family history compared to white indviduals with family history of prostate CA. The slope of prostate volume and PSA is almost flat in african american race.
prostate_factors |>
t_test(formula = preop_psa ~ aa, detailed = TRUE)
## # A tibble: 1 × 15
## estimate estimate1 estimate2 .y. group1 group2 n1 n2 statistic p
## * <dbl> <dbl> <dbl> <chr> <chr> <chr> <int> <int> <dbl> <dbl>
## 1 -1.89 7.86 9.75 preop… White Afric… 259 54 -1.96 0.0534
## # ℹ 5 more variables: df <dbl>, conf.low <dbl>, conf.high <dbl>, method <chr>,
## # alternative <chr>
The above two groups when tested for a significant difference in their means showed a difference of -1.89 which did not reach statistical significance with a p value of 0.0534. CI for the above means was -3.8 to 0.02.
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.