Biostatistics III in R

Exercise 14. Non-collapsibility of proportional hazards models


We simulate for time-to-event data assuming constant hazards and then investigate whether we can estimate the underlying parameters. Note that the binary variable $X$ is essentially a coin toss and we have used a large variance for the normally distributed $U$.

library('knitr')
read_chunk('../q14.R')
opts_chunk$set(cache=FALSE)

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.


The assumed causal diagram is reproduced below:

    \usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,matrix}
    \begin{tikzpicture}[->,bend angle=20,semithick,>=stealth']
      \matrix [matrix of nodes,row sep=10mm, column sep=15mm]
      {
        |(X)| $X$ & |(C)| $C$ \\
        & |(T)| $T$ & |(Y)| $(Y,\Delta)$ \\
        |(U)| $U$ \\
      };
      \begin{scope}[every node/.style={auto}]
        \draw (X) to node[anchor=south] {1} (T);
        \draw (U) to node[anchor=south] {1} (T);
        \draw (T) to node[anchor=north] {} (Y);
        \draw (C) to node[anchor=north] {} (Y);
      \end{scope}
    \end{tikzpicture}

(a) Fitting models with both $X$ and $U$ ##

For constant hazards, we can fit (i) Poisson regression, (ii) Cox regression and (iii) flexible parametric survival models.


It may be useful to investigate whether the hazard ratio for $X$ is time-varying hazard ratio and the form for survival.


(b) Fitting models with only $X$ ##

We now model by excluding the variable $U$. This variable could be excluded when it is not measured or perhaps when the variable is not considered to be a confounding variable -- from the causal diagram, the two variables $X$ and $U$ are not correlated and are only connected through the time variable $T$.



Again, we suggest investigating whether the hazard ratio for $X$ is time-varying.


What do you see from the time-varing hazard ratio? Is $U$ a potential confounder for $X$?

(c) Rarer outcomes ##

We now simulate for rarer outcomes by changing the censoring distribution:




What do you observe?

(d) Less heterogeneity ##

We now simulate for less heterogeneity by changing the reducing the standard deviation for the random effect $U$ from 3 to 1.




What do you observe?

(e) Accelerated failure time models

As an alternative model class, we can fit accelerated failure time models with a smooth baseline survival function. We can use the rstpm2::aft function, which uses splines to model baseline survival. Using the baseline simulation, fit and interpret smooth accelerated failure time models:




Try the biostat3 package in your browser

Any scripts or data that you put into this service are public.

biostat3 documentation built on Oct. 29, 2024, 5:07 p.m.