stan-dev / stan-dev/rstanarm

stan_surv doesn't interpret correctly NAs with type="interval2" survival data

Open
#487 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug survival
Dominant language
R
Stars
401
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Summary:

stan_surv doesn't interpret correcty the convention of having NAs instead of infinite values with type = "interval2" survival data.

Description:

As per ?Surv, when type = "interval2" is specified, "Infinite values can be represented either by actual infinity (Inf) or NA. The second form has proven to be the more useful one."

However, stan_surv seem to interpret correctly only the first form (infinite values).

From the reproducible example below.
First form (infinite values):

stan_surv
 baseline hazard: M-splines on hazard scale
 formula:         Surv(l, u, type = "interval2") ~ grp
 observations:    144
 events:          0 (0%)
 left censored:   62 (43.1%)
 right censored:  82 (56.9%)
 delayed entry:   no

Second form (NAs):

stan_surv
 baseline hazard: M-splines on hazard scale
 formula:         Surv(l, u, type = "interval2") ~ grp
 observations:    82
 events:          0 (0%)
 right censored:  82 (100%)
 delayed entry:   no
Reproducible Steps:
library(rstanarm)
library(tidyverse)

stan_surv(Surv(l, u, type = "interval2") ~ grp, 
          data = mice, chains = 1, refresh = 0, iter = 600)

mice2 <- 
  mice %>% 
  mutate(l = replace(l, is.infinite(l), NA_real_),
         u = replace(u, is.infinite(l), NA_real_))

stan_surv(Surv(l, u, type = "interval2") ~ grp, 
                        data = mice2, chains = 1, refresh = 0, iter = 600)
RStanARM Version:

2.21.2

R Version:

3.6.3

Operating System:

OS X 10.14.6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducible stan_surv examples in this issue, comparing interval2 data represented with Inf against the equivalent NA values. Trace how stan_surv preprocesses Surv(l, u, type = "interval2") inputs. Done means both representations produce the same observation, left-censoring, and right-censoring counts; add a regression test if the existing test structure is located.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.