Skip to content

Support left-truncated Cox? #89

@schuemie

Description

@schuemie

Cyclops currently doesn't support left-truncated Cox models. Could this be added?

library(Cyclops)
library(survival)
library(testthat)

test_that("Check very small Cox example with left truncation", {
    test <- read.table(header=T, sep = ",", text = "
start, length, event, x1, x2
1, 4,  1,0,0
0, 3.5,1,2,0
0, 3,  0,0,1
1, 2.5,1,0,1
0, 2,  1,1,1
0, 1.5,0,1,0
0, 1,  1,1,0
")
    
    goldFit <-  coxph(Surv(start, length, event) ~ x1 + x2, test)
    
    cyclopsData <- createCyclopsData(Surv(start, length, event) ~ x1 + x2, data = test, modelType = "cox")
    cyclopsFit <- fitCyclopsModel(cyclopsData)
    
    tolerance <- 1E-4
    expect_equal(coef(cyclopsFit), coef(goldFit), tolerance = tolerance)
})
# ── Failure: Check very small Cox example with left truncation ─────
# Expected `coef(cyclopsFit)` to equal `coef(goldFit)`.
# Differences:
# 2/2 mismatches (average diff: 1.23)
# [1] -0.3253 - 0.726 == -1.05
# [2]  0.0465 - 1.460 == -1.41

(Needed for OHDSI/CohortMethod#198)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions