```{css, echo=FALSE} body .main-container { max-width: 1280px !important; width: 1280px !important; } body { max-width: 1280px !important; }
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The coarsening of the user-specified input data (referred to as 'raw data' below) into the output data set described above starts with the discretization of each patient’s follow-up time into consecutive intervals that are each time_unit days long. Starting at $t=0$, each interval is stamped with a counter denoted by $t$. The first day of the interval stamped with $t=0$ is the subject’s index date. For each subject, the last follow-up interval contains the day when the subject was either censored or follows the interval that contains the day when the subject experienced the outcome of interest.
The next step in the coarsening of the input data consists in simultaneously assigning values for the exposure, outcome, and censoring status for each time interval $t$ in the output data set according to one of the following two logics.
One of the two logics described below is implemented iteratively for $t=0, 1,…$ and for one subject at a time (in parallel if specified) to assign values to the exposure, outcome and censoring variables in the output data set. The notation $A(t)$ (also shorten with $A$) below refers to the exposure status at interval $t$ . The notation $C(t)$ (also shorten with $C$) below refers to the censoring status at interval $t$. The notation $Y(t)$ (also shorten with $Y$) below refers to the outcome status at interval $t$. The diagrams are used as illustration of the scenarios when each assignment rule applies. Note that for each subject and each interval $t$, the exposure, outcome and censoring values are assigned simultaneously. For simplicity, we use the terminology “exposure level” in the tables below to designate a “non-reference exposure level”.
This first logic is implemented when the user sets the first_exp_rule argument of the construct function to 1. The rules below are then implemented iteratively for each interval $t$ of the same subject until (and including) the first time $t$ (if any) when $A(t)$ is assigned the value $j$:
The subject experiences at least one of the exposure levels for at least one day of interval $t$, and $t$ is not the last interval. We denote the most frequent exposure level in interval $t$ by $j$. If the exposure is binary, then $j=1$ by definition. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as the level involved in the tie that the patient experienced last during the interval t.
case_data0 <- data.frame( id = 1:3, content = c("intnum=t", "2021-04-21", "2021-05-20"), start = c("2021-04-21", "2021-04-21", "2021-05-20"), end = c("2021-05-20", NA, NA), group = c(1,3,4), type = c("background","box","box"), style = rep("background-color: #C0C0C0; font-size: 8pt",3) ) case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=1","2021-05-05","2021-05-08","A=2","2021-04-22","2021-05-04"), start=c("2021-05-05","2021-05-05","2021-05-08","2021-04-22","2021-04-22","2021-05-04"), end=c("2021-05-08",NA,NA,"2021-05-04",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #8FCE00; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px", width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=1","2021-05-05","2021-05-17","A=2","2021-04-22","2021-05-04"), start=c("2021-05-05","2021-05-05","2021-05-17","2021-04-22","2021-04-22","2021-05-04"), end=c("2021-05-17",NA,NA,"2021-05-04",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #8FCE00; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
The subject does not experience any of the exposure levels during interval $t$, and $t$ is not the last interval.
case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data0, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "317px",width="1215px")
The subject experiences the failure event during interval $t$ and none of the exposure levels before the failure event.
case_data <- rbind(case_data0,data.frame(id=4, content=c("Y=1"), start=c("2021-05-09"), end=c(NA), type=c("box"), style=c("background-color: #E06666; font-size: 8pt"), group=c(3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "397px", width="1215px")
The subject experiences a right-censoring event during interval $t$ and none of the exposure levels before the censoring event.
case_data <- rbind(case_data0,data.frame(id=4, content=c("C=1"), start=c("2021-05-09"), end=c(NA), type=c("box"), style=c("background-color: #E69138; font-size: 8pt"), group=c(3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "317px",width="1215px")
The subject experiences a right-censoring event during interval $t$ and at least one of the exposure levels before the censoring event. We denote the most frequent exposure level in interval $t$ prior to and including the day of the censoring event by $j$. If the exposure is binary, then $j=1$ by definition. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as the level involved in the tie that the patient experienced last during interval $t$ up to and including the day when the censoring event occurs.
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("C=1","A=2","2021-04-22","2021-05-04","A=1","2021-05-05","2021-05-08"), start=c("2021-05-09","2021-04-22","2021-04-22","2021-05-04","2021-05-05","2021-05-05","2021-05-08"), end=c(NA,"2021-05-04",NA,NA,"2021-05-08",NA,NA), type=c("box","background","box","box","background","box","box"), style=c("background-color: #E69138; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(3,2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("C=1","A=2","2021-04-22","2021-05-04","A=1","2021-05-05","2021-05-17"), start=c("2021-05-19","2021-04-22","2021-04-22","2021-05-04","2021-05-05","2021-05-05","2021-05-17"), end=c(NA,"2021-05-04",NA,NA,"2021-05-17",NA,NA), type=c("box","background","box","box","background","box","box"), style=c("background-color: #E69138; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(3,2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=1<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
The subject experiences the failure event during interval $t$ and at least one of the exposure levels before the failure event. We denote the most frequent exposure level in interval $t$ prior to and including the day of the failure event by $j$. If the exposure is binary, then $j=1$ by definition. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as the level involved in the tie that the patient experienced last during interval $t$ up to and including the day when the failure event occurs.
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("Y=1","A=2","2021-04-22","2021-05-04","A=1","2021-05-05","2021-05-08"), start=c("2021-05-09","2021-04-22","2021-04-22","2021-05-04","2021-05-05","2021-05-05","2021-05-08"), end=c(NA,"2021-05-04",NA,NA,"2021-05-08",NA,NA), type=c("box","background","box","box","background","box","box"), style=c("background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(3,2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "434px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("Y=1","A=2","2021-04-22","2021-05-04","A=1","2021-05-05","2021-05-17"), start=c("2021-05-19","2021-04-22","2021-04-22","2021-05-04","2021-05-05","2021-05-05","2021-05-17"), end=c(NA,"2021-05-04",NA,NA,"2021-05-17",NA,NA), type=c("box","background","box","box","background","box","box"), style=c("background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(3,2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "434px",width="1215px")
For all subsequent intervals $t$ (if any) of the same subject, the following rules are applied iteratively instead. If the variable $X$ referenced below is not specified explicitly by the user in the function construct() (section 3 – see exp_threshold), it is then is set to 0.50 by default in the current implementation of the LtAtStructuR package. We note that case 7a is skipped intentionally below. In all the examples below $X = 0.50$.
If the exposure is binary, $t$ is not the last interval and the average exposure during interval $t \ge X$ then this case applies, and we then define $j=1$. Or, the exposure is not binary and the subject experiences at least one of the exposure levels for at least one day of interval $t$, and $t$ is not the last interval. We then denote the most frequent exposure level in interval $t$ by $j$. If the proportion of days exposed during interval $t$ to level $j \ge X$ then this case applies. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as $A(t-1)$, if $A(t-1)$ was set to one of the levels involved in the tie at time $t$; and, otherwise, $k$ is set to the level involved in the tie that the patient experienced last during the interval $t$.
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=1","2021-05-10","2021-05-19", "A=2","2021-04-22","2021-05-07"), start=c("2021-05-10","2021-05-10","2021-05-19", "2021-04-22","2021-04-22","2021-05-07"), end=c("2021-05-19",NA,NA, "2021-05-07",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #8FCE00; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "391px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-05-05","A=1","2021-05-06","2021-05-20"), start=c("2021-04-21","2021-04-21","2021-05-05","2021-05-06","2021-05-06","2021-05-20"), end=c("2021-05-05",NA,NA,"2021-05-20",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=2<br><b>Variable Assignment:</b><br>A(t)=k=2<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-05-05","A=1","2021-05-06","2021-05-20"), start=c("2021-04-21","2021-04-21","2021-05-05","2021-05-06","2021-05-06","2021-05-20"), end=c("2021-05-05",NA,NA,"2021-05-20",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=3<br><b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
The exposure is binary, $t$ is not the last interval and average exposure during interval $t
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-04-25","A=1","2021-05-06","2021-05-09"), start=c("2021-04-21","2021-04-21","2021-04-25","2021-05-06","2021-05-06","2021-05-09"), end=c("2021-04-25",NA,NA,"2021-05-09",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-05-04","A=1","2021-05-06","2021-05-09"), start=c("2021-04-21","2021-04-21","2021-05-04","2021-05-06","2021-05-06","2021-05-09"), end=c("2021-05-04",NA,NA,"2021-05-09",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
The exposure is binary, $t$ is the last interval and a right-censoring event occurs during the interval. We then compute the average exposure during the days of the interval up to and including the day when $C$ occurs. If this average is $\ge X$ then this case applies and we define $j=1$. Or, the exposure is not binary, $t$ is the last interval, the subject experiences a right-censoring event during interval $t$, and at least one of the exposure levels before the censoring event. We then denote the most frequent exposure level in interval $t$ up to and including the day when the censoring event occurs by $j$. If the proportion of days exposed during interval $t$ to level $h \ge X$ then this case applies. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as $A(t-1)$, if $A(t-1)$ was set to one of the levels involved in the tie at time $t$; and, otherwise, $k$ is set to the level involved in the tie that the patient experienced last during the interval $t$ and up to and including the day when the censoring event occurs.
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=1","2021-05-08","2021-05-17", "A=2","2021-04-22","2021-05-07", "C=1"), start=c("2021-05-08","2021-05-08","2021-05-17", "2021-04-22","2021-04-22","2021-05-07", "2021-05-18"), end=c("2021-05-17",NA,NA, "2021-05-07",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #8FCE00; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-05-05", "A=1","2021-05-06","2021-05-20", "C=1"), start=c("2021-04-21","2021-04-21","2021-05-05", "2021-05-06","2021-05-06","2021-05-20", "2021-05-20"), end=c("2021-05-05",NA,NA, "2021-05-20",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=2<br><b>Variable Assignment:</b><br>A(t)=k=2<br>Y(t)=0<br>C(t)=1<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-05-05", "A=1","2021-05-06","2021-05-20", "C=1"), start=c("2021-04-21","2021-04-21","2021-05-05", "2021-05-06","2021-05-06","2021-05-20", "2021-05-20"), end=c("2021-05-05",NA,NA, "2021-05-20",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=3<br><b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=1<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
The exposure is binary, $t$ is the last interval and a right-censoring event occurs during interval $t$. We then compute the average exposure during the days of the interval up to and including the day when $C$ occurs. If this average is $
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-04-25", "A=1","2021-05-06","2021-05-09", "C=1"), start=c("2021-04-21","2021-04-21","2021-04-25", "2021-05-06","2021-05-06","2021-05-09", "2021-05-09"), end=c("2021-04-25",NA,NA, "2021-05-09",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-05-04", "A=1","2021-05-06","2021-05-09", "C=1"), start=c("2021-04-21","2021-04-21","2021-05-04", "2021-05-06","2021-05-06","2021-05-09", "2021-05-09"), end=c("2021-05-04",NA,NA, "2021-05-09",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
The exposure is binary, $t$ is the last interval and the subject experiences the failure event during interval $t$. We then define $Z$ as the number of days in each interval (i.e., $Z=\text{unitdays}$) and we compute the average exposure during the $Z$ days up to and including the day when the failure event $Y$ occurs. If this average is $\ge X$, then this case applies and we define $j=1$. Or, the exposure is not binary and the subject experiences the failure event during interval $t$, and at least one of the exposure levels before the failure event. We denote the most frequent exposure level during the $Z$ days up to and including the day when the failure event occurs by $j$. If the proportion of days exposed during interval $t$ to level $j \ge X$ then this case applies. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as$ A(t-1)$, if $A(t-1)$ was set to one of the levels involved in the tie at time $t$; and, otherwise, $k$ is set to the level involved in the tie that the patient experienced last during the interval defined by the $Z$ days up to and including the day when the failure event occurs.
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-20","2021-05-05", "A=1","2021-05-06","2021-05-20", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-20","2021-04-20","2021-05-05", "2021-05-06","2021-05-06","2021-05-20", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-05-05",NA,NA, "2021-05-20",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "588px", width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-19","2021-05-03", "A=1","2021-05-04","2021-05-18", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-19","2021-04-19","2021-05-03", "2021-05-04","2021-05-04","2021-05-18", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-05-03",NA,NA, "2021-05-18",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=2<br><b>Variable Assignment:</b><br>A(t)=k=2<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "628px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-19","2021-05-03", "A=1","2021-05-04","2021-05-18", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-19","2021-04-19","2021-05-03", "2021-05-04","2021-05-04","2021-05-18", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-05-03",NA,NA, "2021-05-18",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=3<br><b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "628px",width="1215px")
The exposure is binary, $t$ is the last interval and the subject experiences the failure event during interval $t$. We then define $Z$ as the number of days in each interval (i.e., $Z=\text{unitdays}$) and we compute the average exposure during the $Z$ days up to and including the day when the failure event $Y$ occurs. If this average is $
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-20","2021-04-28", "A=1","2021-05-06","2021-05-09", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-20","2021-04-20","2021-04-28", "2021-05-06","2021-05-06","2021-05-09", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-04-28",NA,NA, "2021-05-09",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "550px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-20","2021-04-28", "A=1","2021-05-06","2021-05-12", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-20","2021-04-20","2021-04-28", "2021-05-06","2021-05-06","2021-05-12", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-04-28",NA,NA, "2021-05-12",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=1<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "550px",width="1215px")
This second logic is implemented when the user sets the first_exp_rule argument of the construct function to 0. The rules below are then implemented iteratively for each interval $t$ of the same subject:
The exposure is binary, $t$ is not the last interval and the average exposure during interval $t \ge X$. We then define $j=1$. Or, the exposure is not binary and the subject experiences at least one of the exposure levels for at least one day of interval $t$, and $t$ is not the last interval. We then denote the most frequent exposure level in interval $t$ by $j$. If the proportion of days exposed during interval $t$ to level $j \ge X$ then this case applies. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as $A(t-1)$, if $A(t-1)$ was set to one of the levels involved in the tie at time $t$; and, otherwise, (including if $t=0$) $k$ is set to the level involved in the tie that the patient experienced last during the interval $t$.
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=1","2021-05-10","2021-05-19", "A=2","2021-04-22","2021-05-07"), start=c("2021-05-10","2021-05-10","2021-05-19", "2021-04-22","2021-04-22","2021-05-07"), end=c("2021-05-19",NA,NA, "2021-05-07",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #8FCE00; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "391px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-05-05","A=1","2021-05-06","2021-05-20"), start=c("2021-04-21","2021-04-21","2021-05-05","2021-05-06","2021-05-06","2021-05-20"), end=c("2021-05-05",NA,NA,"2021-05-20",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=2<br><b>Variable Assignment:</b><br>A(t)=k=2<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-05-05","A=1","2021-05-06","2021-05-20"), start=c("2021-04-21","2021-04-21","2021-05-05","2021-05-06","2021-05-06","2021-05-20"), end=c("2021-05-05",NA,NA,"2021-05-20",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=3<br><b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
The exposure is binary, $t$ is not the last interval and the average exposure during interval $t
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-04-25","A=1","2021-05-06","2021-05-09"), start=c("2021-04-21","2021-04-21","2021-04-25","2021-05-06","2021-05-06","2021-05-09"), end=c("2021-04-25",NA,NA,"2021-05-09",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("A=2","2021-04-21","2021-05-04","A=1","2021-05-06","2021-05-09"), start=c("2021-04-21","2021-04-21","2021-05-04","2021-05-06","2021-05-06","2021-05-09"), end=c("2021-05-04",NA,NA,"2021-05-09",NA,NA), type=c("background","box","box","background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3)), group=c(2,3,4,2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
The exposure is binary, $t$ is the last interval and a right-censoring event occurs during the interval. We then compute the average exposure during the days of the interval up to and including the day when $C$ occurs. If this average is $\ge X$ then this case applies and we define $j=1$. Or, the exposure is not binary, $t$ is the last interval, the subject experiences a right-censoring event during interval $t$, and at least one of the exposure levels before the censoring event. We then denote the most frequent exposure level in interval $t$ up to and including the day when the censoring event occurs by $j$. If the proportion of days exposed during interval $t$ to level $j\ge X$ then this case applies. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as $A(t-1)$, if $A(t-1)$ was set to one of the levels involved in the tie at time $t$; and, otherwise, (including if $t=0$) $k$ is set to the level involved in the tie that the patient experienced last duringthe interval $t$ and up to and including the day when the censoring event occurs.
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=1","2021-05-08","2021-05-17", "A=2","2021-04-22","2021-05-07", "C=1"), start=c("2021-05-08","2021-05-08","2021-05-17", "2021-04-22","2021-04-22","2021-05-07", "2021-05-18"), end=c("2021-05-17",NA,NA, "2021-05-07",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #8FCE00; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-05-05", "A=1","2021-05-06","2021-05-20", "C=1"), start=c("2021-04-21","2021-04-21","2021-05-05", "2021-05-06","2021-05-06","2021-05-20", "2021-05-20"), end=c("2021-05-05",NA,NA, "2021-05-20",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=2<br><b>Variable Assignment:</b><br>A(t)=k=2<br>Y(t)=0<br>C(t)=1<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-05-05", "A=1","2021-05-06","2021-05-20", "C=1"), start=c("2021-04-21","2021-04-21","2021-05-05", "2021-05-06","2021-05-06","2021-05-20", "2021-05-20"), end=c("2021-05-05",NA,NA, "2021-05-20",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=3<br><b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=1<br>tie=1<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "431px",width="1215px")
The exposure is binary, $t$ is the last interval and a right-censoring event occurs during interval $t$. We then compute the average exposure during the days of the interval up to and including the day when $C$ occurs. If this average is $
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-04-25", "A=1","2021-05-06","2021-05-09", "C=1"), start=c("2021-04-21","2021-04-21","2021-04-25", "2021-05-06","2021-05-06","2021-05-09", "2021-05-09"), end=c("2021-04-25",NA,NA, "2021-05-09",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=0")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("A=2","2021-04-21","2021-05-04", "A=1","2021-05-06","2021-05-09", "C=1"), start=c("2021-04-21","2021-04-21","2021-05-04", "2021-05-06","2021-05-06","2021-05-09", "2021-05-09"), end=c("2021-05-04",NA,NA, "2021-05-09",NA,NA, NA), type=c("background","box","box","background","box","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(2,3,4,2,3,4,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=1<br>tie=0<br>A0.warn=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "354px",width="1215px")
The exposure is binary or categorical, $t$ is the last interval but not the first and the subject experiences the failure event during interval $t$. We then define $Z$ as the number of days in each interval (i.e., $Z=\text{unitdays}$) and we compute the average exposure during the $Z$ days up to and including the day when the failure event occurs. If this average is $\ge X$, then this case applies. Or, the exposure is binary or categorical, $t$ is the last and first interval (i.e., $t=0$), the subject experiences the failure event during interval $t$, and at least one of the exposure levels before the failure event. We denote the most frequent exposure between and including the index date and the day when the failure event occurs by "j". If the proportion of days exposed during interval $t$ to level $j \ge X$ then this case applies. If the exposure is not binary then two exposure levels might have equal frequencies. In that case, $j$ is set to level $k$ and an indicator of a tie in exposure frequency is created. Level $k$ is defined as $A(t-1)$, if $A(t-1)$ was set to one of the levels involved in the tie at time $t$;and, otherwise, (including if t=0) $k$ is set to the level involved in the tie that the patient experienced last during , if $t=0$, the interval $t$ and up to and including the day when the failure event occurs and, if $t>0$, the interval of $Z$ days up to and including the day when the failure event occurs.
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-20","2021-05-05", "A=1","2021-05-06","2021-05-20", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-20","2021-04-20","2021-05-05", "2021-05-06","2021-05-06","2021-05-20", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-05-05",NA,NA, "2021-05-20",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=2<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "587px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-19","2021-05-03", "A=1","2021-05-04","2021-05-18", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-19","2021-04-19","2021-05-03", "2021-05-04","2021-05-04","2021-05-18", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-05-03",NA,NA, "2021-05-18",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=2<br><b>Variable Assignment:</b><br>A(t)=k=2<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "625px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-19","2021-05-03", "A=1","2021-05-04","2021-05-18", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-19","2021-04-19","2021-05-03", "2021-05-04","2021-05-04","2021-05-18", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-05-03",NA,NA, "2021-05-18",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>A(t-1)=3<br><b>Variable Assignment:</b><br>A(t)=k=1<br>Y(t)=0<br>C(t)=0<br>tie=1<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "625px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("Z days","2021-04-21","2021-05-18", "A=2","2021-04-29","2021-05-03", "A=1","2021-05-04","2021-05-18", "Y=1"), start=c("2021-04-21","2021-04-21","2021-05-18", "2021-04-29","2021-04-29","2021-05-03", "2021-05-04","2021-05-04","2021-05-18", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-05-03",NA,NA, "2021-05-18",NA,NA, NA), type=c("range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,2,3,4,2,3,4,3))) case_data[1,"content"] <- "intnum=0" case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=1<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "547px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("Z days","2021-04-21","2021-05-18", "A=2","2021-04-21","2021-05-04", "A=1","2021-05-05","2021-05-18", "Y=1"), start=c("2021-04-21","2021-04-21","2021-05-18", "2021-04-21","2021-04-21","2021-05-04", "2021-05-05","2021-05-05","2021-05-18", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-05-04",NA,NA, "2021-05-18",NA,NA, NA), type=c("range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,2,3,4,2,3,4,3))) case_data[1,"content"] <- "intnum=0" case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=j=1<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "586px",width="1215px")
The exposure is binary or categorical, $t$ is the last interval but not the first and the subject experiences the failure event during interval $t$. We denote the most frequent exposure level during the $Z$ days up to and including the day when the failure event occurs by $j$. If the proportion of days exposed during interval $t$ to level $j
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-20","2021-04-28", "A=1","2021-05-06","2021-05-09", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-20","2021-04-20","2021-04-28", "2021-05-06","2021-05-06","2021-05-09", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-04-28",NA,NA, "2021-05-09",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=0<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "550px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:16, content=c("Z days","2021-04-19","2021-05-18", "intnum=t-1","2021-03-22","2021-04-20", "A=2","2021-04-20","2021-04-28", "A=1","2021-05-06","2021-05-12", "Y=1"), start=c("2021-04-19","2021-04-19","2021-05-18", "2021-03-22","2021-03-22","2021-04-20", "2021-04-20","2021-04-20","2021-04-28", "2021-05-06","2021-05-06","2021-05-12", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-04-20",NA,NA, "2021-04-28",NA,NA, "2021-05-12",NA,NA, NA), type=c("range","box","box", "range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,1,3,4,2,3,4,2,3,4,3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=1<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "550px",width="1215px")
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("Z days","2021-04-21","2021-05-18", "A=2","2021-04-29","2021-05-03", "A=1","2021-05-04","2021-05-13", "Y=1"), start=c("2021-04-21","2021-04-21","2021-05-18", "2021-04-29","2021-04-29","2021-05-03", "2021-05-04","2021-05-04","2021-05-13", "2021-05-18"), end=c("2021-05-18",NA,NA, "2021-05-03",NA,NA, "2021-05-13",NA,NA, NA), type=c("range","box","box", "background","box","box", "background","box","box", "box"), style=c(rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3), rep("background-color: #8FCE00; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt"), group=c(1,3,4,2,3,4,2,3,4,3))) case_data[1,"content"] <- "intnum=0" case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>A(t)=0<br>Y(t)=0<br>C(t)=0<br>tie=0<br>A0.warn=1<br><br>A(t+1)=missing<br>Y(t+1)=1<br>C(t+1)=missing")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "513px",width="1215px")
Following the assignment of exposure, outcome and censoring values according to one of the two logics described above, the logic described below is implemented iteratively for $t=0, 1,...$ and for one subject at a time to assign values to the time-dependent covariates in the output data set. The notation $L(t)$ (also shorten with $L$) below refers to the covariate status at interval $t$ . For simplicity, we use the terminology “exposure level” in the tables below to designate a “non-reference exposure level”.
The logic below was designed to insure the fundamental time-ordering assumption between the covariates $L(t)$ and the exposure $A(t)$ or censoring variable $C(t)$ at each interval $t$, i.e., the covariate level at interval $t$ is defined from measurements that either (a) occurred before the exposure or censoring at interval $t$ or (b) are otherwise assumed not to be affected by the exposure and censoring level at time $t$ or thereafter. When the input data sets contain measurements of exposures or censoring events on the same day as covariate measurements, the user can specify separately for each covariate whether the latter assumption (b) holds using the acute_change argument of the setCovariate() function. In addition, the logic below insures that any given input covariate measurement for any given subject is mapped to at most one interval $t$ of that subject and that the measurements assigned to consecutive intervals are chronologically ordered according to their dates of collection specified in the input data sets. Furthermore, for each subject, only the covariate measurements in the cohort data set collected at the index date and the measurements in the corresponding input data sets that are collected strictly after the index dates are considered in the logic below. Note that the covariate assignment rules identified by cases 6 and 8 below depend on the user-specified argument value for the first_exp_rule of the construct() function.
Interval $t$ is the first interval and not the last interval, and the unit is deemed unexposed in this interval. Note that (even when setCovariate(...,acute_change=TRUE)) the covariate value from the cohort data set stamped with the index date (can be missing) is assigned to $L(0)$ in this case because it is assumed that the cohort data set characterizes each subject at the very beginning of the first interval $t=0$.
Measurement exists on index date
case_data <- rbind(case_data0,data.frame(id=4:6, content=c("eGFR=62.95", "eGFR=60.62", "eGFR=59.71"), start=c("2021-04-21", "2021-05-01", "2021-05-15"), end=c(NA, NA, NA), type=c("box", "box", "box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3)), group=c(3,3,3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=62.95")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "274px",width="1215px")
Measurement does not exist on index date
case_data <- rbind(case_data0,data.frame(id=4:5, content=c("eGFR=60.62", "eGFR=59.71"), start=c("2021-05-01", "2021-05-15"), end=c(NA, NA), type=c("box", "box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",2)), group=c(3,3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "240px",width="1215px")
Interval $t$ is the first interval and not the last interval, and the unit is deemed exposed to one of the exposure levels. $L(0)$ is set to the last measurement strictly after index date up to and including (if setCovariate(...,acute_change=FALSE)), or not including, day when exposure to level $j$ is first initiated. If no such measurement is available then the measurement on the index date is used instead (even if exposure to level $j$ starts on the index date and acute_change=TRUE).
Measurement exists on and after index date
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("eGFR=62.95", "eGFR=60.62", "eGFR=59.71", "A=2","2021-05-15","2021-05-20"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15","2021-05-15","2021-05-20"), end=c(NA, NA, NA, "2021-05-20",NA,NA), type=c("box", "box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3,3,3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=59.71")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "311px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("eGFR=62.95", "eGFR=60.62", "eGFR=59.71", "A=2","2021-05-15","2021-05-20"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15","2021-05-15","2021-05-20"), end=c(NA, NA, NA, "2021-05-20",NA,NA), type=c("box", "box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3,3,3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=60.62")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "311px",width="1215px")
Measurement do not exists after index date
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("eGFR=62.95", "A=2","2021-05-15","2021-05-20"), start=c("2021-04-21", "2021-05-15","2021-05-15","2021-05-20"), end=c(NA, "2021-05-20",NA,NA), type=c("box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=62.95")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "311px",width="1215px")
Measurement do not exists on or after index date
case_data <- rbind(case_data0,data.frame(id=4:6, content=c("A=2","2021-05-15","2021-05-20"), start=c("2021-05-15","2021-05-15","2021-05-20"), end=c("2021-05-20",NA,NA), type=c("background","box","box"), style=c(rep("background-color: #80B78A; font-size: 8pt",3)), group=c(2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "274px",width="1215px")
The unit is not deemed to change exposure status during interval $t$, and interval $t$ is not the last interval or the first interval. $L(t)$ is set to the last measurement in the previous interval strictly after the date when $L(t-1)$ is measured and is set to missing if no such measurement exists.
Measurements exists after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10"), end=c("2021-04-20",NA,NA, NA, NA), type=c("background","box","box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",2)), group=c(1,3,4, 3,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=60.62")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "277px",width="1215px")
Measurements do not exist after L(t-1)
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30"), end=c("2021-04-20",NA,NA, NA), type=c("background","box","box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1)), group=c(1,3,4, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "277px",width="1215px")
The unit is deemed to change exposure status during interval $t$, and $t$ is not the last or the first interval. $L(t)$ is set to the last measurement in either the previous interval strictly after the date when $L(t-1)$ is measured (if assignment exists) or in the current interval up to and including (if acute_change=FALSE), or not including, the day when the new exposure status begins. $L(t)$ is set to missing if no such measurement exists.
Measurements exists after $L(t-1)$ or the current interval
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "A=2","2021-04-28","2021-05-19"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28","2021-04-28","2021-05-19"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, "2021-05-19",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=61.59")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "351px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "A=2","2021-04-28","2021-05-19"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28","2021-04-28","2021-05-19"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, "2021-05-19",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.84")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "351px",width="1215px")
Measurements do not exist after $L(t-1)$ or the current interval
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "A=2","2021-04-28","2021-05-19"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-28","2021-04-28","2021-05-19"), end=c("2021-04-20",NA,NA, NA, "2021-05-19",NA,NA), type=c("background","box","box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "314px",width="1215px")
Last interval $t$, the unit is not deemed to change exposure status, and a right-censoring event occurs. (This case also applies when interval $t$ is the first and the last interval). $L(t)$ is set to the last measurement in either the previous interval strictly after the date when $L(t-1)$ is measured (if assignment exists) or in the current interval up to and including (if acute_change=FALSE), or not including, the day when $C$ occurs. If $t=0$ then $L(t)$ is set to the last measurement on or after the index date (even when acute_change=TRUE) and up to and including (if acute_change=FALSE),or not including, the day when $C$ occurs. $L(t)$ is set to missing if no such measurement exists. Note that occurrence of a censoring event C on the index date should never happen or else the user should remove the unit from the cohort data set.
Measurements exists after $L(t-1)$ or the current interval
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:11, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "C=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, NA), type=c("background","box","box", "box", "box", "box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E69138; font-size: 8pt",1)), group=c(1,3,4, 3,3,3,3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=61.59")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "314px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:11, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "C=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, NA), type=c("background","box","box", "box", "box", "box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E69138; font-size: 8pt",1)), group=c(1,3,4, 3,3,3,3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.84")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "314px",width="1215px")
Measurements do not exist after $L(t-1)$ or the current interval
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "C=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA), type=c("background","box","box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E69138; font-size: 8pt",1)), group=c(1,3,4, 3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "277px",width="1215px")
Measurements exists on or after index date
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("eGFR=62.95", "eGFR=60.62", "eGFR=59.71", "C=1"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15"), end=c(NA, NA, NA, NA), type=c("box", "box", "box", "box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(3,3,3, 3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=59.71")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "274px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("eGFR=62.95", "eGFR=60.62", "eGFR=59.71", "C=1"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15"), end=c(NA, NA, NA, NA), type=c("box", "box", "box", "box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), "background-color: #E69138; font-size: 8pt"), group=c(3,3,3, 3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=60.62")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "274px",width="1215px")
Measurements do not exist after index date
case_data <- rbind(case_data0,data.frame(id=4:5, content=c("eGFR=62.95", "C=1"), start=c("2021-04-21", "2021-05-15"), end=c(NA, NA), type=c("box", "box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",1), "background-color: #E69138; font-size: 8pt"), group=c(3, 3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=62.95")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "274px",width="1215px")
Measurements do not exist on or after index date
case_data <- rbind(case_data0,data.frame(id=4, content=c("C=1"), start=c("2021-05-15"), end=c(NA), type=c("box"), style=c("background-color: #E69138; font-size: 8pt"), group=c(3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "237px",width="1215px")
Last interval $t$, the unit is not deemed to change exposure status, and the outcome event occurs. (This case also applies when interval $t$ is first and last interval). If first_exp_rule=0 then case 6 above uses instead the algorithm described for case 13 below. $L(t)$ is set to the last measurement in either the previous interval strictly after the date when $L(t-1)$ is measured or on the index date if $t=0$ (even when acute_change=TRUE). $L(t)$ is set to missing if no such measurement exists. $L(t+1)$ is set to the last measurement strictly after the date when $L(t)$ is measured (or, if $L(t)$ is missing, strictly after the date of the last non-missing measurement in prior intervals and either strictly after the last day of the previous interval if $t>0$ or strictly after the index date $if t=0$) and before or on the day the event occurred. $L(t+1)$ is set to missing if no such measurement exists. Note that occurrence of the outcome on the index date should never happen or else the user should remove the unit from the cohort data set.
Measurements exists in previous interval strictly after $L(t-1)$; and, measurements exists after $L(t)$
case_data <- rbind(case_data0,data.frame(id=4:11, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "Y=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, NA), type=c("background","box","box", "box", "box", "box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E06666; font-size: 8pt",1)), group=c(1,3,4, 3,3,3,3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=60.62<br>L(t+1)=61.59<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "374px",width="1215px")
Measurements exists in previous interval strictly after $L(t-1)$; and, measurements do no exist after $L(t)$
case_data <- rbind(case_data0,data.frame(id=4:9, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "Y=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA, NA), type=c("background","box","box", "box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",2), rep("background-color: #E06666; font-size: 8pt",1)), group=c(1,3,4, 3,3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=60.62<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "337px",width="1215px")
Measurements do not exist in previous interval strictly after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "Y=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA), type=c("background","box","box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E06666; font-size: 8pt",1)), group=c(1,3,4, 3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "337px",width="1215px")
Measurements exist on or after index date
case_data <- rbind(case_data0,data.frame(id=4:6, content=c("eGFR=62.95", "eGFR=60.62", "Y=1"), start=c("2021-04-21", "2021-05-01", "2021-05-01"), end=c(NA, NA, NA), type=c("box", "box", "box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",2), "background-color: #E06666; font-size: 8pt"), group=c(3,3, 3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.95<br>L(t+1)=60.62<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "340px",width="1215px")
Measurement exists on index date
case_data <- rbind(case_data0,data.frame(id=4:5, content=c("eGFR=62.95", "Y=1"), start=c("2021-04-21", "2021-05-01"), end=c(NA, NA), type=c("box", "box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",1), "background-color: #E06666; font-size: 8pt"), group=c(3, 3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.95<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
Measurements do not exist on nor after index date
case_data <- rbind(case_data0,data.frame(id=4, content=c("Y=1"), start=c("2021-05-01"), end=c(NA), type=c("box"), style=c("background-color: #E06666; font-size: 8pt"), group=c(3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "297px",width="1215px")
Last interval $t$, the unit is deemed to change exposure status, and a right-censoring event occurs. (This case also applies when the interval $t$ is first and last interval). $L(t)$ is set to the last measurement in either the previous interval strictly after the date when $L(t-1)$ is measured (if assignment exists) or in the current interval up to and including (if acute_change=FALSE) , or not including, the day when $C$ occurs. If $t=0$ then $L(t)$ is set to the last measurement on or after the index date (even when acute_change=TRUE) and up to and including (if acute_change=FALSE), or not including, the day when $C$ occurs. $L(t)$ is set to missing if no such measurement exists.
Measurements exists after $L(t-1)$ or current interval
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:14, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "C=1", "A=2","2021-04-25","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28", "2021-04-25","2021-04-25","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E69138; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=61.59")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "388px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:14, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "C=1", "A=2","2021-04-25","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28", "2021-04-25","2021-04-25","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E69138; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.84")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "388px",width="1215px")
Measurements do not exist after $L(t-1)$ or current interval
case_data <- rbind(case_data0,data.frame(id=4:11, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "C=1", "A=2","2021-04-25","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-28", "2021-04-25","2021-04-25","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E69138; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "351px",width="1215px")
Measurements exists on or after index date
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("eGFR=62.95", "eGFR=60.62", "eGFR=59.71", "Y=1", "A=2","2021-04-23","2021-05-13"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15", "2021-04-23","2021-04-23","2021-05-13"), end=c(NA, NA, NA, NA, "2021-05-13",NA,NA), type=c("box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3,3,3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=59.71")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "311px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("eGFR=62.95", "eGFR=60.62", "eGFR=59.71", "Y=1", "A=2","2021-04-23","2021-05-13"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15", "2021-04-23","2021-04-23","2021-05-13"), end=c(NA, NA, NA, NA, "2021-05-13",NA,NA), type=c("box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3,3,3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=60.62")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "311px",width="1215px")
Measurements exist only on index date
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("eGFR=62.95", "Y=1", "A=2","2021-04-23","2021-05-13"), start=c("2021-04-21", "2021-05-15", "2021-04-23","2021-04-23","2021-05-13"), end=c(NA, NA, "2021-05-13",NA,NA), type=c("box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",1), "background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=62.95")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "311px",width="1215px")
Measurements do not exist on nor after index date
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("Y=1", "A=2","2021-04-23","2021-05-13"), start=c("2021-05-15", "2021-04-23","2021-04-23","2021-05-13"), end=c(NA, "2021-05-13",NA,NA), type=c("box", "background","box","box"), style=c("background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(0)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "274px",width="1215px")
The unit is deemed to change exposure status in the last interval $t$, and the outcome occurs. (This case also applies when interval $t$ is the first and last interval). If first_exp_rule=0 then case 8 above uses instead the algorithm described for case 14 below. $L(t)$ is set to the last measurement in either the previous interval strictly after the date when $L(t-1)$ is measured (if assignment exists) or in the current interval up to and including (if acute_change=FALSE), or not including, the first day when the unit changes exposure status. If $t=0$ then $L(t)$ is set to the last measurement on or after the index date (even when acute_change=TRUE) and up to and including (if acute_change=FALSE), or not including, the first day when the unit changes exposure status. $L(t)$ is set to missing if no such measurement exists. $L(t+1)$ is set to the last measurement strictly after the date when $L(t)$ is measured (or, if $L(t)$ is missing, strictly after the date of the last non-missing measurement in prior intervals and either strictly after the first day when the unit changes exposure status ifacute_change=FALSE or on or after the first day when the unit changes exposure status if acute_change=TRUE) and before or on the day the event occurred. $L(t+1)$ is set to missing if no such measurement exists.
Measurements exists in previous interval strictly after $L(t-1)$; and, measurements exists after $L(t)$
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:14, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "Y=1", "A=2","2021-04-23","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28", "2021-04-23","2021-04-23","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.84<br>L(t+1)=61.59<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "448px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:14, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "Y=1", "A=2","2021-04-23","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28", "2021-04-23","2021-04-23","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=60.62<br>L(t+1)=61.59<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "448px",width="1215px")
Measurements exists in previous interval strictly after $L(t-1)$; and, measurements do no exist after $L(t)$
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "Y=1", "A=2","2021-04-23","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-23","2021-04-23","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.84<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "448px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:12, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "Y=1", "A=2","2021-04-23","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-28", "2021-04-23","2021-04-23","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",2), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=60.62<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "411px",width="1215px")
Measurements do not exist in previous interval strictly after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:11, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "Y=1", "A=2","2021-04-23","2021-05-18"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-28", "2021-04-23","2021-04-23","2021-05-18"), end=c("2021-04-20",NA,NA, NA, NA, "2021-05-18",NA,NA), type=c("background","box","box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "411px",width="1215px")
Measurements exist on or after index date
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("eGFR=62.14", "eGFR=63.84", "eGFR=61.59", "Y=1", "A=2","2021-05-01","2021-05-13"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15", "2021-05-01","2021-05-01","2021-05-13"), end=c(NA, NA, NA, NA, "2021-05-13",NA,NA), type=c("box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3,3,3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=63.84<br>L(t+1)=61.59<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("eGFR=62.14", "eGFR=63.84", "eGFR=61.59", "Y=1", "A=2","2021-05-01","2021-05-13"), start=c("2021-04-21", "2021-05-01", "2021-05-15", "2021-05-15", "2021-05-01","2021-05-01","2021-05-13"), end=c(NA, NA, NA, NA, "2021-05-13",NA,NA), type=c("box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",3), "background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3,3,3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.14<br>L(t+1)=61.59<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
Measurements exist only on index date
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("eGFR=62.14", "Y=1", "A=2","2021-05-01","2021-05-13"), start=c("2021-04-21", "2021-05-15", "2021-05-01","2021-05-01","2021-05-13"), end=c(NA, NA, "2021-05-13",NA,NA), type=c("box", "box", "background","box","box"), style=c(rep("background-color: #C99DFA; font-size: 8pt",1), "background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.14<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
Measurements do not exist on nor after index date
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("Y=1", "A=2","2021-05-01","2021-05-13"), start=c("2021-05-15", "2021-05-01","2021-05-01","2021-05-13"), end=c(NA, "2021-05-13",NA,NA), type=c("box", "background","box","box"), style=c("background-color: #E06666; font-size: 8pt", rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "297px",width="1215px")
The rules above are implemented for each interval $t$ until after the first time $t$ (if any) when $A(t)$ is assigned a value other than 0/'not exposed'. For all subsequent intervals $t$ (if any), the following rules are applied iteratively instead. If the variable $X$ referenced below is not specified explicitly by the user in the function construct() (section 3 – see exp_threshold), it is then is set to 0.50 by default in the current implementation of the LtAtStructuR package. We note that case 9 is skipped intentionally below. In all the examples below $X = 0.50$.
The unit is not deemed to change exposure status during interval $t$, and interval $t$ is not the last interval. $L(t)$ is set to the last measurement in the previous interval strictly after the date when $L(t-1)$ is measured. $L(t)$ is set to missing if no such measurement exists.
Measurements exists after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10"), end=c("2021-04-20",NA,NA, NA, NA), type=c("background","box","box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",2)), group=c(1,3,4, 3,3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=60.62")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "277px",width="1215px")
Measurements does not exist after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30"), end=c("2021-04-20",NA,NA, NA), type=c("background","box","box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1)), group=c(1,3,4, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "277px",width="1215px")
The unit is deemed to change exposure status during interval $t$, and interval $t$ is not the last interval: $d$ is the first day when the new exposure status is experienced in the interval. $L(t)$ is set to the last measurement in either the previous interval strictly after the date when $L(t-1)$ is measured (if assignment exists) or in the current interval up to and including (if acute_change=FALSE), or not including day $d$. $L(t)$ is set to missing if no such measurement exists. Note that if $A(t-1)=j$ (exposed status) and $A(t)=0/\text{not exposed}$ then the start of non-exposure status is defined as the first day of the interval when the unit is unexposed to any exposure levels. If the patient is always exposed during the interval then the start of non-exposure is defined as the first day of the interval by default.
Measurements exist after $L(t-1)$
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "A=2","2021-04-28","2021-05-19"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28","2021-04-28","2021-05-19"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, "2021-05-19",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=61.59")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "351px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:13, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=60.62", "eGFR=63.84", "eGFR=61.59", "A=2","2021-04-28","2021-05-19"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-23", "2021-04-28", "2021-04-28","2021-04-28","2021-05-19"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA, "2021-05-19",NA,NA), type=c("background","box","box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3,3,3,3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.84")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "351px",width="1215px")
Measurements do not exist after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "A=2","2021-04-28","2021-05-19"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-28","2021-04-28","2021-05-19"), end=c("2021-04-20",NA,NA, NA, "2021-05-19",NA,NA), type=c("background","box","box", "box", "background","box","box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 3, 2,3,4))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "314px",width="1215px")
Last interval $t$ with occurrence of a right-censoring event (exposure status may or may not change). $L(t)$ is set to the last measurement in either the previous interval strictly after the date when $L(t-1)$ is measured or in current interval up to and including (if acute_change=FALSE), or not including day when $C$ occurs. $L(t)$ is set to missing if no such measurement exists.
Measurements exist after $L(t-1)$ or current interval
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=64.37", "eGFR=61.34", "C=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-28", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA), type=c("background","box","box", "box", "box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",3), rep("background-color: #E69138; font-size: 8pt",1)), group=c(1,3,4, 3,3,3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=61.34")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "314px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=64.37", "eGFR=61.34", "C=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-10", "2021-04-28", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA, NA, NA), type=c("background","box","box", "box", "box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",3), rep("background-color: #E69138; font-size: 8pt",1)), group=c(1,3,4, 3,3,3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=64.37")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "314px",width="1215px")
Measurements do not exist after $L(t-1)$ or current interval
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "C=1"), start=c("2021-03-22","2021-03-22","2021-04-20", "2021-03-30", "2021-04-28"), end=c("2021-04-20",NA,NA, NA, NA), type=c("background","box","box", "box", "box"), style=c(rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E69138; font-size: 8pt",1)), group=c(1,3,4, 3, 3))) case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "277px",width="1215px")
Last interval $t$, the unit is not deemed to change exposure status, the outcome event occurs. $Z$ is the number of days in each interval. We call the Z-day interval before the event, $Z.last$, and the previous Z-day interval $Z.penultimate$. $L(t)$ is set to the last measurement in $Z.penultimate$ strictly after the date when $L(t-1)$ is measured. If $t=0$ then $L(t)$ is set instead to the measurement on the index date. $L(t)$ is set to missing if no such measurement exists. $L(t+1)$ is set to the last measurement strictly after the date when $L(t)$ is measured (or , strictly after the date of the last non-missing measurement in prior intervals and strictly after the last day of $Z.penultimate$ if $L(t)$ is missing) and before or on the day the event occurred. $L(t+1)$ is set to missing if no such measurement exists.
Note: case 13 is applied at t=0 only when case 13 replaces cases 6.
Measurements exist after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:19, content=c("Z.penultimate","2021-02-28","2021-03-29", "Z.last","2021-03-30","2021-04-28", "intnum=t-2","2021-02-20","2021-03-21", "intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=63.60", "eGFR=62.90", "Y=1"), start=c("2021-02-28","2021-02-28","2021-03-29", "2021-03-30","2021-03-30","2021-04-28", "2021-02-20","2021-02-20","2021-03-21", "2021-03-22","2021-03-22","2021-04-20", "2021-03-23", "2021-03-27", "2021-04-28", "2021-04-28"), end=c("2021-03-29",NA,NA, "2021-04-28",NA,NA, "2021-03-21",NA,NA, "2021-04-20",NA,NA, NA, NA, NA, NA), type=c("range","box","box", "range","box","box", "range","box","box", "range","box","box", "box", "box", "box", "box"), style=c(rep("background-color: #BF5858; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #C0C0C0; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",1)), group=c(1,3,4, 1,3,4, 1,3,4, 1,3,4, 3,3,3, 3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.60<br>L(t+1)=62.90<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "450px",width="1215px")
Measurements do not exist after $L(t-1)$
case_data <- rbind(case_data0,data.frame(id=4:17, content=c("Z.penultimate","2021-02-28","2021-03-29", "Z.last","2021-03-30","2021-04-28", "intnum=t-2","2021-02-20","2021-03-21", "intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "Y=1"), start=c("2021-02-28","2021-02-28","2021-03-29", "2021-03-30","2021-03-30","2021-04-28", "2021-02-20","2021-02-20","2021-03-21", "2021-03-22","2021-03-22","2021-04-20", "2021-03-23", "2021-04-28"), end=c("2021-03-29",NA,NA, "2021-04-28",NA,NA, "2021-03-21",NA,NA, "2021-04-20",NA,NA, NA, NA), type=c("range","box","box", "range","box","box", "range","box","box", "range","box","box", "box", "box"), style=c(rep("background-color: #BF5858; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #C0C0C0; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E06666; font-size: 8pt",1)), group=c(1,3,4, 1,3,4, 1,3,4, 1,3,4, 3, 3))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "413px",width="1215px")
Measurement exists on or after index date
case_data <- rbind(case_data0,data.frame(id=4:6, content=c("eGFR=62.95", "eGFR=61.05", "Y=1"), start=c("2021-04-21", "2021-05-10", "2021-05-17"), end=c(NA, NA, NA), type=c("box", "box", "box"), style=c(rep("background-color: #A468E8; font-size: 8pt",2), rep("background-color: #E06666; font-size: 8pt",1)), group=c(3, 3, 3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.95<br>L(t+1)=61.05<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
Measurement exists on index date
case_data <- rbind(case_data0,data.frame(id=4:5, content=c("eGFR=62.95", "Y=1"), start=c("2021-04-21", "2021-05-17"), end=c(NA, NA), type=c("box", "box"), style=c(rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E06666; font-size: 8pt",1)), group=c(3, 3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.95<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
Measurement does not exist on nor after index date
case_data <- rbind(case_data0,data.frame(id=4, content=c("Y=1"), start=c("2021-05-17"), end=c(NA), type=c("box"), style=c(rep("background-color: #E06666; font-size: 8pt",1)), group=c(3))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "297px",width="1215px")
Last interval $t$, the unit is deemed to change exposure status, the outcome event occurs during $Z.last$: $d$ is the first day when the exposure status changes in the Z-day interval preceding Y. $L(t)$ is set to the last measurement in either $Z.penultimate$ strictly after the date when $L(t-1)$ is measured ) or in $Z.last$ up to and including (if no.acute. change=1 acute_change=FALSE), or not including, day $d$ in $Z.last$. If $t=0$ then $L(t)$ is set to the last measurement on or after the index date (even when acute_change=TRUE) and up to and including (if acute_change=FALSE), or not including, the first day when the unit changes exposure status. $L(t)$ is set to missing if no such measurement exists. $L(t+1)$ is set to the last measurement strictly after the date when $L(t)$ is measured (or, if $L(t)$ is missing, , strictly after the date of the last non-missing measurement in prior intervals and either strictly after day $d$ in $Z.last$ if also no.acute. change=1 acute_change=FALSE or on or after $d$ in $Z.last$ if also no.acute. change=0 acute_change=TRUE) and before or on the day the event occurred. $L(t+1)$ is set to missing if no such measurement exists. Note that the above implies that if $d$=index date and acute_change=TRUE then $L(t)$ is set to the measurement on the index date. Note that if $A(t-1)=j$ (exposed status) and $A(t)=0/\text{not exposed}$ then the start of non-exposure status is defined as the first day of the $Z.last$ interval when the unit is unexposed to any exposure levels. If the patient is always exposed during the $Z.last$ interval then the start of non-exposure is defined as the first day of the $Z.last$ interval by default.
Note: case 14 is applied at t=0 only when case 14 replaces cases 8
Measurements exists in $Z.penultimate$ strictly after $L(t-1)$; and, measurements exists after $L(t)$
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:23, content=c("Z.penultimate","2021-03-20","2021-04-18", "Z.last","2021-04-19","2021-05-18", "intnum=t-2","2021-02-20","2021-03-21", "intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=63.50", "eGFR=62.60", "eGFR=62.90", "Y=1", "A=2","2021-04-25","2021-05-16"), start=c("2021-03-20","2021-03-20","2021-04-18", "2021-04-19","2021-04-19","2021-05-18", "2021-02-20","2021-02-20","2021-03-21", "2021-03-22","2021-03-22","2021-04-20", "2021-03-28", "2021-04-25", "2021-04-10", "2021-05-18", "2021-05-18", "2021-04-25","2021-04-25","2021-05-16"), end=c("2021-04-18",NA,NA, "2021-05-18",NA,NA, "2021-03-21",NA,NA, "2021-04-20",NA,NA, NA, NA, NA, NA, NA, "2021-05-16",NA,NA), type=c("range","box","box", "range","box","box", "range","box","box", "range","box","box", "box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #BF5858; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #C0C0C0; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 1,3,4, 1,3,4, 1,3,4, 3, 3, 3, 3, 3, 2,3,4))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.50<br>L(t+1)=62.90<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "561px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:23, content=c("Z.penultimate","2021-03-20","2021-04-18", "Z.last","2021-04-19","2021-05-18", "intnum=t-2","2021-02-20","2021-03-21", "intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=63.50", "eGFR=62.60", "eGFR=62.90", "Y=1", "A=2","2021-04-25","2021-05-16"), start=c("2021-03-20","2021-03-20","2021-04-18", "2021-04-19","2021-04-19","2021-05-18", "2021-02-20","2021-02-20","2021-03-21", "2021-03-22","2021-03-22","2021-04-20", "2021-03-28", "2021-04-25", "2021-04-10", "2021-05-18", "2021-05-18", "2021-04-25","2021-04-25","2021-05-16"), end=c("2021-04-18",NA,NA, "2021-05-18",NA,NA, "2021-03-21",NA,NA, "2021-04-20",NA,NA, NA, NA, NA, NA, NA, "2021-05-16",NA,NA), type=c("range","box","box", "range","box","box", "range","box","box", "range","box","box", "box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #BF5858; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #C0C0C0; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",4), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 1,3,4, 1,3,4, 1,3,4, 3, 3, 3, 3, 3, 2,3,4))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=62.60<br>L(t+1)=62.90<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "561px",width="1215px")
Measurements exists in $Z.penultimate$ strictly after $L(t-1)$; and, measurements do no exist after $L(t)$
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:22, content=c("Z.penultimate","2021-03-20","2021-04-18", "Z.last","2021-04-19","2021-05-18", "intnum=t-2","2021-02-20","2021-03-21", "intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "eGFR=63.50", "eGFR=62.60", "Y=1", "A=2","2021-04-25","2021-05-16"), start=c("2021-03-20","2021-03-20","2021-04-18", "2021-04-19","2021-04-19","2021-05-18", "2021-02-20","2021-02-20","2021-03-21", "2021-03-22","2021-03-22","2021-04-20", "2021-03-28", "2021-04-25", "2021-04-10", "2021-05-18", "2021-04-25","2021-04-25","2021-05-16"), end=c("2021-04-18",NA,NA, "2021-05-18",NA,NA, "2021-03-21",NA,NA, "2021-04-20",NA,NA, NA, NA, NA, NA, "2021-05-16",NA,NA), type=c("range","box","box", "range","box","box", "range","box","box", "range","box","box", "box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #BF5858; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #C0C0C0; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 1,3,4, 1,3,4, 1,3,4, 3, 3, 3, 3, 2,3,4))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=63.50<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "561px",width="1215px")
Measurements do not exist in $Z.penultimate$ strictly after $L(t-1)$, or in $Z.last$
case_data <- rbind(case_data0,data.frame(id=4:20, content=c("Z.penultimate","2021-03-20","2021-04-18", "Z.last","2021-04-19","2021-05-18", "intnum=t-2","2021-02-20","2021-03-21", "intnum=t-1","2021-03-22","2021-04-20", "eGFR=62.95", "Y=1", "A=2","2021-04-25","2021-05-16"), start=c("2021-03-20","2021-03-20","2021-04-18", "2021-04-19","2021-04-19","2021-05-18", "2021-02-20","2021-02-20","2021-03-21", "2021-03-22","2021-03-22","2021-04-20", "2021-03-28", "2021-05-18", "2021-04-25","2021-04-25","2021-05-16"), end=c("2021-04-18",NA,NA, "2021-05-18",NA,NA, "2021-03-21",NA,NA, "2021-04-20",NA,NA, NA, NA, "2021-05-16",NA,NA), type=c("range","box","box", "range","box","box", "range","box","box", "range","box","box", "box", "box", "background","box","box"), style=c(rep("background-color: #BF5858; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",3), rep("background-color: #C0C0C0; font-size: 8pt",3), rep("background-color: #7D7D7D; font-size: 8pt",3), rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(1,3,4, 1,3,4, 1,3,4, 1,3,4, 3, 3, 2,3,4))) case_data[1,"type"] <- "range" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Prior Variable Assignment:</b><br>L(t-1)=62.95<br><b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "524px",width="1215px")
Measurement exists on or after index date; and, measurements exists after $L(t)$
acute_change=FALSE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("eGFR=62.95", "eGFR=61.05", "eGFR=62.65", "Y=1", "A=2","2021-04-28","2021-05-16"), start=c("2021-04-21", "2021-05-10", "2021-04-28", "2021-05-17", "2021-04-28","2021-04-28","2021-05-16"), end=c(NA, NA, NA, NA, "2021-05-16",NA,NA), type=c("box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #A468E8; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 3, 3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.65<br>L(t+1)=61.05<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
acute_change=TRUE
case_data <- rbind(case_data0,data.frame(id=4:10, content=c("eGFR=62.95", "eGFR=61.05", "eGFR=62.65", "Y=1", "A=2","2021-04-28","2021-05-16"), start=c("2021-04-21", "2021-05-10", "2021-04-28", "2021-05-17", "2021-04-28","2021-04-28","2021-05-16"), end=c(NA, NA, NA, NA, "2021-05-16",NA,NA), type=c("box", "box", "box", "box", "background","box","box"), style=c(rep("background-color: #A468E8; font-size: 8pt",3), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 3, 3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.95<br>L(t+1)=61.66<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
Measurement exists on index date
case_data <- rbind(case_data0,data.frame(id=4:8, content=c("eGFR=62.95", "Y=1", "A=2","2021-04-28","2021-05-16"), start=c("2021-04-21", "2021-05-17", "2021-04-28","2021-04-28","2021-05-16"), end=c(NA, NA, "2021-05-16",NA,NA), type=c("box", "box", "background","box","box"), style=c(rep("background-color: #A468E8; font-size: 8pt",1), rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=62.95<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "334px",width="1215px")
Measurement does not exist on nor after index date
case_data <- rbind(case_data0,data.frame(id=4:7, content=c("Y=1", "A=2","2021-04-28","2021-05-16"), start=c("2021-05-17", "2021-04-28","2021-04-28","2021-05-16"), end=c(NA, "2021-05-16",NA,NA), type=c("box", "background","box","box"), style=c(rep("background-color: #E06666; font-size: 8pt",1), rep("background-color: #80B78A; font-size: 8pt",3)), group=c(3, 2,3,4))) case_data[1,"content"] <- "intnum=0" case_groups <- data.frame(id=1:5,content=c("Interval coursening", "Exposures", "Start date", "End date", "<b>Variable Assignment:</b><br>L(t)=NA<br>L(t+1)=NA<br>A(t+1)=NA<br>Y(t+1)=1")) timevis::timevis(data=case_data, groups=case_groups, showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "297px",width="1215px")
Finally, for time-independent covariates the covariate $L(t)$ for interval $t=0$ is set, for each subject, to its measurement (if any) at the index date contained in the cohort data set. Following the assignment of values to the covariates $L(t)$ according to the logic described above, any missing values at interval $t=0$ are imputed according to the methods specified by the impute argument of the setCovarite() function. Any subsequent missing values (i.e., at $t>0$) are replaced by carrying forward the covariate value in the previous interval (possibly an imputed value). For each time-dependent covariate with potential missing values (i.e., covariates of type sporadic), an indicator of either imputation or of last value carried forward is created and included in the output data set.
Finally, for each subject, the values $L(t)$ for $t=0,1,...$ of each time-independent covariate are set to the value specified at the index date in the input cohort data set. If this value is missing, the values $L(t)$ are set to an imputed value according to the method specified by the list element value of impute to the argument L0_timeIndep of the setCohort() function. An indicator of imputation is created for each covariate and included in the output data set.
Here we detail the structuring algorithm (with or without data coarsening) that is implemented by the construct routine of the LtAtStructuR package when it operates on an LtAtData object that was constructed based on an exposure object created with a call to the setInstantExposure function (as opposed to a call to the setExposure function).
Starting on the index date for each subject, the follow-up time (expressed in days) is first coarsened into consecutive intervals of unit_time days each until the subject's end of follow-up (EOF) is reached, i.e., the earliest of either the occurrence of a censoring event or the failure event of interest. The intnum column of the output data set contains integers that index the resulting follow-up intervals with 0 encoding the first follow-up interval. The size of the coarsening interval is specified by the user with the argument unit_time of the construct function. Below is an example of follow-up coarsening for one patient with unit_time=30.
library(timevis) library(lubridate) `%+%` <- function(a, b) paste0(a, b) maxIntnum <- 10 unitTime <- 30 indexDate <- as_date("2020-04-12") eofDate <- indexDate+maxIntnum*unitTime-ceiling(unitTime/2) startDate <- indexDate+(0:(maxIntnum-1))*unitTime endDate <- indexDate+(1:(maxIntnum))*unitTime-1 data0 <- data.frame( id = 1:(maxIntnum*3+2), content = c("intnum="%+%0:(maxIntnum-1), as.character(startDate), as.character(endDate),"EOF date="%+%eofDate,"Index date="%+%indexDate), start = c(startDate,startDate,endDate,eofDate,indexDate), end = c(endDate,rep(NA,maxIntnum*2),NA,NA), type= c(rep("background",maxIntnum),rep("box",maxIntnum*2+2)), style=c(rep(c("background-color: #C0C0C0; font-size: 8pt","background-color: #808080;font-size: 8pt"),maxIntnum/2),rep(c("background-color: #C0C0C0; font-size: 8pt","background-color: #808080; font-size: 8pt"),maxIntnum/2),rep(c("background-color: #C0C0C0; font-size: 8pt","background-color: #808080; font-size: 8pt"),maxIntnum/2),rep("font-size: 8pt",2)), group = c(rep(2,maxIntnum),rep(3,maxIntnum),rep(4,maxIntnum),1,1) ) data0$style <- as.character(data0$style) timevis(data0, groups=data.frame(id=1:4,content=c("Follow-up time","Interval coarsening","Interval start","Interval end")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "200px",width="1215px")
The right-censoring process is implicitly considered part of the exposure process.
The binary variable that indicates the occurrence of a right-censoring event at interval intnum=t for $t=0,1,2,\ldots$ is denoted by $C(t)$. The values of the right-censoring process $\bar{C}=(C(0),C(1),\ldots)$ are stored in the censor column of the output data set. The value for $C(t)$ is set to 0 except for a subject whose end of follow-up is due to a right-censoring event in which case it is set to 1 in the follow-up interval that contains the EOF (end of follow-up) date.
Using the example above, the output data set would contain the following right-censoring information if the subject's EOF reason is a right-censoring event (left table) or the failure event (right table):
eg.censored <- data.frame("Subject.ID"="J. Doe","intnum"=0:9,"censor"=c(rep(0,9),1)) eg.failed <- data.frame("Subject.ID"="J. Doe","intnum"=0:9,"censor"=rep(0,10)) knitr::kables(list( knitr::kable(eg.censored,caption = "EOF reason is censoring"), knitr::kable(eg.failed, caption = "EOF reason is failure") )) library(LtAtStructuR) library(data.table) cohortDT <- setCohort( rbind(data.table("Subject.ID"="J. Doe","INDEX_DT"=indexDate,"eof_dt"=eofDate,"eof_reason"="disenroll","sex"="female","a1c"=9.2), data.table("Subject.ID"="J. Smith","INDEX_DT"=indexDate,"eof_dt"=eofDate,"eof_reason"="MI","sex"="male","a1c"=7.2)), "Subject.ID", "INDEX_DT", "eof_dt", "eof_reason", "MI",c("sex","a1c"), list("sex"=list("categorical"=TRUE, "impute"=NA, "impute_default_level"=NA) )) expDT <- setInstantExposure( rbind(data.table("Subject.ID"="J. Doe","fill.date"=indexDate,"D.t"="analog insulin","Q.t"=15), data.table("Subject.ID"="J. Doe","fill.date"=indexDate+10,"D.t"="analog insulin","Q.t"=90), data.table("Subject.ID"="J. Doe","fill.date"=indexDate+10+80,"D.t"="analog insulin","Q.t"=90), data.table("Subject.ID"="J. Doe","fill.date"=indexDate+10+90,"D.t"="human insulin","Q.t"=15), data.table("Subject.ID"="J. Doe","fill.date"=indexDate+10+90+30,"D.t"="human insulin","Q.t"=180), data.table("Subject.ID"="J. Smith","fill.date"=indexDate,"D.t"="analog insulin","Q.t"=15), data.table("Subject.ID"="J. Smith","fill.date"=indexDate+1,"D.t"="analog insulin","Q.t"=90), data.table("Subject.ID"="J. Smith","fill.date"=indexDate+2,"D.t"="human insulin","Q.t"=90) ), "Subject.ID", "fill.date", c("D.t","Q.t")) a1cData <- rbind(data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2020-03-10"),"a1c"=6.6), data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2020-04-21"),"a1c"=8.8), data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2020-07-15"),"a1c"=7.0), data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2020-08-20"),"a1c"=6.9), data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2020-10-01"),"a1c"=6.5), data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2021-01-05"),"a1c"=7.5), data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2021-01-22"),"a1c"=7.7), data.table("Subject.ID"="J. Doe","a1c.dt"=as_date("2021-04-19"),"a1c"=10) ) a1cDT <- setCovariate(a1cData,type="sporadic",IDvar="Subject.ID",L_date="a1c.dt",L_name="a1c",categorical=FALSE,acute_change=FALSE) suppressWarnings(LtAt.specification <- cohortDT + expDT + a1cDT) LtAt.data <- construct( LtAt.specification, time_unit = 30, dates=TRUE) LtAt.data.all <- construct( LtAt.specification, time_unit = 30, dates=TRUE, summary_cov_var="all")
The vector of variable(s) that represent(s) the user-specified exposure at interval intnum=t for $t=0,1,2,\ldots$ is denoted by $A(t)=(A_0(t),A_1(t),\ldots,A_p(t))$ where $p$ is the length of the argument exp_level passed by the user to the setInstantExposure function.
For instance, in a study of the effect of medication (re)fill patterns, a subject's exposure regimen can be characterized by whether a prescription is (re)filled at each follow-up interval $\big(\bar{A}_0=(A_0(0),A_0(1),\ldots)\big)$ along with the type of drug dispensed $\big(\bar{A}_1=(A_1(0),A_1(1),\ldots)\big)$ and the days of supply $\big(\bar{A}_2=(A_2(0),A_2(1),\ldots)\big)$ provided to the subject at each pharmacy encounter that occurs during the subject's follow-up. The following sample data illustrate the structure of the input data set that the user could pass to the setInstantExposure function using the data argument to encode the exposure regimen for one subject:
knitr::kable(expDT$data[Subject.ID=="J. Doe",], caption = "Input exposure data")
The user would then indicate the columns that encode drug dispensing information by passing exp_date="fill.date" and exp_level=c("D.t",Q.t") to the setInstantExposure function. In this example, the reference exposure level is implicitly defined as the absence of a drug dispensing event.
The binary variable(s) $A_0(t)$ indicate(s) exposure to one or more non-reference exposure level during interval intnum=t. Using the pharmacy dispensing example, $A_0(t)$ would then encode the total number of drug dispensing events during follow-up interval $t$. Specifically, $A_0(t)$ is defined as a vector of binary variables $A_0(t)=(A_{0,1}(t),\ldots,A_{0,q}(t))$ where $q$ is the maximum number of dispensing event for any given subject and any given follow-up interval $t$. If, $q$ is strictly greater than the value (default is 100) of the argument max_exp_var passed to the construct function then the algorithm will be interrupted and will return an error message without producing an output data set. This behavior is implemented to avoid the construction of an extremely wide output data set without prior user consent. The binary variable $A_{0,j}(t)$ for $j=1,\ldots,q$ indicates whether the subject had at least $j$ drug dispensing(s). For example, with $q=3$, $A_0(t)=(1,1,0)$ would indicate dispensing of two prescriptions during interval $t$. In the output data set, the values of the process $\bar{A}0=(\bar{A}{0,1},\ldots,\bar{A}{0,q})$ are stored in $q$ columns named exposure.1, exposure.2, etc. where column exposure.j stores the values for the process $\bar{A}{0,j}=(A_{0,j}(0),A_{0,j}(1),\ldots)$.
The vector $(A_1(t),\ldots,A_p(t))$ is nil if exp_level=NA and otherwise it describes all non-reference exposure levels experienced by the subject during interval $t$. We note that non-reference exposure levels experienced before the index date or after the EOF date are ignored, i.e., they are not captured by the output data set. The number of non-reference exposure levels experienced by a subject ($\leq q$) at interval $t$ is stored in the column maxExp of the output data set. When a subject experiences strictly more than one non-reference exposure level during interval $t$, these exposure events are temporally ranked using the dates in the exp_date column of the exposure input data set. In case of ties, exposure events are ranked by increasing values in the exp_level columns of the exposure input data set (starting with exp_level[1], then exp_level[2], etc). Using this ranking, the $j^{th}$ non-reference exposure level experienced by the subject during interval $t$ is encoded by the $p$ variable(s) $(A_{1,j}(t),\ldots,A_{p,j}(t))$ with $j=1,\ldots,$maxExp. If $A_{0,j}(t)=0$, $(A_{1,j}(t),\ldots,A_{p,j}(t))$ is nil and otherwise it encodes the $j^{th}$ non-reference exposure event experienced by the subject during interval $t$. In the output data set, the values of $(\bar{A}{1,j} = (A{1,j}(0),A_{1,j}(1),\ldots),\ldots,\bar{A}{p,j} = (A{p,j}(0),A_{p,j}(1),\ldots))$ are stored in $p$ columns named *.j where * stands for the $p$ character strings specified by the user with exp_level.
Using the pharmacy dispensing example and assuming that subjects of the cohort experienced at most $q=3$ pharmacy dispensing events at any given follow-up interval, the non-reference exposure levels experienced by any given subject at any given interval $t$ would then be encoded by the vector $(A_1(t),A_2(t))$ where $A_1(t)=(A_{1,1}(t),A_{1,2}(t),A_{1,3}(t))$ represents the drug type(s) dispensed at each possible pharmacy encounter during the interval and $A_2(t)=(A_{2,1}(t),A_{2,2}(t),A_{2,3}(t))$ represents the corresponding days of supply. The columns of the output data set that encode $A_1(t)$ are named "D.t.1", "D.t.2", and "D.t.3". The columns of the output data set that encode $A_2(t)$ are named "Q.t.1", "Q.t.2", and "Q.t.3". The following table illustrates the output data set obtained with the algorithm just described using the example subject and pharmacy dispensing exposure data given above when the subject's EOF reason is a censoring event:
knitr::kable(LtAt.data[Subject.ID=="J. Doe",][,-c("eof_reason","outcome","sex","I.sex","a1c","dt.a1c","I.a1c")], caption = "Output data")
Note that the column(s) containing the dates of the non-reference exposure events (e.g., fill.date.1) are only retained in the output if the user sets the argument dates to TRUE when calling the function construct.
The algorithm implemented for assigning the measurements of time-dependent covariates to the follow-up intervals intnum=t adheres to a twofold principle: 1) measurements of time-dependent covariates assigned to interval $t$ temporally precede or can be assumed to precede all exposure measurements assigned to the same interval; 2) each measurement of a time-dependent covariate is assigned to only one interval. As a result of the assignment algorithm detailed below, all measurements of time-dependent covariates assigned to interval $t$ precede those assigned to interval $t+1$.
The outcome process is considered one element of the covariate process and is denoted by $\bar{Y}=(Y(0), Y(1), \ldots)$ where $Y(t)$ indicates the occurrence of the failure event of interest during interval intnum=t-1 for $t=0,1,\ldots$. The values of the outcome process $\bar{Y}$ are stored in the outcome column of the output data set. For each subject whose EOF reason is failure occurrence, an artificial follow-up interval intnum is included in the output data set to encode outcome occurrence. Using the example above,the output data set would contain the following outcome and right-censoring information if the subject's EOF reason is a right-censoring event (left table) or the failure event (right table):
eg.censored <- data.frame("Subject.ID"="J. Doe","intnum"=0:9,"censor"=c(rep(0,9),1),"eof_reason"="disenroll") eg.failed <- data.frame("Subject.ID"="J. Doe","intnum"=0:10,"censor"=c(rep(0,10),0),"outcome"=c(rep(0,10),1),"eof_reason"="AMI") knitr::kables(list( knitr::kable(eg.censored,caption = "EOF reason is censoring"), knitr::kable(eg.failed, caption = "EOF reason is failure") ))
The example output above assumes that the user set the argument EOF_type to "eof_reason" when calling the setCohort function, i.e., "eof_reason" is the name of the column of the cohort data set that contains the reasons for end of follow-up for each subject such as disenrollment from the health plan (encoded with the value "disenroll" in the sample) and acute myocardial infarction (encoded with the value "AMI" in the example).
For all other time-dependent covariates, measurement assignment is determined by the look-back window associated with each follow-up interval $t$. The definitions of look-back windows are covariate-specific. Each measurement of a time-dependent covariate is assigned to the first follow-up interval $t$ whose look-back window contains the measurement date.
For a given covariate, look-back windows are defined as follows based on the acute_change value passed by the user to the setCovariate function when defining the time-dependent covariate:
data <- data0[ c(1,11,21), ] data$content <- as.character(data$content) data$content[1] <- "intnum = 0" data <- rbind(data,data.frame(id=26, content="index date only", start=as_date("2020-04-12"), end=as_date("2020-04-12"), type="box", style="background-color: #80B78A; font-size: 8pt", group=6)) data$group <- data$group-1 timevis(data, groups=data.frame(id=1:5,content=c("Interval coarsening","Interval start date (example)","Interval end date (example)","exposure.1 at t=0 is 0","Look-back window for interval 0")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "234px",width="1200px")
data[data$id==26,"content"] <- "interval 0 through first exposure date (inclusive if acute_change=FALSE)" data[data$id==26,"end"] <- as_date("2020-05-02") data[data$id==26,"type"] <- "background" data <- rbind(data,data.frame(id=25, content="example date of first exposure: 2020-05-02", start=as_date("2020-05-02"), end=as_date(NA), type="box", style="font-size: 8pt", group=4)) timevis(data, groups=data.frame(id=1:5,content=c("Interval coarsening","Interval start date (example)","Interval end date (example)","exposure.1 at t=0 is 1","Look-back window for interval 0")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "219px",width="1200px")
data[data$id==26,"content"] <- "interval 0 through right-censoring date (inclusive if acute_change=FALSE)" data[data$id==26,"end"] <- as_date("2020-05-06") data[data$id==25,"content"] <- "example right-censoring date: 2020-05-06" data[data$id==25,"start"] <- as_date("2020-05-06") timevis(data, groups=data.frame(id=1:5,content=c("Interval coarsening","Interval start date (example)","Interval end date (example)","censor at t=0 is 1","Look-back window for interval 0")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "219px",width="1200px")
data <- data0[ c(2:3,12:13,22:23), ] data$content <- as.character(data$content) data$content[1:2] <- c("intnum = t-1","intnum = t") data <- rbind(data,data.frame(id=26, content="interval t-1", start=as_date("2020-05-12"), end=as_date("2020-06-10"), type="background", style="background-color: #80B78A; font-size: 8pt", group=6)) data$group <- data$group-1 timevis(data, groups=data.frame(id=1:5,content=c("Interval coarsening","Interval start date (example)","Interval end date (example)","exposure.1 at t is 0","Look-back window for interval t")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "211px",width="1200px")
data <- rbind(data,data.frame(id=25, content="example date of first exposure: 2020-06-23", start=as_date("2020-06-23"), end=as_date(NA), type="box", style="font-size: 8pt", group=4)) data[data$id==26,"content"] <- "interval t-1 + interval t only through first exposure date (inclusive if acute_change=FALSE)" data[data$id==26,"end"] <- as_date("2020-06-23") timevis(data, groups=data.frame(id=1:5,content=c("Interval coarsening","Interval start date (example)","Interval end date (example)","exposure.1 at t is 1","Look-back window for interval t")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "219px",width="1200px")
data[data$id==26,"content"] <- "interval t-1 + interval t only through right-censoring date (inclusive if acute_change=FALSE)" data[data$id==26,"end"] <- as_date("2020-06-29") data[data$id==25,"content"] <- "example data of right-censoring event: 2020-06-29" data[data$id==25,"start"] <- as_date("2020-06-29") timevis(data, groups=data.frame(id=1:5,content=c("Interval coarsening","Interval start date (example)","Interval end date (example)","censor at t is 1","Look-back window for interval t")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "219px",width="1200px")
data[data$id==26,"content"] <- "interval t-1 only through failure date (inclusive)" data[data$id==26,"end"] <- as_date("2020-05-27") data[data$id==25,"content"] <- "example failure date: 2020-05-27" data[data$id==25,"start"] <- as_date("2020-05-27") timevis(data, groups=data.frame(id=1:5,content=c("Interval coarsening","Interval start date (example)","Interval end date (example)","outcome at t is 1","Look-back window for interval t")), showZoom=FALSE, options = list( showCurrentTime = FALSE), height = "219px",width="1200px")
The vector of variable(s) that represent(s) the user-specified time-dependent covariate measurement(s) at interval intnum=t for $t=0,1,2, \ldots$ is denoted by $L(t)=(L_1(t),\ldots,L_s(t))$ where $s$ is the number of distinct time-dependent attributes that are user-specified with separate calls to setCovariate. For each time-dependent covariate $j=1,\ldots,s$, $q_j$ denotes the maximum number of measurements for covariate $j$ found in the look-back window for any given follow-up interval $t$ and any given subject. If, for any $j$, $q_j$ is strictly greater than the value (default is 100) of the argument max_cov_var passed to the construct function then the algorithm will be interrupted and will return an error message without producing an output data set. This behavior is implemented to avoid the construction of an extremely wide output data set without prior user consent. The covariate $L_j(t)$ is defined as the vector of random variables $(L_{j,1}(t),\ldots,L_{j,q_j}(t))$ where $L_{j,k}$ for $k=1,\ldots, q_j$ represents the $k^{th}$ temporally ordered measurement of covariate $j$ found in the look-back window associated with interval $t$. Temporal ordering is defined using the measurement dates specified by the user with the L_date argument passed to the setCovariate when defining covariate $j$. We note that if a measurement with a collection date equal to the index date is provided for covariate $j$ in both the input cohort data set specified with setCohort and the input covariate data set specified with setCovariate, the algorithm assumes that the measurement provided in the cohort data set precede that of the covariate data set. In the output data set, the values of $(\bar{L}{j,1}=(L{j,1}(0),L_{j,1}(1),\ldots), \ldots, \bar{L}{j,q{j}}=(L_{j,q_j}(0),L_{j,q_j}(1),\ldots))$ are stored in $q_j$ columns named *.k for $k=1,\ldots,q_j$ where * stands for the character string L_name specified by the user when calling setCovariate to define covariate $j$. For each covariate $j$, the last measurement found in the look-back window associated with each follow-up interval $t$ is stored in a separate column of the output data set named L_name. This last covariate column is the only one retained in the output data set if the user set the argument summary_cov_var to "last" when calling the construct function. Finally, the number of measurements collected on a subject ($\leq q_j$) at interval $t$ for covariate $j$ is stored in the column max.* of the output data set where * stands for the character string L_name.
The following sample data illustrates the structure of the input data sets that the user could pass to the setCohort and setCovariate function using the data argument to define time-dependent glycemia measurements (A1c) (type=sporadic) in the pharmacy example problem above:
knitr::kables(list( knitr::kable(cohortDT$data[Subject.ID=="J. Doe",], caption = "Input cohort data"), knitr::kable(a1cData, caption = "Input A1c data") #a1cDT$data[Subject.ID=="J. Doe",] ))
The algorithm described above would result in the following assignment of covariate measurements in the output data set:
knitr::kable(LtAt.data[Subject.ID=="J. Doe",][,-c("eof_reason","outcome","sex","I.sex","maxExp","exposure.2","fill.date.2","D.t.2","Q.t.2","exposure.3","fill.date.3","D.t.3","Q.t.3","D.t.1","Q.t.1")], caption = "Output data")
After covariate assignment, imputation of missing covariate values at intnum=0 is implemented first before imputation of all other covariate misusing values by last observed value carried forward. The details of the imputation step are the same as those of the data structuring algorithm with interval exposures. Note that this imputation step is only implemented for the columns of the output data set that contain the last measurements in each follow-up interval of the time-dependent covariates, i.e., the column a1c in the example output data above. Corresponding indicator(s) of imputation are created and denoted by the column I.* (e.g., I.a1c in the example above).
Note that the column(s) containing the dates of the A1c measurements (e.g., dt.a1c) are only retained in the output data set if the user sets the argument dates to TRUE when calling the function construct.
Finally, we note that time-independent covariates (e.g., sex in the input cohort data above) and output data format (e.g., format="MSM SAS macro") are handled using the same processing steps as those of the data structuring algorithm with interval exposures.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.