# Biostatistics III in R

#### Code by Annika Tillander, Johan Zetterqvist and Mark Clements

# Exercise 9. Localised melanoma: modelling cause-specific mortality using Cox regression

In exercise 7 we modelled the cause-specific mortality of patients diagnosed with localised melanoma using Poisson regression. We will now model cause-specific mortality using Cox regression and compare the results to those we obtained using the Poisson regression model.

To fit a Cox proportional hazards model (for cause-specific survival) with calendar period as the only explanatory variable, the following commands can be used. Note that we are censoring all survival times at 120 months (10 years) in order to facilitate comparisons with the Poisson regression model in exercise 7.

You may have to install the required packages the first time you use them. You can install a package by `install.packages("package_of_interest")` for each package you require.

    library(biostat3)
    library(dplyr)    # for data manipulation
    library(splines)   # ns (recommended package)

    ## Read melanoma data, select subcohorts and create a death indicator
    melanoma.l <- biostat3::melanoma %>%
        filter(stage=="Localised") %>%
        mutate(death_cancer = as.numeric(status=="Dead: cancer"))

    melanoma.l2 <-    mutate(melanoma.l,
                             ## Create a death indicator (only count deaths within 120 months)
                             death_cancer = death_cancer * as.numeric( surv_mm <= 120),
                             ## Create a new time variable
                             surv_mm = pmin(surv_mm, 120))

## (a)

    summary( coxfit9a <- coxph(Surv(surv_mm, death_cancer) ~ year8594,
                               data = melanoma.l2) )

    ## Call:
    ## coxph(formula = Surv(surv_mm, death_cancer) ~ year8594, data = melanoma.l2)
    ##
    ##   n= 5318, number of events= 960
    ##
    ##                             coef exp(coef) se(coef)      z Pr(>|z|)
    ## year8594Diagnosed 85-94 -0.25297   0.77649  0.06579 -3.845 0.000121 ***
    ## ---
    ## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    ##
    ##                         exp(coef) exp(-coef) lower .95 upper .95
    ## year8594Diagnosed 85-94    0.7765      1.288    0.6825    0.8834
    ##
    ## Concordance= 0.533  (se = 0.008 )
    ## Rsquare= 0.003   (max possible= 0.949 )
    ## Likelihood ratio test= 14.83  on 1 df,   p=1e-04
    ## Wald test            = 14.78  on 1 df,   p=1e-04
    ## Score (logrank) test = 14.86  on 1 df,   p=1e-04

Patients diagnosed during 1985–94 experience only 77.7% of the cancer mortality experienced by those diagnosed 1975–84. That is, mortality due to skin melanoma has decreased by 22.3% in the latter period compared to the earlier period. This estimate is not adjusted for potential confounders. There is strong evidence of a statistically significant difference in survival between the two periods (based on the test statistic or the fact that the CI for the hazard ratio does not contain 1).

## (b)

    summary( coxfit3c <- coxph(Surv(surv_mm, death_cancer) ~ year8594,
                               data = melanoma.l) )

    ## Call:
    ## coxph(formula = Surv(surv_mm, death_cancer) ~ year8594, data = melanoma.l)
    ##
    ##   n= 5318, number of events= 1013
    ##
    ##                             coef exp(coef) se(coef)      z Pr(>|z|)
    ## year8594Diagnosed 85-94 -0.25790   0.77267  0.06565 -3.928 8.56e-05 ***
    ## ---
    ## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    ##
    ##                         exp(coef) exp(-coef) lower .95 upper .95
    ## year8594Diagnosed 85-94    0.7727      1.294    0.6794    0.8788
    ##
    ## Concordance= 0.533  (se = 0.008 )
    ## Rsquare= 0.003   (max possible= 0.955 )
    ## Likelihood ratio test= 15.49  on 1 df,   p=8e-05
    ## Wald test            = 15.43  on 1 df,   p=9e-05
    ## Score (logrank) test = 15.51  on 1 df,   p=8e-05

The three test statistics are

        log-rank

        :   14.85

        Wald

        :   $-3.84^2=14.75$ (from the $z$ test above)

        Likelihood ratio