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)
Cyclops currently doesn't support left-truncated Cox models. Could this be added?
(Needed for OHDSI/CohortMethod#198)