3
$\begingroup$

Suppose we are studying some event and the observations are the pairs: time and indicator whether the event has already happened at this time. We have one observation per subject. No events happen before time 0. The event may happen only once for a subject. In other words, we have the data as pairs (time, event), where event is a binary variable indicating whether the event has happened on the interval [0,time].

Is there a standard way to treat such data? If so then what libraries am I to use in R?

$\endgroup$
  • 2
    $\begingroup$ @AdamO that would seem to be the answer (i.e. that the poster has interval censored survival data), and perhaps you should post it as such. $\endgroup$ – Weiwen Ng Mar 1 at 14:43
4
$\begingroup$

Survival analysis will meet your needs. It has the added benefit of managing left-, right-, and interval-censored events. Not everyone has to die on your watch. Not everyone has to be alive at the beginning. And some mysterious unrecorded deaths can occur, which you only discover long after the fact. All such semi problematic data will be used. The result of the analysis is a properly-modeled (Weibull family of distributions) and optimized (MLE) hazard function which then has predictive power.

If you want to implement this yourself, you can follow the excellent Wikipedia page https://en.m.wikipedia.org/wiki/Survival_analysis, which includes a full loss function if you want to implement the log-likelihood optimization yourself (with $optim$ in R) AND it includes a brief tutorial on R’s $survival$ package, which I have found more difficult to use than the loss functions, but that may say more about me than the $survival$ package.

$\endgroup$
  • 1
    $\begingroup$ @Viktor so ordered. $\endgroup$ – Peter Leopold Mar 1 at 15:56
  • 1
    $\begingroup$ I was never sure how to specify mixture data: left- and right- and interval-censored in the same data set. The documentation isn't at all clear. It seems you can pick one, but not all three. The Surv object uses a "type" attribute which is a string, not an array. I never did find the work-around in the documentation or the package, but I'm sure there has to be one. I can't debug someone else's functional spec, and I can't debug someone else's documentation, but I can debug my own implementation, so the decision to write from scratch was very, very, very easy. $\endgroup$ – Peter Leopold Mar 1 at 17:18
  • 1
    $\begingroup$ @PeterLeopold transpose data from long to wide, one row per each observation event. If subject is left, interval, and right censored then two rows needed: one from start to end of first period of observation, one from start to end of second period of observation. $\endgroup$ – AdamO Mar 1 at 22:31
  • 1
    $\begingroup$ @Viktor if there is no staggered entry, you do not use two time variables, just put the right time (what you call time2) as an argument to time. Read ?Surv $\endgroup$ – AdamO Mar 5 at 3:50
  • 3
    $\begingroup$ @AdamO Interval censoring happens if the subject is alive at time t1 and dead at t2, but there is no actual recorded time of death. en.wikipedia.org/wiki/Survival_analysis#Censoring $\endgroup$ – Peter Leopold Mar 6 at 0:58
4
$\begingroup$

When the time variable indicates the event has happened exactly at that time, the dyad of time and event yes/no is called a survival observation. Censoring occurs when a subject is not under observation for a period of time when they are at risk for the event: if the event happened you wouldn't know. For cases like death or non-recurrent events, you cannot have left or interval censored data, because the subject is never at risk for death again.

Censored data can be included in a survival analysis using a parametric or Cox proportional hazards model. In the Cox model, a semiparametric likelihood is used. One inspects only the distribution of people at risk at any event time. This set is called a risk set. If 1 person dies at time 10, everyone who is alive at time 10 comprises the risk set for that time. Censored observations are merely omitted from risk sets.

It is a different thing to say that a subject enters a study or re-enters a study at a point in time and you know that the event has happened exactly once (assuming no reoccurrence of event). This is missing survival data.

You can use typical methods of missing data, like trying to impute the event time. You can also discretize the intervals which leads to a logistic regression model with an offset for the log of time under observation and a 0/1 response for whether the event occurred.

$\endgroup$
  • $\begingroup$ Ok, I have the case of missing survival data. The event may happen only once for a subject. The problem is that all the time data is missing. Are there methods other than imputation to treat such data? May be some likelihood approach? $\endgroup$ – Viktor Mar 1 at 16:50
  • 1
    $\begingroup$ @Viktor there is the EM algorithm if you use parametric survival. $\endgroup$ – AdamO Mar 1 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.