CoxNCSpline: This function implments natural cubic splines in Cox...

View source: R/CoxNCSpline.R

CoxNCSplineR Documentation

This function implments natural cubic splines in Cox regression for latency analysis

Description

This function implments natural cubic splines in Cox regression for latency analysis

Usage

CoxNCSpline(
  data,
  time_start,
  time_end,
  status,
  exposure,
  knots_number,
  latency,
  adjusted_variable = NULL,
  adjusted_model = NULL,
  id = "id"
)

Arguments

data

A data frame containing the data

time_start

start time

time_end

end time

status

survival status. 1 for death and 0 for censored

exposure

Name of the time-varying exposure variable. From the most recent to the furthest in time.

knots_number

Pre-specified number of knots

latency

prespecified latency

adjusted_variable

A vector of adjusted variables

adjusted_model

A vector of adjusted models

id

A string to specify the name of the id column

Value

A list. The first element is the best knots with the lowest AIC. The second element is a Cox model

Examples

time_start <- "age_start"
time_end <- "age_end"
status <- "failure"
exposure <- paste0("lag", 0:19)
knots_number <- 3
latency <- 20
fit <- CoxNCSpline(sim_data, time_start, time_end, status, exposure, knots_number, latency)

LatencyA documentation built on Oct. 21, 2026, 5:14 p.m.