library('knitr') read_chunk('../q2.R') opts_chunk$set(cache=FALSE)
Load dependencies
We define two 1/0 variables for the events. We then list the first few observations to get an idea about the data.
We now tabulate the distribution of the melanoma patients by cancer stage at diagnosis.
We then plot the survival and survival by stage.
Survival depends heavily on stage. It is interesting to note that patients with stage 0 (unknown) appear to have a similar survival to patients with stage 1 (localized).
As an extension, we can use thebshazard
to calculate the hazards with confidence intervals (see below). Note, however, that the bshazard function will adjust for covariates rather than stratify by covariates. This means that we need to divide the dataset into strata and calculate the smoothed hazards separately. I have shown one approach using dplyr
for dividing the data, with the plots use tinyplot
and ggplot
, which allows for over-lapping confidence intervals (using the alpha
transparency argument).
survRate
commandThe time unit is years (since we specified surv_mm/12
as the analysis
time). Therefore, the units of the rates shown above are
events/person-years.
We can also do this using more general tools:
Here we tabulate crude rates per 1000 person-years. For example,
Below we see that the crude mortality rate is higher for males than for females.
We see that the crude mortality rate is higher for males than females, a difference which is also reflected in the survival and hazard curves:
The majority of patients are alive at end of study. 1,913 died from cancer while 1,134 died from another cause. The cause of death is highly depending of age, as young people die less from other causes. To observe this we tabulate the events by age group.
The survival is worse for all-cause survival than for cause-specific, since you now can die from other causes, and these deaths are incorporated in the Kaplan-Meier estimates. The ”other cause” mortality is particularly present in patients with localised and unknown stage.
By comparing Kaplan-Meier estimates for cancer deaths with all-cause mortality conditioned on age over 75 years, we see that the “other” cause mortality is particularly influential in patients with localised and unknown stage. Patients with localised disease, have a better prognosis (i.e. the cancer does not kill them), and are thus more likely to experience death from another cause. For regional and distant stage, the cancer is more aggressive and is the cause of death for most of these patients (i.e. it is the cancer that kills these patients before they have “the chance” to die from something else).
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.